org.opengis.filter.spatial.Disjoint Java Examples

The following examples show how to use org.opengis.filter.spatial.Disjoint. 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: FilterToElasticHelper.java    From elasticgeo with GNU General Public License v3.0 6 votes vote down vote up
private void visitComparisonSpatialOperator(BinarySpatialOperator filter, PropertyName property, Literal geometry,
                                            boolean swapped, Object extraData) {

    // if geography case, sanitize geometry first
    Literal geometry1 = clipToWorld(geometry);

    //noinspection RedundantCast
    visitBinarySpatialOperator(filter, (Expression)property, (Expression) geometry1, swapped, extraData);

    // if geography case, sanitize geometry first
    if(isWorld(geometry1)) {
        // nothing to filter in this case
        delegate.queryBuilder = MATCH_ALL;
        return;
    } else if(isEmpty(geometry1)) {
        if(!(filter instanceof Disjoint)) {
            delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must_not", MATCH_ALL));
        } else {
            delegate.queryBuilder = MATCH_ALL;
        }
        return;
    }

    //noinspection RedundantCast
    visitBinarySpatialOperator(filter, (Expression)property, (Expression) geometry1, swapped, extraData);
}
 
Example #2
Source File: ElasticGeometryFilterIT.java    From elasticgeo with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testDisjointFilter() throws Exception {
    init("not-active","geo3");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    GeometryFactory gf = new GeometryFactory();
    PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
    Point ls = gf.createPoint(sf.create(new double[] { 0, 0 }, 2));
    Disjoint f = ff.disjoint(ff.property("geo3"), ff.literal(ls));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(2, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.12");
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.13");
}
 
Example #3
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 #4
Source File: ElasticCapabilities.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
public ElasticCapabilities() {
    super(new ElasticFilterCapabilities());

    addAll(LOGICAL_OPENGIS);
    addAll(SIMPLE_COMPARISONS_OPENGIS);
    addType(PropertyIsNull.class);
    addType(PropertyIsBetween.class);
    addType(Id.class);
    addType(IncludeFilter.class);
    addType(ExcludeFilter.class);
    addType(PropertyIsLike.class);

    // spatial filters
    addType(BBOX.class);
    addType(Contains.class);
    //addType(Crosses.class);
    addType(Disjoint.class);
    //addType(Equals.class);
    addType(Intersects.class);
    //addType(Overlaps.class);
    //addType(Touches.class);
    addType(Within.class);
    addType(DWithin.class);
    addType(Beyond.class);

    //temporal filters
    addType(After.class);
    addType(Before.class);
    addType(Begins.class);
    addType(BegunBy.class);
    addType(During.class);
    addType(Ends.class);
    addType(EndedBy.class);
    addType(TContains.class);
    addType(TEquals.class);
}
 
Example #5
Source File: FilterToElasticHelper.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
private void visitGeoShapeBinarySpatialOperator(BinarySpatialOperator filter, Expression e1, Expression e2,
                                                boolean swapped, Object extraData) {

    SpatialRelation shapeRelation;
    if (filter instanceof Disjoint) {
        shapeRelation = SpatialRelation.DISJOINT;
    } else if ((!swapped && filter instanceof Within) || (swapped && filter instanceof Contains)) {
        shapeRelation = SpatialRelation.WITHIN;
    } else if (filter instanceof Intersects || filter instanceof BBOX) {
        shapeRelation = SpatialRelation.INTERSECTS;
    } else {
        FilterToElastic.LOGGER.fine(filter.getClass().getSimpleName() 
                + " is unsupported for geo_shape types");
        shapeRelation = null;
        delegate.fullySupported = false;
    }

    if (shapeRelation != null) {
        e1.accept(delegate, extraData);
        key = (String) delegate.field;
        e2.accept(delegate, extraData);
        shapeBuilder = delegate.currentShapeBuilder;
    }

    if (shapeRelation != null && shapeBuilder != null) {
        delegate.queryBuilder = ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter",
                ImmutableMap.of("geo_shape", ImmutableMap.of(key,
                        ImmutableMap.of("shape", shapeBuilder, "relation", shapeRelation)))));
    } else {
        delegate.queryBuilder = MATCH_ALL;
    }
}
 
Example #6
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testEmptyDisjointGeoShape() {
    LineString ls = gf.createLineString(new Coordinate[0]);
    Disjoint filter = ff.disjoint(ff.property("geom"), ff.literal(ls));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(MATCH_ALL, builder.getQueryBuilder());
}
 
Example #7
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final Disjoint filter, final Object extraData) {
  if (!usesProperty(filter)) {
    return Filter.INCLUDE;
  }
  return super.visit(filter, extraData);
}
 
Example #8
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final Disjoint filter, final Object extraData) {
  if (!usesProperty(filter)) {
    return Filter.INCLUDE;
  }
  return super.visit(filter, extraData);
}
 
Example #9
Source File: FilterToElastic.java    From elasticgeo with GNU General Public License v3.0 4 votes vote down vote up
public Object visit(Disjoint filter, Object extraData) {
    return visitBinarySpatialOperator(filter, extraData);
}
 
Example #10
Source File: ExtractGeometryFilterVisitor.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public Object visit(final Disjoint filter, final Object data) {
  // disjoint does not define a rectangle, but a hole in the
  // Cartesian plane, no way to limit it
  return new ExtractGeometryFilterVisitorResult(infinity(), null);
}
 
Example #11
Source File: ExtractTimeFilterVisitor.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public Object visit(final Disjoint filter, final Object data) {
  return new TemporalConstraints();
}
 
Example #12
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(Disjoint filter, Object userData) {
	throw new UnsupportedOperationException("visit(Disjoint filter, Object userData)");
}