org.opengis.filter.spatial.Crosses Java Examples

The following examples show how to use org.opengis.filter.spatial.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: StyleConverterServiceTest.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testFilters() throws LayerException {
	Style style = styleConverterService.convert(layerBeansMixedGeometryStyleInfoSld.getUserStyle());
	List<Rule> rules = style.featureTypeStyles().get(0).rules();
	assertThat(rules.get(0).getFilter()).isInstanceOf(BBOX.class);
	assertThat(rules.get(1).getFilter()).isInstanceOf(Contains.class);
	assertThat(rules.get(2).getFilter()).isInstanceOf(Crosses.class);
	assertThat(rules.get(3).getFilter()).isInstanceOf(Disjoint.class);
	assertThat(rules.get(4).getFilter()).isInstanceOf(Equals.class);
	assertThat(rules.get(5).getFilter()).isInstanceOf(Intersects.class);
	assertThat(rules.get(6).getFilter()).isInstanceOf(Overlaps.class);
	assertThat(rules.get(7).getFilter()).isInstanceOf(Touches.class);
	assertThat(rules.get(8).getFilter()).isInstanceOf(Within.class);
	NamedStyleInfo namedStyleInfo = styleConverterService.convert(
			layerBeansMixedGeometryStyleInfoSld.getUserStyle(), featureInfo);
	Assert.assertEquals(9, namedStyleInfo.getFeatureStyles().size());
}
 
Example #3
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 #4
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());
}
 
Example #5
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final Crosses filter, final Object extraData) {
  if (!usesProperty(filter)) {
    return Filter.INCLUDE;
  }
  return super.visit(filter, extraData);
}
 
Example #6
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final Crosses filter, final Object extraData) {
  if (!usesProperty(filter)) {
    return Filter.INCLUDE;
  }
  return super.visit(filter, extraData);
}
 
Example #7
Source File: ExtractGeometryFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final Crosses filter, Object data) {
  if (!attributeOfInterest.equals(filter.getExpression1().toString())) {
    return new ExtractGeometryFilterVisitorResult(infinity(), null);
  }
  data = filter.getExpression2().accept(this, data);
  return new ExtractGeometryFilterVisitorResult((Geometry) data, CompareOperation.CROSSES);
}
 
Example #8
Source File: FilterToElastic.java    From elasticgeo with GNU General Public License v3.0 4 votes vote down vote up
public Object visit(Crosses filter, Object extraData) {
    return visitBinarySpatialOperator(filter, extraData);
}
 
Example #9
Source File: ExtractTimeFilterVisitor.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public Object visit(final Crosses filter, final Object data) {
  return new TemporalConstraints();
}
 
Example #10
Source File: CriteriaVisitor.java    From geomajas-project-server with GNU Affero General Public License v3.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public Object visit(Crosses filter, Object userData) {
	throw new UnsupportedOperationException("visit(Crosses filter, Object userData)");
}