Search in sources :

Example 1 with SpatialQuery

use of mil.nga.giat.geowave.core.geotime.store.query.SpatialQuery in project incubator-rya by apache.

the class GeoWaveGTQueryTest method executePolygonQueryTest.

@Test
public void executePolygonQueryTest() throws IOException {
    System.out.println("Constructing polygon for the area contained by [Baltimore, MD; Richmond, VA; Harrisonburg, VA].");
    final Polygon polygon = GeometryUtils.GEOMETRY_FACTORY.createPolygon(new Coordinate[] { BALTIMORE, RICHMOND, HARRISONBURG, BALTIMORE });
    System.out.println("Executing query, expecting to match ALL points...");
    final QueryOptions queryOptions = new QueryOptions(ADAPTER, INDEX);
    final SpatialQuery spatialQuery = new SpatialQuery(polygon);
    /*
         * NOTICE: In this query, the adapter is added to the query options. If
         * an index has data from more than one adapter, the data associated
         * with a specific adapter can be selected.
         */
    try (final CloseableIterator<SimpleFeature> closableIterator = dataStore.query(queryOptions, spatialQuery)) {
        int count = 0;
        while (closableIterator.hasNext()) {
            System.out.println("Query match: " + closableIterator.next().getID());
            count++;
        }
        System.out.println("executePolygonQueryTest count: " + count);
        // Should match "FedEx Field", "Washington Monument", and "White House"
        assertEquals(3, count);
    }
}
Also used : SpatialQuery(mil.nga.giat.geowave.core.geotime.store.query.SpatialQuery) Polygon(com.vividsolutions.jts.geom.Polygon) QueryOptions(mil.nga.giat.geowave.core.store.query.QueryOptions) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Example 2 with SpatialQuery

use of mil.nga.giat.geowave.core.geotime.store.query.SpatialQuery in project incubator-rya by apache.

the class GeoWaveGTQueryTest method executeBoundingBoxQueryTest.

@Test
public void executeBoundingBoxQueryTest() throws IOException {
    System.out.println("Constructing bounding box for the area contained by [Baltimore, MD and Richmond, VA.");
    final Geometry boundingBox = GeometryUtils.GEOMETRY_FACTORY.toGeometry(new Envelope(BALTIMORE, RICHMOND));
    System.out.println("Executing query, expecting to match ALL points...");
    final QueryOptions queryOptions = new QueryOptions(ADAPTER, INDEX);
    final SpatialQuery spatialQuery = new SpatialQuery(boundingBox);
    try (final CloseableIterator<SimpleFeature> iterator = dataStore.query(queryOptions, spatialQuery)) {
        int count = 0;
        while (iterator.hasNext()) {
            System.out.println("Query match: " + iterator.next().getID());
            count++;
        }
        System.out.println("executeBoundingBoxQueryTest count: " + count);
        // Should match "FedEx Field", "Washington Monument", and "White House"
        assertEquals(3, count);
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) SpatialQuery(mil.nga.giat.geowave.core.geotime.store.query.SpatialQuery) Envelope(com.vividsolutions.jts.geom.Envelope) QueryOptions(mil.nga.giat.geowave.core.store.query.QueryOptions) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Aggregations

SpatialQuery (mil.nga.giat.geowave.core.geotime.store.query.SpatialQuery)2 QueryOptions (mil.nga.giat.geowave.core.store.query.QueryOptions)2 Test (org.junit.Test)2 SimpleFeature (org.opengis.feature.simple.SimpleFeature)2 Envelope (com.vividsolutions.jts.geom.Envelope)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 Polygon (com.vividsolutions.jts.geom.Polygon)1