public String getPropertyName() { return filter.getPropertyName(); }
public static Object buildBBOX(BBOX filter, Object extraData) { StringBuilder output = asStringBuilder(extraData); output.append("BBOX("); output.append(filter.getPropertyName()); output.append(", "); output.append(filter.getMinX()); output.append(","); output.append(filter.getMinY()); output.append(","); output.append(filter.getMaxX()); output.append(","); output.append(filter.getMaxY()); output.append(")"); return output; }
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 getProperty(Object object, QName name) throws Exception { BBOX box = (BBOX) object; // <xsd:element ref="ogc:PropertyName"/> if (OGC.PropertyName.equals(name)) { return factory.property(box.getPropertyName()); } // <xsd:element ref="gml:Box"/> if (GML.Box.equals(name) || org.geotools.gml3.GML.Envelope.equals(name)) { try { String srs = box.getSRS(); if (srs != null) { CoordinateReferenceSystem crs = CRS.decode(srs); return new ReferencedEnvelope( box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY(), crs); } } catch (Throwable t) { // never mind } return new Envelope(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY()); } return null; } }
public String getPropertyName() { return filter.getPropertyName(); } public Object accept( ExpressionVisitor visitor, Object data ) {
public String getPropertyName() { return filter.getPropertyName(); } public Object accept( ExpressionVisitor visitor, Object data ) {
@Override public Object visit(BBOX filter, Object extraData) { geometryPropertyName = filter.getPropertyName(); return Filter.INCLUDE; }
/** The provided target CRS (3857) should override the native one (4326). */ public void testBboxReprojectWithTargetCrsProvided() throws FactoryException { ReprojectingFilterVisitor reprojector = new ReprojectingFilterVisitor(ff, ft, CRS.decode("EPSG:3857")); BBOX bbox = ff.bbox(ff.property("geom"), 10, 15, 20, 25, "EPSG:4326"); Filter clone = (Filter) bbox.accept(reprojector, null); assertNotSame(bbox, clone); BBOX clonedBbox = (BBOX) clone; assertEquals(bbox.getPropertyName(), clonedBbox.getPropertyName()); assertEquals(1113194.9079327357, clonedBbox.getMinX(), 0.1); assertEquals(1689200.1396078924, clonedBbox.getMinY(), 0.1); assertEquals(2226389.8158654715, clonedBbox.getMaxX(), 0.1); assertEquals(2875744.6243522423, clonedBbox.getMaxY(), 0.1); assertEquals("EPSG:3857", clonedBbox.getSRS()); }
/** * The provided target CRS (3857) should not override the native one (4326) since the use * property is not a geometry. */ public void testTargetCrsProvidedButNoGeometryProperty() throws FactoryException { ReprojectingFilterVisitor reprojector = new ReprojectingFilterVisitor(ff, ft, CRS.decode("EPSG:3857")); BBOX bbox = ff.bbox(ff.property("name"), 10, 15, 20, 25, "EPSG:4326"); BBOX clone = (BBOX) bbox.accept(reprojector, null); assertNotSame(bbox, clone); // check that no reprojection was applied assertEquals(bbox.getPropertyName(), clone.getPropertyName()); assertEquals(10.0, clone.getMinX(), 0.1); assertEquals(15.0, clone.getMinY(), 0.1); assertEquals(20.0, clone.getMaxX(), 0.1); assertEquals(25.0, clone.getMaxY(), 0.1); assertEquals("EPSG:4326", clone.getSRS()); }
public void testBboxReproject() { // see if coordinates gets flipped, urn forces lat/lon interpretation BBOX bbox = ff.bbox(ff.property("geom"), 10, 15, 20, 25, "urn:x-ogc:def:crs:EPSG:6.11.2:4326"); Filter clone = (Filter) bbox.accept(reprojector, null); assertNotSame(bbox, clone); BBOX clonedBbox = (BBOX) clone; assertEquals(bbox.getPropertyName(), clonedBbox.getPropertyName()); assertEquals(15, clonedBbox.getMinX(), 1e-6); assertEquals(10, clonedBbox.getMinY(), 1e-6); assertEquals(25, clonedBbox.getMaxX(), 1e-6); assertEquals(20, clonedBbox.getMaxY(), 1e-6); assertEquals("EPSG:4326", clonedBbox.getSRS()); }
public void testBboxReprojectNoNativeAuthority() throws Exception { // like WGS84, but no authority String wkt = "GEOGCS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", SPHEROID[\"WGS 84\", 6378137.0, 298.257223563]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"degree\", 0.017453292519943295], AXIS[\"Geodetic longitude\", EAST], AXIS[\"Geodetic latitude\", NORTH]]"; CoordinateReferenceSystem crs = CRS.parseWKT(wkt); SimpleFeatureType newFt = FeatureTypes.transform(ft, crs); reprojector = new ReprojectingFilterVisitor(ff, newFt); BBOX bbox = ff.bbox(ff.property("geom"), 10, 15, 20, 25, "urn:x-ogc:def:crs:EPSG:6.11.2:4326"); Filter clone = (Filter) bbox.accept(reprojector, null); assertNotSame(bbox, clone); BBOX clonedBbox = (BBOX) clone; assertEquals(bbox.getPropertyName(), clonedBbox.getPropertyName()); assertTrue(15 == clonedBbox.getMinX()); assertTrue(10 == clonedBbox.getMinY()); assertTrue(25 == clonedBbox.getMaxX()); assertTrue(20 == clonedBbox.getMaxY()); // the srs code cannot be found, but it's legal to use a WKT description instead // CoordinateReferenceSystem reprojected = CRS.parseWKT(clonedBbox.getSRS()); // assertTrue(CRS.equalsIgnoreMetadata(crs, reprojected)); }
public void testParse() throws Exception { FilterMockData.bbox(document, document); BBOX box = (BBOX) parse(); assertEquals("foo", box.getPropertyName()); assertEquals(0, box.getMinX(), 0.0); assertEquals(0, box.getMinY(), 0.0); assertEquals(1, box.getMaxX(), 0.0); assertEquals(1, box.getMaxY(), 0.0); assertEquals("EPSG:4326", box.getSRS()); }
public static Object buildBBOX(BBOX filter, Object extraData) { StringBuilder output = asStringBuilder(extraData); output.append( "BBOX("); output.append( filter.getPropertyName() ); output.append( ", "); output.append( filter.getMinX() ); output.append( ","); output.append( filter.getMinY() ); output.append( ","); output.append( filter.getMaxX() ); output.append( ","); output.append( filter.getMaxY() ); output.append( ")"); return output; }
String propertyName = filter.getPropertyName(); String srs = filter.getSRS(); return getFactory(extraData).bbox(propertyName, minx, miny, maxx, maxy, srs);
public Object getProperty(Object object, QName name) throws Exception { BBOX box = (BBOX) object; //<xsd:element ref="ogc:PropertyName"/> if (OGC.PropertyName.equals(name)) { return factory.property(box.getPropertyName()); } //<xsd:element ref="gml:Box"/> if (GML.Box.equals(name)) { return new Envelope(box.getMinX(), box.getMaxX(), box.getMinY(), box.getMaxY()); } return null; } }
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); try { // grab the original envelope data double minx = filter.getMinX(); double miny = filter.getMinY(); double maxx = filter.getMaxX(); double maxy = filter.getMaxY(); String propertyName = filter.getPropertyName(); String defaultSrs = CRS.toSRS(defaultCrs); return getFactory(extraData).bbox(propertyName, minx, miny, maxx, maxy, defaultSrs); } catch (Exception e) { throw new RuntimeException("Could not decode srs '" + srs + "'", e); } }
public Object visit(BBOX filter, Object extraData) { String propertyName=filter.getPropertyName(); 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); }
public Object visit(BBOX filter, Object extraData) { String propertyName=filter.getPropertyName(); double [] coords= new double[4]; coords[0]=filter.getMinX(); coords[1]=filter.getMinY(); coords[2]=filter.getMaxX(); coords[3]=filter.getMaxY(); String srs=filter.getSRS(); double[] dest=new double[4]; try { mt.transform(coords, 0, dest, 0, 2); } catch (TransformException e) { throw new RuntimeException(e); } return getFactory(extraData).bbox(propertyName, dest[0], dest[1], dest[2], dest[3], srs); }
public Object visit(BBOX filter, Object extraData) { String propertyName=filter.getPropertyName(); double [] coords= new double[4]; coords[0]=filter.getMinX(); coords[1]=filter.getMinY(); coords[2]=filter.getMaxX(); coords[3]=filter.getMaxY(); String srs=filter.getSRS(); double[] dest=new double[4]; try { mt.transform(coords, 0, dest, 0, 2); } catch (TransformException e) { throw new RuntimeException(e); } return getFactory(extraData).bbox(propertyName, dest[0], dest[1], dest[2], dest[3], srs); }
@Test public void testReprojectFilterWithTargetCrs() throws FactoryException { BBOX bbox = filterFactory.bbox(filterFactory.property("geom"), 10, 15, 20, 25, "EPSG:4326"); Filter clone = WFSReprojectionUtil.reprojectFilter(bbox, featureType, CRS.decode("EPSG:3857")); assertNotSame(bbox, clone); BBOX clonedBbox = (BBOX) clone; assertEquals(bbox.getPropertyName(), clonedBbox.getPropertyName()); assertEquals(1669792.3618991035, clonedBbox.getMinX(), 0.1); assertEquals(1118889.9748579597, clonedBbox.getMinY(), 0.1); assertEquals(2782987.269831839, clonedBbox.getMaxX(), 0.1); assertEquals(2273030.926987689, clonedBbox.getMaxY(), 0.1); assertEquals("EPSG:3857", clonedBbox.getSRS()); } }