use of org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter in project geowave by locationtech.
the class GeoWaveGTDataStore method getAdapter.
private InternalGeotoolsFeatureDataAdapter getAdapter(final String typeName) {
final InternalGeotoolsFeatureDataAdapter featureAdapter;
final Short adapterId = internalAdapterStore.getAdapterId(typeName);
if (adapterId == null) {
return null;
}
final InternalDataAdapter<?> adapter = adapterStore.getAdapter(adapterId);
if ((adapter == null) || !(adapter instanceof InternalGeotoolsFeatureDataAdapter)) {
return null;
}
featureAdapter = (InternalGeotoolsFeatureDataAdapter) adapter;
if (featureNameSpaceURI != null) {
featureAdapter.setNamespace(featureNameSpaceURI.toString());
}
return featureAdapter;
}
use of org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter in project geowave by locationtech.
the class CQLQueryFilterTest method test.
@Test
public void test() {
final FilterFactoryImpl factory = new FilterFactoryImpl();
final Expression exp1 = factory.property("pid");
final Expression exp2 = factory.literal("a89dhd-123-abc");
final Filter f = factory.equal(exp1, exp2, false);
final Index spatialIndex = SpatialDimensionalityTypeProvider.createIndexFromOptions(new SpatialOptions());
final FeatureDataAdapter adapter = new FeatureDataAdapter(type);
final AdapterToIndexMapping indexMapping = BaseDataStoreUtils.mapAdapterToIndex(adapter.asInternalAdapter((short) -1), spatialIndex);
final InternalGeotoolsFeatureDataAdapter<SimpleFeature> internalAdapter = (InternalGeotoolsFeatureDataAdapter<SimpleFeature>) adapter.asInternalAdapter((short) -1);
final ExplicitCQLQuery cqlQuery = new ExplicitCQLQuery(null, f, internalAdapter, indexMapping);
final List<QueryFilter> filters = cqlQuery.createFilters(spatialIndex);
final List<QueryFilter> dFilters = new ArrayList<>();
for (final QueryFilter filter : filters) {
dFilters.add(filter);
}
final FilterList dFilterList = new FilterList(dFilters);
assertTrue(dFilterList.accept(spatialIndex.getIndexModel(), getEncodings(spatialIndex, internalAdapter.encode(createFeature(), indexMapping, spatialIndex)).get(0)));
}
use of org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter in project geowave by locationtech.
the class CQLQueryTest method testGeoTemporalRangeWithMatchingIndex.
@Test
public void testGeoTemporalRangeWithMatchingIndex() throws CQLException, SchemaException {
final SimpleFeatureType type = DataUtilities.createType("geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,start:Date,end:Date,pid:String");
final FeatureDataAdapter a = new FeatureDataAdapter(type);
final InternalGeotoolsFeatureDataAdapter<SimpleFeature> adapter = (InternalGeotoolsFeatureDataAdapter<SimpleFeature>) a.asInternalAdapter((short) -1);
final ExplicitCQLQuery query = (ExplicitCQLQuery) OptimalCQLQuery.createOptimalQuery("BBOX(geometry,27.20,41.30,27.30,41.20) and start during 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z", adapter, null, null);
final List<MultiDimensionalNumericData> constraints = query.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(Arrays.equals(constraints.get(0).getMinValuesPerDimension(), new Double[] { 27.2, 41.2, 1.116534776001E12 }));
assertTrue(Arrays.equals(constraints.get(0).getMaxValuesPerDimension(), new Double[] { 27.3, 41.3, 1.116538375999E12 }));
final ExplicitCQLQuery query2 = (ExplicitCQLQuery) OptimalCQLQuery.createOptimalQuery("BBOX(geometry,27.20,41.30,27.30,41.20) and end during 2005-05-19T20:32:56Z/2005-05-19T21:32:56Z", adapter, null, null);
final List<MultiDimensionalNumericData> constraints2 = query2.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(Arrays.equals(constraints2.get(0).getMinValuesPerDimension(), new Double[] { 27.2, 41.2, 1.116534776001E12 }));
assertTrue(Arrays.equals(constraints2.get(0).getMaxValuesPerDimension(), new Double[] { 27.3, 41.3, 1.116538375999E12 }));
final ExplicitCQLQuery query3 = (ExplicitCQLQuery) OptimalCQLQuery.createOptimalQuery("BBOX(geometry,27.20,41.30,27.30,41.20) and (start before 2005-05-19T21:32:56Z and end after 2005-05-19T20:32:56Z)", adapter, null, null);
final List<MultiDimensionalNumericData> constraints3 = query3.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(Arrays.equals(constraints3.get(0).getMinValuesPerDimension(), new Double[] { 27.2, 41.2, 1.116534776001E12 }));
assertTrue(Arrays.equals(constraints3.get(0).getMaxValuesPerDimension(), new Double[] { 27.3, 41.3, 1.116538375999E12 }));
final ExplicitCQLQuery query4 = (ExplicitCQLQuery) OptimalCQLQuery.createOptimalQuery("BBOX(geometry,27.20,41.30,27.30,41.20) and (start after 2005-05-19T20:32:56Z and end after 2005-05-19T20:32:56Z)", adapter, null, null);
final List<MultiDimensionalNumericData> constraints4 = query4.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(Arrays.equals(constraints4.get(0).getMinValuesPerDimension(), new Double[] { 27.2, 41.2, 1.116534776001E12 }));
assertTrue(Arrays.equals(constraints4.get(0).getMaxValuesPerDimension(), new Double[] { 27.3, 41.3, 9.223372036854775999E18 }));
}
use of org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter in project geowave by locationtech.
the class CQLQueryTest method init.
@Before
public void init() throws SchemaException {
type = DataUtilities.createType("geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,when:Date,pid:String");
final FeatureDataAdapter a = new FeatureDataAdapter(type);
adapter = (InternalGeotoolsFeatureDataAdapter<SimpleFeature>) a.asInternalAdapter((short) -1);
}
use of org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter in project geowave by locationtech.
the class GeoWaveStabilityIT method queryBadData.
private void queryBadData(final boolean badMetadata) throws Exception {
final PersistentAdapterStore badAdapterStore = badDataStore.createAdapterStore();
try {
final InternalDataAdapter<?>[] dataAdapters = badAdapterStore.getAdapters();
final InternalDataAdapter<?> adapter = dataAdapters[0];
Assert.assertTrue(adapter instanceof InternalGeotoolsFeatureDataAdapter);
Assert.assertTrue(adapter.getAdapter() instanceof GeotoolsFeatureDataAdapter);
final QueryConstraints constraints = OptimalCQLQuery.createOptimalQuery("BBOX(geom,-105,28,-87,44) and STATE = 'IL'", (InternalGeotoolsFeatureDataAdapter) adapter, null, null);
final QueryBuilder<?, ?> bldr = QueryBuilder.newBuilder();
try (final CloseableIterator<?> actualResults = badDataStore.createDataStore().query(bldr.constraints(constraints).build())) {
final int size = Iterators.size(actualResults);
LOGGER.error(String.format("Found %d results, expected exception...", size));
Assert.fail();
} catch (final Exception e) {
// Expected exception
}
} catch (final Exception e) {
if (!badMetadata) {
Assert.fail();
}
}
}
Aggregations