Search in sources :

Example 1 with ResultSet

use of org.locationtech.geowave.core.store.query.gwql.ResultSet in project geowave by locationtech.

the class GeoWaveQueryLanguageIT method testAggregations.

@Test
public void testAggregations() {
    final DataStore ds = dataStore.createDataStore();
    final DataTypeAdapter<SimpleFeature> adapter = createDataAdapter();
    final Index spatialIndex = SpatialDimensionalityTypeProvider.createIndexFromOptions(new SpatialOptions());
    ds.addType(adapter, spatialIndex);
    final Index latitudeIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, LATITUDE));
    ds.addIndex(TYPE_NAME, latitudeIndex);
    // Ingest data
    ingestData(ds);
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT BBOX(%s) FROM %s", ALT, TYPE_NAME))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(Envelope.class.isAssignableFrom(results.columnType(0)));
        assertEquals(new Envelope(-63, 63, -63, 63), results.next().columnValue(0));
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT BBOX(%s) FROM %s WHERE %s > 0", ALT, TYPE_NAME, LATITUDE))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(Envelope.class.isAssignableFrom(results.columnType(0)));
        assertEquals(new Envelope(1, 63, -63, -1), results.next().columnValue(0));
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT COUNT(%s) FROM %s", ALT, TYPE_NAME))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(Long.class.isAssignableFrom(results.columnType(0)));
        assertEquals(TOTAL_FEATURES / 2, ((Long) results.next().columnValue(0)).intValue());
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT COUNT(%s) FROM %s WHERE %s > 0", ALT, TYPE_NAME, LATITUDE))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(Long.class.isAssignableFrom(results.columnType(0)));
        assertEquals(TOTAL_FEATURES / 4, ((Long) results.next().columnValue(0)).intValue());
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT SUM(%s) FROM %s", INTEGER, TYPE_NAME, LATITUDE))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(0)));
        assertEquals(-64, ((BigDecimal) results.next().columnValue(0)).intValue());
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT SUM(%s) FROM %s WHERE %s > 0", INTEGER, TYPE_NAME, LATITUDE))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(0)));
        int expected = 0;
        for (int i = 1; i < TOTAL_FEATURES / 2; i++) {
            expected += i;
        }
        assertEquals(expected, ((BigDecimal) results.next().columnValue(0)).intValue());
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT MIN(%s) FROM %s", INTEGER, TYPE_NAME, LATITUDE))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(0)));
        assertEquals(-64, ((BigDecimal) results.next().columnValue(0)).intValue());
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT MIN(%s) FROM %s WHERE %s > 0", INTEGER, TYPE_NAME, LATITUDE))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(0)));
        assertEquals(1, ((BigDecimal) results.next().columnValue(0)).intValue());
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT MAX(%s) FROM %s", INTEGER, TYPE_NAME, LATITUDE))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(0)));
        assertEquals(63, ((BigDecimal) results.next().columnValue(0)).intValue());
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT MAX(%s) FROM %s WHERE %s < 0", INTEGER, TYPE_NAME, LATITUDE))) {
        assertEquals(1, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(0)));
        assertEquals(-1, ((BigDecimal) results.next().columnValue(0)).intValue());
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT BBOX(%s), MIN(%s), MAX(%s), SUM(%s) FROM %s", ALT, INTEGER, INTEGER, INTEGER, TYPE_NAME, LATITUDE))) {
        assertEquals(4, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(Envelope.class.isAssignableFrom(results.columnType(0)));
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(1)));
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(2)));
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(3)));
        final Result next = results.next();
        assertEquals(new Envelope(-63, 63, -63, 63), next.columnValue(0));
        assertEquals(-64, ((BigDecimal) next.columnValue(1)).intValue());
        assertEquals(63, ((BigDecimal) next.columnValue(2)).intValue());
        assertEquals(-64, ((BigDecimal) next.columnValue(3)).intValue());
        assertFalse(results.hasNext());
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT BBOX(%s), MIN(%s), MAX(%s), SUM(%s) FROM %s WHERE %s > 0", ALT, INTEGER, INTEGER, INTEGER, TYPE_NAME, LATITUDE))) {
        assertEquals(4, results.columnCount());
        assertTrue(results.hasNext());
        assertTrue(Envelope.class.isAssignableFrom(results.columnType(0)));
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(1)));
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(2)));
        assertTrue(BigDecimal.class.isAssignableFrom(results.columnType(3)));
        final Result next = results.next();
        assertEquals(new Envelope(1, 63, -63, -1), next.columnValue(0));
        assertEquals(1, ((BigDecimal) next.columnValue(1)).intValue());
        assertEquals(63, ((BigDecimal) next.columnValue(2)).intValue());
        int expected = 0;
        for (int i = 1; i < TOTAL_FEATURES / 2; i++) {
            expected += i;
        }
        assertEquals(expected, ((BigDecimal) next.columnValue(3)).intValue());
        assertFalse(results.hasNext());
    }
}
Also used : AttributeIndexOptions(org.locationtech.geowave.core.store.index.AttributeIndexOptions) DataStore(org.locationtech.geowave.core.store.api.DataStore) ResultSet(org.locationtech.geowave.core.store.query.gwql.ResultSet) Index(org.locationtech.geowave.core.store.api.Index) Envelope(org.locationtech.jts.geom.Envelope) SpatialOptions(org.locationtech.geowave.core.geotime.index.SpatialOptions) SimpleFeature(org.opengis.feature.simple.SimpleFeature) BigDecimal(java.math.BigDecimal) Point(org.locationtech.jts.geom.Point) Result(org.locationtech.geowave.core.store.query.gwql.Result) Test(org.junit.Test)

