public Object visit(BBOX filter, Object arg1) { String propertyName = filter.getPropertyName(); if (propertyName.length() < 1) { // see GetFeatureKvpRequestReader bboxFilter() // propertyName is meant to be empty, and it will get it from the feature // later (if not available, it will use feature's default geometry) // instead of always use the default geometry from the feature type return filter; } Expression name = ff.property(propertyName); final List sourceNames = (List) name.accept(this, null); final List combined = new ArrayList(sourceNames.size()); for (Iterator it = sourceNames.iterator(); it.hasNext(); ) { Expression sourceName = (Expression) it.next(); Filter unrolled; unrolled = ff.bbox(sourceName, filter.getBounds(), filter.getMatchAction()); combined.add(unrolled); } Filter unrolled = combineOred(combined); return unrolled; }
@Override public Object visit(BBOX filter, Object data) { final ReferencedEnvelope bbox = ReferencedEnvelope.reference(filter.getBounds()); if (this.bbox != null) { this.bbox = (ReferencedEnvelope) this.bbox.intersection(bbox); } else { this.bbox = bbox; } return super.visit(filter, data); } }
public Object visit(BBOX filter, Object extraData) { // if no srs is specified we can't transform anyways String srs = filter.getSRS(); if (srs != null && !"".equals(srs.trim())) return super.visit(filter, extraData); if (defaultCrs == null || filter.getBounds() == null || defaultCrs.getCoordinateSystem().getDimension() == filter.getBounds().getDimension()) { return getFactory(extraData) .bbox( filter.getExpression1(), ReferencedEnvelope.create(filter.getBounds(), defaultCrs)); } else { try { SingleCRS horizontalCRS = CRS.getHorizontalCRS(defaultCrs); ReferencedEnvelope bounds = ReferencedEnvelope.create(filter.getBounds(), horizontalCRS); return getFactory(extraData).bbox(filter.getExpression1(), bounds); } catch (Exception e) { throw new RuntimeException("Could not decode srs '" + srs + "'", e); } } }
public Object visit(BBOX filter, Object extraData) { // grab the original envelope data BoundingBox boundaries = filter.getBounds(); // parse the srs, it might be a code or a WKT definition CoordinateReferenceSystem crs = boundaries.getCoordinateReferenceSystem(); // if no srs is specified we can't transform anyways if (crs == null) return super.visit(filter, extraData); // grab the property data PropertyName propertyName = null; // get the expression as is to preserve namespace context if (filter.getExpression1() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression1(); } else if (filter.getExpression2() instanceof PropertyName) { propertyName = (PropertyName) filter.getExpression2(); } CoordinateReferenceSystem targetCrs = findPropertyCRS(propertyName); // if there is a mismatch, reproject and replace if (crs != null && targetCrs != null && !CRS.equalsIgnoreMetadata(crs, targetCrs)) { ReferencedEnvelope envelope = ReferencedEnvelope.reference(boundaries); try { envelope = envelope.transform(targetCrs, true); } catch (TransformException e) { throw new RuntimeException(e); } catch (FactoryException e) { throw new RuntimeException(e); } boundaries = envelope; } return getFactory(extraData).bbox(propertyName, boundaries); }
public Object visit(BBOX filter, Object extraData) { Expression propertyName = visit(filter.getExpression1(), extraData); if (!(filter instanceof BBOX3D)) { double minx = filter.getMinX(); double miny = filter.getMinY(); double maxx = filter.getMaxX(); double maxy = filter.getMaxY(); String srs = filter.getSRS(); return getFactory(extraData) .bbox(propertyName, minx, miny, maxx, maxy, srs, filter.getMatchAction()); } return getFactory(extraData).bbox(propertyName, filter.getBounds()); }
Filter f1 = filters.get(0); assertTrue(f1 instanceof BBOX); BoundingBox bbox1 = ((BBOX) f1).getBounds(); ReferencedEnvelope expected = new ReferencedEnvelope(-11, 111, -11, 111, DefaultGeographicCRS.WGS84); Filter f2 = filters.get(1); assertTrue(f2 instanceof BBOX); BoundingBox bbox2 = ((BBOX) f2).getBounds(); assertEquals(new ReferencedEnvelope(-6, 106, -6, 106, DefaultGeographicCRS.WGS84), bbox2);
@Override public Filter[] visit(BBOX filter, Object extraData) { Expression metaProperty = toBoundsExpression(filter.getExpression1(), false); BBOX bbox = ff.bbox(metaProperty, filter.getBounds()); return tuple(bbox, INCLUDE); }
@Override public Object visit(BBOX filter, Object extraData) { if (filter.getExpression1() instanceof PropertyName) { PropertyName pname = (PropertyName) filter.getExpression1(); PropertyName qualified = (PropertyName) pname.accept(this, extraData); return getFactory(extraData).bbox(qualified, filter.getBounds()); } else { return super.visit(filter, extraData); } } }
/** * Expands the BBOX in the Filter. * */ @Override public Object visit(BBOX filter, Object extraData) { // no need to change the property name Expression propertyName = filter.getExpression1(); BoundingBox boundingBox = filter.getBounds(); double minx = boundingBox.getMinX() - expandMinX; double miny = boundingBox.getMinY() - expandMinY; double maxx = boundingBox.getMaxX() + expandMaxX; double maxy = boundingBox.getMaxY() + expandMaxY; CoordinateReferenceSystem crs = boundingBox.getCoordinateReferenceSystem(); return getFactory(extraData).bbox(propertyName, new ReferencedEnvelope(minx, maxx, miny, maxy, crs)); }
@Override public Object visit(BBOX filter, Object extraData) { String propertyName = null; if (filter.getExpression1() instanceof PropertyName) { propertyName = ((PropertyName) filter.getExpression1()).getPropertyName(); } else if (filter.getExpression2() instanceof PropertyName) { propertyName = ((PropertyName) filter.getExpression2()).getPropertyName(); } if (propertyName != null) { PropertyName propertyAtt = ff.property(propertyName, nsContext); filter = ff.bbox(propertyAtt, filter.getBounds()); } return filter; } }
if (attributeOfInterest.equals(filter.getExpression1().toString())) { final Geometry bbox = bbox(data); final BoundingBox referencedBBox = filter.getBounds(); Geometry bounds = new GeometryFactory().toGeometry(
@Test public void bboxOredFilter() throws Exception { BBOX bbox1 = ff.bbox("nonmaterialized", 0, 0, 180, 90, "EPSG:4326"); BBOX bbox2 = ff.bbox("nonmaterialized", -180, -90, 0, 0, "EPSG:4326"); Filter filter = ff.or(bbox1, bbox2); Or expected = ff.or(// ff.bbox(ff.property("@bounds"), bbox1.getBounds()), // ff.bbox(ff.property("@bounds"), bbox2.getBounds())); assertFilter(filter, expected, INCLUDE); }
@Test public void bboxFilter() throws Exception { BBOX filter = ff.bbox("nontmaterialized", 0, 0, 180, 90, "EPSG:4326"); BBOX expected = ff.bbox(ff.property("@bounds"), filter.getBounds()); assertFilter(filter, expected, INCLUDE); }
@Override public Object visit(BBOX filter, Object extraData) { // BBOX must work against a propertyName, if boundedBy is // used we // need to switch to an intersects filter Expression expression1 = filter.getExpression1(); if (expression1 instanceof PropertyName && isGmlBoundedBy((PropertyName) expression1)) { ReferencedEnvelope bounds = ReferencedEnvelope.reference( filter.getBounds()); Polygon polygon = JTS.toGeometry(bounds); Function boundedBy = filterFactory.function( "boundedBy", filterFactory.property("")); return filterFactory.intersects( boundedBy, filterFactory.literal(polygon)); } return super.visit(filter, extraData); } },