Search in sources :

Example 1 with InternalGeotoolsFeatureDataAdapter

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;
}
Also used : InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter)

Example 2 with InternalGeotoolsFeatureDataAdapter

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)));
}
Also used : ArrayList(java.util.ArrayList) AdapterToIndexMapping(org.locationtech.geowave.core.store.AdapterToIndexMapping) Index(org.locationtech.geowave.core.store.api.Index) FilterList(org.locationtech.geowave.core.store.query.filter.FilterList) SpatialOptions(org.locationtech.geowave.core.geotime.index.SpatialOptions) SimpleFeature(org.opengis.feature.simple.SimpleFeature) QueryFilter(org.locationtech.geowave.core.store.query.filter.QueryFilter) ExplicitCQLQuery(org.locationtech.geowave.core.geotime.store.query.ExplicitCQLQuery) Expression(org.opengis.filter.expression.Expression) QueryFilter(org.locationtech.geowave.core.store.query.filter.QueryFilter) Filter(org.opengis.filter.Filter) InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter) Test(org.junit.Test)

Example 3 with InternalGeotoolsFeatureDataAdapter

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 }));
}
Also used : MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) ExplicitCQLQuery(org.locationtech.geowave.core.geotime.store.query.ExplicitCQLQuery) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Example 4 with InternalGeotoolsFeatureDataAdapter

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);
}
Also used : FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Before(org.junit.Before)

Example 5 with InternalGeotoolsFeatureDataAdapter

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();
        }
    }
}
Also used : PersistentAdapterStore(org.locationtech.geowave.core.store.adapter.PersistentAdapterStore) GeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.GeotoolsFeatureDataAdapter) InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter) InternalGeotoolsFeatureDataAdapter(org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter) InternalDataAdapter(org.locationtech.geowave.core.store.adapter.InternalDataAdapter) QueryConstraints(org.locationtech.geowave.core.store.query.constraints.QueryConstraints)

Aggregations

InternalGeotoolsFeatureDataAdapter (org.locationtech.geowave.core.geotime.store.InternalGeotoolsFeatureDataAdapter)5 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)3 SimpleFeature (org.opengis.feature.simple.SimpleFeature)3 Test (org.junit.Test)2 ExplicitCQLQuery (org.locationtech.geowave.core.geotime.store.query.ExplicitCQLQuery)2 ArrayList (java.util.ArrayList)1 FilterFactoryImpl (org.geotools.filter.FilterFactoryImpl)1 Before (org.junit.Before)1 SpatialOptions (org.locationtech.geowave.core.geotime.index.SpatialOptions)1 GeotoolsFeatureDataAdapter (org.locationtech.geowave.core.geotime.store.GeotoolsFeatureDataAdapter)1 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)1 AdapterToIndexMapping (org.locationtech.geowave.core.store.AdapterToIndexMapping)1 InternalDataAdapter (org.locationtech.geowave.core.store.adapter.InternalDataAdapter)1 PersistentAdapterStore (org.locationtech.geowave.core.store.adapter.PersistentAdapterStore)1 Index (org.locationtech.geowave.core.store.api.Index)1 QueryConstraints (org.locationtech.geowave.core.store.query.constraints.QueryConstraints)1 FilterList (org.locationtech.geowave.core.store.query.filter.FilterList)1 QueryFilter (org.locationtech.geowave.core.store.query.filter.QueryFilter)1 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)1 Filter (org.opengis.filter.Filter)1