@Test public void testBBOX() { ff.bbox("geom", 0, 0, 10, 10, "EPSG:4326").accept(visitor, null); assertTrue(visitor.hasSpatialFilter); }
public void testResolveEmptyName() { // We use a geometry filter here to test that expression1 does not get filled with the // default geometry BBOX f = factory.bbox("", 0.0, 0.0, 1.0, 1.0, DefaultGeographicCRS.WGS84.toString()); assertEquals("", f.getExpression1().toString()); f = (BBOX) f.accept(new PropertyNameResolvingVisitor(featureType), null); assertEquals("", f.getExpression1().toString()); } }
public void testBboxReprojectUnreferencedProperty() { // see if coordinates gets flipped, urn forces lat/lon interpretation BBOX bbox = ff.bbox(ff.property("line"), 10, 15, 20, 25, "urn:x-ogc:def:crs:EPSG:6.11.2:4326"); Filter clone = (Filter) bbox.accept(reprojector, null); assertNotSame(bbox, clone); assertEquals(bbox, clone); }
public void testBboxReprojectUnreferencedBBox() { // see if coordinates gets flipped, urn forces lat/lon interpretation BBOX bbox = ff.bbox(ff.property("geom"), 10, 15, 20, 25, null); Filter clone = (Filter) bbox.accept(reprojector, null); assertNotSame(bbox, clone); assertEquals(bbox, clone); }
@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()); }
@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()); } }
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()); }
/** 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)); }
@Test public void testBBox3D() throws Exception { BBOX bbox = ff.bbox("location", new ReferencedEnvelope3D(0, 10, 20, 50, 60, 70, null)); assertTrue(bbox instanceof BBOX3DImpl); BBOX3DImpl bbox3d = (BBOX3DImpl) bbox; Filter unrolled = (Filter) bbox.accept(visitor, null); assertTrue(unrolled instanceof BBOX3DImpl); BBOX3DImpl unrolled3d = (BBOX3DImpl) unrolled; assertEquals(bbox3d.getMinX(), unrolled3d.getMinX(), 0.0); assertEquals(bbox3d.getMaxX(), unrolled3d.getMaxX(), 0.0); assertEquals(bbox3d.getMinY(), unrolled3d.getMinY(), 0.0); assertEquals(bbox3d.getMaxY(), unrolled3d.getMaxY(), 0.0); assertEquals(bbox3d.getMinZ(), unrolled3d.getMinZ(), 0.0); assertEquals(bbox3d.getMaxZ(), unrolled3d.getMaxZ(), 0.0); } }