Example 2 with ResultSet

use of org.locationtech.geowave.core.store.query.gwql.ResultSet in project geowave by locationtech.

the class GeoWaveQueryLanguageIT method testNumericExpressionQueries.

@Test
public void testNumericExpressionQueries() {
    final DataStore ds = dataStore.createDataStore();
    final DataTypeAdapter<SimpleFeature> adapter = createDataAdapter();
    final Index spatialIndex = SpatialDimensionalityTypeProvider.createIndexFromOptions(new SpatialOptions());
    ds.addType(adapter, spatialIndex);
    final Index integerIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, INTEGER));
    final Index latitudeIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, LATITUDE));
    final Index longitudeIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, LONGITUDE));
    ds.addIndex(TYPE_NAME, integerIndex, latitudeIndex, longitudeIndex);
    // Ingest data
    ingestData(ds);
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s FROM %s WHERE %s > 0", INTEGER, TYPE_NAME, INTEGER))) {
        assertEquals(1, results.columnCount());
        assertEquals(TOTAL_FEATURES / 2 - 1, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s FROM %s WHERE %s < 0", LATITUDE, TYPE_NAME, LATITUDE))) {
        assertEquals(1, results.columnCount());
        assertEquals(TOTAL_FEATURES / 2, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s FROM %s WHERE %s >= 0", INTEGER, TYPE_NAME, INTEGER))) {
        assertEquals(1, results.columnCount());
        assertEquals(TOTAL_FEATURES / 2, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s FROM %s WHERE %s <= 0", LONGITUDE, TYPE_NAME, LONGITUDE))) {
        assertEquals(1, results.columnCount());
        assertEquals(TOTAL_FEATURES / 2 + 1, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s FROM %s WHERE %s = 12", INTEGER, TYPE_NAME, INTEGER))) {
        assertEquals(1, results.columnCount());
        assertEquals(1, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s FROM %s WHERE %s <> 12 AND %s <> 8", INTEGER, TYPE_NAME, INTEGER, INTEGER))) {
        assertEquals(1, results.columnCount());
        assertEquals(TOTAL_FEATURES - 2, Iterators.size(results));
    }
}
Also used : AttributeIndexOptions(org.locationtech.geowave.core.store.index.AttributeIndexOptions) DataStore(org.locationtech.geowave.core.store.api.DataStore) ResultSet(org.locationtech.geowave.core.store.query.gwql.ResultSet) Index(org.locationtech.geowave.core.store.api.Index) SpatialOptions(org.locationtech.geowave.core.geotime.index.SpatialOptions) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Example 3 with ResultSet

use of org.locationtech.geowave.core.store.query.gwql.ResultSet in project geowave by locationtech.

the class GWQLQuery method execute.

@Override
public void execute(final OperationParams params) {
    if (debug) {
        Configurator.setLevel(LogManager.getRootLogger().getName(), Level.DEBUG);
    }
    // Ensure we have all the required arguments
    if (parameters.size() != 2) {
        throw new ParameterException("Requires arguments: <store name> <query>");
    }
    final String storeName = parameters.get(0);
    // Attempt to load store.
    final DataStorePluginOptions inputStoreOptions = CLIUtils.loadStore(storeName, getGeoWaveConfigFile(params), params.getConsole());
    final String query = parameters.get(1);
    final StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    final ResultSet results = inputStoreOptions.createDataStore().query(query, authorizations.toArray(new String[authorizations.size()]));
    stopWatch.stop();
    output.output(results);
    results.close();
    if (debug) {
        LOGGER.debug("Executed query in " + stopWatch.toString());
    }
}
Also used : DataStorePluginOptions(org.locationtech.geowave.core.store.cli.store.DataStorePluginOptions) ResultSet(org.locationtech.geowave.core.store.query.gwql.ResultSet) ParameterException(com.beust.jcommander.ParameterException) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 4 with ResultSet

use of org.locationtech.geowave.core.store.query.gwql.ResultSet in project geowave by locationtech.

the class SelectStatement method execute.

@Override
public ResultSet execute(final String... authorizations) {
    final String typeName = adapter.getTypeName();
    if (isAggregation()) {
        final AggregationQueryBuilder<PersistableList, List<Object>, T, ?> bldr = AggregationQueryBuilder.newBuilder();
        bldr.setAuthorizations(authorizations);
        if (filter != null) {
            bldr.filter(filter);
        }
        if (limit != null) {
            bldr.limit(limit);
        }
        final CompositeAggregation<T> composite = new CompositeAggregation<>();
        final List<String> columnNames = Lists.newArrayListWithCapacity(selectors.size());
        final List<Class<?>> columnTypes = Lists.newArrayListWithCapacity(selectors.size());
        for (final Selector selector : selectors) {
            final AggregationSelector aggregation = (AggregationSelector) selector;
            final AggregationFunction<?> function = GWQLExtensionRegistry.instance().getAggregationFunction(aggregation.functionName());
            if (function == null) {
                throw new RuntimeException("No aggregation function called '" + aggregation.functionName() + "' was found.");
            }
            composite.add(function.getAggregation(adapter, aggregation.functionArgs()));
            columnNames.add(selector.name());
            columnTypes.add(function.getReturnType());
        }
        bldr.aggregate(typeName, composite);
        return new SingletonResultSet(columnNames, columnTypes, dataStore.aggregate(bldr.build()));
    } else {
        final QueryBuilder<T, ?> bldr = QueryBuilder.newBuilder(adapter.getDataClass()).addTypeName(typeName);
        bldr.setAuthorizations(authorizations);
        if (filter != null) {
            bldr.filter(filter);
        }
        if ((selectors != null) && !selectors.isEmpty()) {
            final Set<String> usedAttributes = Sets.newHashSet();
            selectors.forEach(s -> usedAttributes.add(((ColumnSelector) s).columnName()));
            if (filter != null) {
                filter.addReferencedFields(usedAttributes);
            }
            for (final String attribute : usedAttributes) {
                if (adapter.getFieldDescriptor(attribute) == null) {
                    throw new RuntimeException("No column named " + attribute + " was found in " + typeName);
                }
            }
            bldr.subsetFields(typeName, usedAttributes.toArray(new String[usedAttributes.size()]));
        } else {
            selectors = Lists.transform(Arrays.asList(adapter.getFieldDescriptors()), f -> new ColumnSelector(f.fieldName()));
        }
        if (limit != null) {
            bldr.limit(limit);
        }
        return new AdapterEntryResultSet<>(selectors, adapter, dataStore.query(bldr.build()));
    }
}
Also used : Arrays(java.util.Arrays) AggregationSelector(org.locationtech.geowave.core.store.query.gwql.AggregationSelector) ColumnSelector(org.locationtech.geowave.core.store.query.gwql.ColumnSelector) DataStore(org.locationtech.geowave.core.store.api.DataStore) AggregationQueryBuilder(org.locationtech.geowave.core.store.api.AggregationQueryBuilder) Set(java.util.Set) PersistableList(org.locationtech.geowave.core.index.persist.PersistableList) Sets(com.google.common.collect.Sets) AggregationFunction(org.locationtech.geowave.core.store.query.gwql.function.aggregation.AggregationFunction) List(java.util.List) ResultSet(org.locationtech.geowave.core.store.query.gwql.ResultSet) SingletonResultSet(org.locationtech.geowave.core.store.query.gwql.SingletonResultSet) Selector(org.locationtech.geowave.core.store.query.gwql.Selector) Lists(com.google.common.collect.Lists) SelectorType(org.locationtech.geowave.core.store.query.gwql.Selector.SelectorType) DataTypeAdapter(org.locationtech.geowave.core.store.api.DataTypeAdapter) Filter(org.locationtech.geowave.core.store.query.filter.expression.Filter) GWQLExtensionRegistry(org.locationtech.geowave.core.store.query.gwql.GWQLExtensionRegistry) QueryBuilder(org.locationtech.geowave.core.store.api.QueryBuilder) AdapterEntryResultSet(org.locationtech.geowave.core.store.query.gwql.AdapterEntryResultSet) CompositeAggregation(org.locationtech.geowave.core.store.query.aggregate.CompositeAggregation) Nullable(javax.annotation.Nullable) AggregationSelector(org.locationtech.geowave.core.store.query.gwql.AggregationSelector) CompositeAggregation(org.locationtech.geowave.core.store.query.aggregate.CompositeAggregation) AdapterEntryResultSet(org.locationtech.geowave.core.store.query.gwql.AdapterEntryResultSet) PersistableList(org.locationtech.geowave.core.index.persist.PersistableList) ColumnSelector(org.locationtech.geowave.core.store.query.gwql.ColumnSelector) PersistableList(org.locationtech.geowave.core.index.persist.PersistableList) List(java.util.List) SingletonResultSet(org.locationtech.geowave.core.store.query.gwql.SingletonResultSet) AggregationSelector(org.locationtech.geowave.core.store.query.gwql.AggregationSelector) ColumnSelector(org.locationtech.geowave.core.store.query.gwql.ColumnSelector) Selector(org.locationtech.geowave.core.store.query.gwql.Selector)

Example 5 with ResultSet

use of org.locationtech.geowave.core.store.query.gwql.ResultSet in project geowave by locationtech.

the class GeoWaveQueryLanguageIT method testSpatialExpressionQueries.

@Test
public void testSpatialExpressionQueries() {
    final DataStore ds = dataStore.createDataStore();
    final DataTypeAdapter<SimpleFeature> adapter = createDataAdapter();
    final Index spatialIndex = SpatialDimensionalityTypeProvider.createIndexFromOptions(new SpatialOptions());
    ds.addType(adapter, spatialIndex);
    final Index altIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, ALT));
    final Index polyIndex = AttributeDimensionalityTypeProvider.createIndexFromOptions(ds, new AttributeIndexOptions(TYPE_NAME, POLY));
    ds.addIndex(TYPE_NAME, altIndex, polyIndex);
    final String boxPoly = GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-20.5, -20.5), new Coordinate(-20.5, 20.5), new Coordinate(20.5, 20.5), new Coordinate(20.5, -20.5), new Coordinate(-20.5, -20.5) }).toText();
    final String boxPoly2 = GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { new Coordinate(-20, -20), new Coordinate(-20, 20), new Coordinate(20, 20), new Coordinate(20, -20), new Coordinate(-20, -20) }).toText();
    // Large diagonal line
    final String line = GeometryUtils.GEOMETRY_FACTORY.createLineString(new Coordinate[] { new Coordinate(-20.5, -20.5), new Coordinate(20.5, 20.5) }).toText();
    // Ingest data
    ingestData(ds);
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE BBOX(%s, 0.5, 0.5, 64.5, 64.5)", GEOM, POLY, ALT, TYPE_NAME, GEOM))) {
        assertEquals(3, results.columnCount());
        assertEquals(TOTAL_FEATURES / 2 - 1, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE BBOXLOOSE(%s, 0.5, 0.5, 64.5, 64.5)", GEOM, POLY, ALT, TYPE_NAME, GEOM))) {
        assertEquals(3, results.columnCount());
        assertEquals(TOTAL_FEATURES / 2 - 1, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE INTERSECTS(%s, '%s')", GEOM, POLY, ALT, TYPE_NAME, ALT, boxPoly))) {
        assertEquals(3, results.columnCount());
        assertEquals(20, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE INTERSECTSLOOSE(%s, '%s')", GEOM, POLY, ALT, TYPE_NAME, ALT, boxPoly))) {
        assertEquals(3, results.columnCount());
        assertEquals(20, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE DISJOINT(%s, '%s')", GEOM, POLY, ALT, TYPE_NAME, GEOM, boxPoly))) {
        assertEquals(3, results.columnCount());
        assertEquals(TOTAL_FEATURES - 41, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE DISJOINTLOOSE(%s, '%s')", GEOM, POLY, ALT, TYPE_NAME, GEOM, boxPoly))) {
        assertEquals(3, results.columnCount());
        assertEquals(TOTAL_FEATURES - 41, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE CROSSES(%s, '%s')", GEOM, POLY, ALT, TYPE_NAME, POLY, line))) {
        assertEquals(3, results.columnCount());
        assertEquals(43, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE OVERLAPS(%s, '%s')", GEOM, POLY, ALT, TYPE_NAME, POLY, boxPoly))) {
        assertEquals(3, results.columnCount());
        assertEquals(4, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE CONTAINS(%s, '%s')", GEOM, POLY, ALT, TYPE_NAME, GEOM, boxPoly))) {
        assertEquals(3, results.columnCount());
        assertFalse(results.hasNext());
    }
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE CONTAINS('%s', %s)", GEOM, POLY, ALT, TYPE_NAME, boxPoly, GEOM))) {
        assertEquals(3, results.columnCount());
        assertEquals(41, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE TOUCHES(%s, '%s')", GEOM, POLY, ALT, TYPE_NAME, POLY, boxPoly2))) {
        assertEquals(3, results.columnCount());
        assertEquals(2, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE WITHIN(%s, '%s')", GEOM, POLY, ALT, TYPE_NAME, GEOM, boxPoly))) {
        assertEquals(3, results.columnCount());
        assertEquals(41, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE %s = 'POINT(1 1)'", GEOM, POLY, ALT, TYPE_NAME, GEOM))) {
        assertEquals(3, results.columnCount());
        assertEquals(1, Iterators.size(results));
    }
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE 'POINT(1 1)'::geometry = %s", GEOM, POLY, ALT, TYPE_NAME, GEOM))) {
        assertEquals(3, results.columnCount());
        assertEquals(1, Iterators.size(results));
    }
    // ///////////////////////////////////////////////////
    try (final ResultSet results = ds.query(String.format("SELECT %s, %s, %s FROM %s WHERE %s <> 'POINT(1 1)'", GEOM, POLY, ALT, TYPE_NAME, GEOM))) {
        assertEquals(3, results.columnCount());
        assertEquals(TOTAL_FEATURES - 1, Iterators.size(results));
    }
}
Also used : AttributeIndexOptions(org.locationtech.geowave.core.store.index.AttributeIndexOptions) Coordinate(org.locationtech.jts.geom.Coordinate) DataStore(org.locationtech.geowave.core.store.api.DataStore) ResultSet(org.locationtech.geowave.core.store.query.gwql.ResultSet) Index(org.locationtech.geowave.core.store.api.Index) SpatialOptions(org.locationtech.geowave.core.geotime.index.SpatialOptions) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Aggregations

ResultSet (org.locationtech.geowave.core.store.query.gwql.ResultSet)8 DataStore (org.locationtech.geowave.core.store.api.DataStore)7 Test (org.junit.Test)6 SpatialOptions (org.locationtech.geowave.core.geotime.index.SpatialOptions)6 Index (org.locationtech.geowave.core.store.api.Index)6 SimpleFeature (org.opengis.feature.simple.SimpleFeature)6 AttributeIndexOptions (org.locationtech.geowave.core.store.index.AttributeIndexOptions)4 SpatialTemporalOptions (org.locationtech.geowave.core.geotime.index.SpatialTemporalOptions)2 Result (org.locationtech.geowave.core.store.query.gwql.Result)2 Point (org.locationtech.jts.geom.Point)2 ParameterException (com.beust.jcommander.ParameterException)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 BigDecimal (java.math.BigDecimal)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Arrays (java.util.Arrays)1 Date (java.util.Date)1 List (java.util.List)1 Set (java.util.Set)1 Nullable (javax.annotation.Nullable)1