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

The following examples show how to use org.opengis.filter.FilterFactory2#crosses() . 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 testGeoShapeAsWkt() throws Exception {
    if (client.getVersion() < 6.2) {
        // wkt unsupported prior to v6.2
        return;
    }
    init("not-active","geo6");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    GeometryFactory gf = new GeometryFactory();
    PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
    LineString ls = gf.createLineString(sf.create(new double[] { 0, 0, 2, 2 }, 2));
    Crosses f = ff.crosses(ff.property("geo3"), ff.literal(ls));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.12");

    sf = new PackedCoordinateSequenceFactory();
    ls = gf.createLineString(sf.create(new double[] { 0, 0, 1, 1 }, 2));
    f = ff.crosses(ff.property("geo5"), ff.literal(ls));
    features = featureSource.getFeatures(f);
    assertEquals(0, features.size());
}
 
Example 2
Source File: ElasticGeometryFilterIT.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testCrossesFilter() throws Exception {
    init("not-active","geo3");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    GeometryFactory gf = new GeometryFactory();
    PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
    LineString ls = gf.createLineString(sf.create(new double[] { 0, 0, 2, 2 }, 2));
    Crosses f = ff.crosses(ff.property("geo3"), ff.literal(ls));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.12");
}
 
Example 3
Source File: ElasticGeometryFilterIT.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testNotCrossesFilter() throws Exception {
    init("not-active","geo3");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    GeometryFactory gf = new GeometryFactory();
    PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
    LineString ls = gf.createLineString(sf.create(new double[] { 0, 0, 1, 1 }, 2));
    Crosses f = ff.crosses(ff.property("geo3"), ff.literal(ls));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(0, features.size());
}