Java Code Examples for org.opengis.filter.FilterFactory2#bbox()

The following examples show how to use org.opengis.filter.FilterFactory2#bbox() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElasticGeometryFilterIT.java    From elasticgeo with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testAlternateGeometry() throws Exception {
    init("active", "geo2");
    SimpleFeatureType schema = featureSource.getSchema();
    GeometryDescriptor gd = schema.getGeometryDescriptor();
    assertNotNull(gd);
    assertEquals("geo2", gd.getLocalName());

    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    BBOX bbox = ff.bbox("geo2", 6.5, 23.5, 7.5, 24.5, "EPSG:4326");
    SimpleFeatureCollection features = featureSource.getFeatures(bbox);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.09");
}
 
Example 2
Source File: ElasticGeometryFilterIT.java    From elasticgeo with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testOgrStyleGeoPoint() throws Exception {
    init("not-active","geo4.coordinates");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    BBOX bbox = ff.bbox("geo4.coordinates", 0, 0, 5, 5, "EPSG:4326");
    assertNotNull(featureSource.getSchema().getDescriptor("geo4.coordinates"));
    assertNull(featureSource.getSchema().getDescriptor("geo4.type"));

    SimpleFeatureCollection features = featureSource.getFeatures(bbox);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    SimpleFeature feature = fsi.next();
    assertEquals(feature.getID(), "active.13");
    assertNotNull(feature.getDefaultGeometry());
}
 
Example 3
Source File: GeometryUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static SpatialOperator geometryToSpatialOperator(
    final Geometry jtsGeom,
    final String geometryAttributeName) {
  final FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2();
  if (jtsGeom.equalsTopo(jtsGeom.getEnvelope())) {
    return factory.bbox(
        factory.property(geometryAttributeName),
        new ReferencedEnvelope(jtsGeom.getEnvelopeInternal(), GeometryUtils.getDefaultCRS()));
  }
  // there apparently is no way to associate a CRS with a poly
  // intersection operation so it will have to assume the same CRS as the
  // feature type
  return factory.intersects(factory.property(geometryAttributeName), factory.literal(jtsGeom));
}