Refine search
@Override public List getProperties(Object object, XSDElementDeclaration element) throws Exception { BBOX box = (BBOX) object; List properties = new ArrayList(); Envelope env = null; try { String srs = box.getSRS(); if (srs != null) { CoordinateReferenceSystem crs = CRS.decode(srs); env = new ReferencedEnvelope( box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY(), crs); } } catch (Throwable t) { // never mind } if (env == null) { env = new Envelope(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY()); } properties.add(new Object[] {ENVELOPE_PARTICLE, env}); return properties; } }
/** Expands the BBOX in the Filter. */ @SuppressWarnings("deprecation") @Override public Object visit(BBOX filter, Object extraData) { // no need to change the property name Expression propertyName = filter.getExpression1(); /** Using the deprecated methods since they are too useful... */ 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 - expandMinX, miny - expandMaxX, maxx + expandMinY, maxy + expandMaxY, srs); } }
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; }
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()); }
@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); } },
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) { if (filter.getExpression2() instanceof Literal) { Literal bboxLiteral = (Literal) filter.getExpression2(); if (bboxLiteral.getValue() instanceof BoundingBox) { BoundingBox bounds = (BoundingBox) bboxLiteral.getValue(); return ff.bbox( filter.getExpression1(), new ReferencedEnvelope( bounds.getMinY(), if (geom.getUserData() instanceof CoordinateReferenceSystem) { crs = (CoordinateReferenceSystem) geom.getUserData(); } else if (filter.getSRS() != null) { try { crs = CRS.decode(filter.getSRS()); } catch (FactoryException e) { return ff.bbox( filter.getExpression1(), new ReferencedEnvelope( geomEnvelope.getMinY(),
@Test public void testPreserveOriginalSRS() throws NoSuchAuthorityCodeException, FactoryException { String srs = "AUTO:42004,9001,0,33"; CoordinateReferenceSystem crs = CRS.decode(srs); BBOX bbox = ff.bbox(ff.property(""), 0, 1000, 2000, 3000, srs); Geometry geom = bbox.getExpression2().evaluate(null, Geometry.class); assertEquals(crs, geom.getUserData()); assertEquals(srs, bbox.getSRS()); } }
@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); }
public void testPreservedNamespaceContext() { // set GEOT-3756 NamespaceSupport nsContext = new NamespaceSupport(); nsContext.declarePrefix("f", "http://feature.example.org"); Expression geometry = fac.property("f:name", nsContext); BBOX bbox = fac.bbox(geometry, 0, 0, 1, 1, "EPSG:4326"); DuplicatingFilterVisitor visitor = new DuplicatingFilterVisitor(fac); BBOX clone = (BBOX) bbox.accept(visitor, null); assertEquals(bbox, clone); assertNotSame(bbox, clone); assertSame(nsContext, ((PropertyName) clone.getExpression1()).getNamespaceContext()); }
@Test public void force3DCRS3DEnvelope() throws Exception { CoordinateReferenceSystem crs = CRS.decode("EPSG:4939", true); CoordinateReferenceSystem hcrs = CRS.getHorizontalCRS(crs); BBOX bbox = ff.bbox( ff.property("the_geom"), new ReferencedEnvelope3D(-180, 180, -90, 90, 0, 100, null)); DefaultCRSFilterVisitor visitor = new DefaultCRSFilterVisitor(ff, crs); BBOX filtered = (BBOX) bbox.accept(visitor, null); Literal box = (Literal) filtered.getExpression2(); Geometry g = (Geometry) box.evaluate(null); assertEquals(crs, g.getUserData()); } }
@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); }
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(final BBOX filter, Object data) { data = filter.getExpression1().accept(this, data); data = filter.getExpression2().accept(this, data); return data; }
public Object visit(BBOX filter, Object extraData) { if (filter.getExpression2() instanceof Literal) { Literal bboxLiteral = (Literal) filter.getExpression2(); if (bboxLiteral.getValue() instanceof BoundingBox) { BoundingBox bounds = (BoundingBox) bboxLiteral.getValue(); return ff.bbox(filter.getExpression1(), new ReferencedEnvelope( bounds.getMinY(), bounds.getMaxY(), bounds.getMinX(), bounds.getMaxX(), bounds.getCoordinateReferenceSystem())); } else if (bboxLiteral.getValue() instanceof Geometry) { Geometry geom = (Geometry) bboxLiteral.getValue(); Envelope geomEnvelope = geom.getEnvelopeInternal(); return ff.bbox(filter.getExpression1(), new ReferencedEnvelope( geomEnvelope.getMinY(), geomEnvelope.getMaxY(), geomEnvelope.getMinX(), geomEnvelope.getMaxX(), null)); } } return filter; }
@Test public void force3DCRS2DEnvelope() throws Exception { CoordinateReferenceSystem crs = CRS.decode("EPSG:4939", true); CoordinateReferenceSystem hcrs = CRS.getHorizontalCRS(crs); BBOX bbox = ff.bbox("the_geom", -180, -90, 180, 90, null); DefaultCRSFilterVisitor visitor = new DefaultCRSFilterVisitor(ff, crs); BBOX filtered = (BBOX) bbox.accept(visitor, null); Literal box = (Literal) filtered.getExpression2(); Geometry g = (Geometry) box.evaluate(null); assertEquals(hcrs, g.getUserData()); }
@Override public Object visit(final BBOX filter, final Object data) { if (attributeOfInterest.equals(filter.getExpression1().toString())) { final Geometry bbox = bbox(data); final BoundingBox referencedBBox = filter.getBounds(); Geometry bounds = new GeometryFactory().toGeometry(
public String getPropertyName() { return filter.getPropertyName(); }
@Override public Object getProperty(Object object, QName name) throws Exception { BBOX box = (BBOX) object; if (FES.ValueReference.equals(name)) { return box.getExpression1(); } return null; }