org.opengis.filter.And Java Examples
The following examples show how to use
org.opengis.filter.And.
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: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 6 votes |
@Test public void testAndWithBbox() { And filter = ff.and(ff.id(ff.featureId("id1")), ff.bbox("geom", 0., 0., 1.1, 1.1, "EPSG:4326")); List<List<Double>> coords = new ArrayList<>(); coords.add(ImmutableList.of(0.,0.)); coords.add(ImmutableList.of(0.,1.1)); coords.add(ImmutableList.of(1.1,1.1)); coords.add(ImmutableList.of(1.1,0.)); coords.add(ImmutableList.of(0.,0.)); // vertices in reverse order List<List<Double>> reverseCoords = ImmutableList.of( coords.get(0), coords.get(3), coords.get(2), coords.get(1), coords.get(4) ); Map<String,Object> expected = ImmutableMap.of("bool", ImmutableMap.of("must", ImmutableList.of( ImmutableMap.of("ids", ImmutableMap.of("values", ImmutableList.of("id1"))), ImmutableMap.of("bool", ImmutableMap.of("must", MATCH_ALL, "filter", ImmutableMap.of("geo_shape", ImmutableMap.of("geom", ImmutableMap.of("shape", ImmutableMap.of("coordinates", ImmutableList.of(coords), "type", "Polygon"), "relation", "INTERSECTS"))) ))))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertThat(builder.getQueryBuilder().toString(), isOneOf(expected.toString(), expected.toString().replace(coords.toString(), reverseCoords.toString()))); }
Example #2
Source File: ElasticGeometryFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testBBOXAndEqualsFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo property = ff.equals(ff.property("standard_ss"), ff.literal("IEEE 802.11b")); BBOX bbox = ff.bbox("geo", -180, -180, 180, 180, "EPSG:" + SOURCE_SRID); And filter = ff.and(property, bbox); SimpleFeatureCollection features = featureSource.getFeatures(filter); assertEquals(7, features.size()); }
Example #3
Source File: ElasticFilterTest.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testAnd() { And filter = ff.and(ff.id(ff.featureId("id1")), ff.id(ff.featureId("id2"))); Map<String,Object> expected = ImmutableMap.of("bool", ImmutableMap.of("must", ImmutableList.of(ImmutableMap.of("ids", ImmutableMap.of("values", ImmutableList.of("id1"))), ImmutableMap.of("ids", ImmutableMap.of("values", ImmutableList.of("id2")))))); builder.visit(filter, null); assertTrue(builder.createCapabilities().fullySupports(filter)); assertEquals(expected, builder.getQueryBuilder()); }
Example #4
Source File: ElasticFeatureFilterIT.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
@Test public void testGetFeaturesWithAndLogicFilter() throws Exception { init(); FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo property = ff.equals(ff.property("standard_ss"), ff.literal("IEEE 802.11b")); BBOX bbox = ff.bbox("geo", -1, -1, 10, 10, "EPSG:" + SOURCE_SRID); And filter = ff.and(property, bbox); SimpleFeatureCollection features = featureSource.getFeatures(filter); assertEquals(3, features.size()); }
Example #5
Source File: ExtractGeometryFilterVisitor.java From geowave with Apache License 2.0 | 5 votes |
@Override public Object visit(final And filter, final Object data) { ExtractGeometryFilterVisitorResult finalResult = null; for (final Filter f : filter.getChildren()) { final Object obj = f.accept(this, data); if ((obj != null) && (obj instanceof ExtractGeometryFilterVisitorResult)) { final ExtractGeometryFilterVisitorResult currentResult = (ExtractGeometryFilterVisitorResult) obj; final Geometry currentGeom = currentResult.getGeometry(); final double currentArea = currentGeom.getArea(); if (finalResult == null) { finalResult = currentResult; } else if (!Double.isInfinite(currentArea) && !Double.isNaN(currentArea)) { // if predicates match then we can combine the geometry as // well as predicate if (currentResult.matchPredicate(finalResult)) { finalResult = new ExtractGeometryFilterVisitorResult( finalResult.getGeometry().intersection(currentGeom), currentResult.getCompareOp()); } else { // if predicate doesn't match then still combine // geometry but set predicate to null finalResult = new ExtractGeometryFilterVisitorResult( finalResult.getGeometry().intersection(currentGeom), null); } } else { finalResult = new ExtractGeometryFilterVisitorResult(finalResult.getGeometry(), null); } } } return finalResult; }
Example #6
Source File: DelaySecurityFilterPreStep.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
@Override public void execute(PipelineContext context, GetFeaturesContainer response) throws GeomajasException { Filter filter = context.getOptional(PipelineCode.FILTER_KEY, Filter.class); context.put(SAVED_FILTER_KEY, filter); if (filter instanceof And) { And and = (And) filter; if (and.getChildren().size() == 2) { recorder.record("layer", "removed security filter before layer"); context.put(PipelineCode.FILTER_KEY, and.getChildren().get(0)); context.put(SECURITY_FILTER_KEY, and.getChildren().get(1)); } } }
Example #7
Source File: ExtractTimeFilterVisitor.java From geowave with Apache License 2.0 | 4 votes |
@Override public Object visit(final And filter, final Object data) { final TemporalConstraintsSet constraints = new TemporalConstraintsSet(); for (final Filter f : filter.getChildren()) { final Object output = f.accept(this, data); if (output instanceof ParameterTimeConstraint) { final ParameterTimeConstraint ranges = (ParameterTimeConstraint) output; constraints.getConstraintsFor(ranges.getName()).replaceWithIntersections(ranges); } else if (output instanceof TemporalConstraintsSet) { final TemporalConstraintsSet rangeSet = (TemporalConstraintsSet) output; for (final Map.Entry<String, TemporalConstraints> entry : rangeSet.getSet()) { constraints.getConstraintsFor(entry.getKey()).replaceWithIntersections(entry.getValue()); } } } for (final String[] range : validParamRanges) { if (constraints.hasConstraintsFor(range[0]) && constraints.hasConstraintsFor(range[1])) { final TemporalConstraints start = constraints.getConstraintsFor(range[0]); final TemporalConstraints end = constraints.getConstraintsFor(range[1]); constraints.removeConstraints(range[0], range[1]); // TODO: make this logic more robust if (start.getEndRange().getEndTime().after(end.getStartRange().getStartTime())) { // does this really make sense? seems like start should always be the start time and end // should always be the end time, but perhaps with multiple and's and or's it probably // gets complicated such that this is the only working logic constraints.getConstraintsForRange(range[0], range[1]).add( new TemporalRange( end.getStartRange().getStartTime(), start.getEndRange().getEndTime())); } else { // if there are multiple non-instersecting ranges, this is // an approximation approximation |= (start.getRanges().size() > 1) || (end.getRanges().size() > 1); constraints.getConstraintsForRange(range[0], range[1]).add( new TemporalRange( start.getStartRange().getStartTime(), end.getEndRange().getEndTime())); } } } return constraints; }
Example #8
Source File: FilterToElastic.java From elasticgeo with GNU General Public License v3.0 | 2 votes |
/** * Write the FilterBuilder for an And filter * * @param filter the filter to visit * @param extraData extra data (unused by this method) * */ public Object visit(And filter, Object extraData) { return visit((BinaryLogicOperator)filter, "AND"); }