@Test public void testIntersects() { ff.intersects(ff.property("geom"), ff.literal(null)).accept(visitor, null); assertTrue(visitor.hasSpatialFilter); }
public void testIntersectsUnreferencedGeometry() throws Exception { GeometryFactory gf = new GeometryFactory(); LineString ls = gf.createLineString( new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)}); // see if coordinates gets flipped, urn forces lat/lon interpretation Intersects original = ff.intersects(ff.property("geom"), ff.literal(ls)); Filter clone = (Filter) original.accept(reprojector, null); assertNotSame(original, clone); assertEquals(original, clone); }
public void testIntersectsWithFunction() throws Exception { Function function = new GeometryFunction(); // see if coordinates gets flipped, urn forces lat/lon interpretation Intersects original = ff.intersects(ff.property("geom"), function); Filter clone = (Filter) original.accept(reprojector, null); assertNotSame(original, clone); Intersects isClone = (Intersects) clone; assertEquals(isClone.getExpression1(), original.getExpression1()); LineString clonedLs = (LineString) isClone.getExpression2().evaluate(null); assertTrue(15 == clonedLs.getCoordinateN(0).x); assertTrue(10 == clonedLs.getCoordinateN(0).y); assertTrue(25 == clonedLs.getCoordinateN(1).x); assertTrue(20 == clonedLs.getCoordinateN(1).y); assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData()); }
public void testIntersectsReproject(Expression geom) throws FactoryException { GeometryFactory gf = new GeometryFactory(); LineString ls = gf.createLineString( new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)}); ls.setUserData(CRS.decode("urn:x-ogc:def:crs:EPSG:6.11.2:4326")); // see if coordinates gets flipped, urn forces lat/lon interpretation Intersects original = ff.intersects(geom, ff.literal(ls)); Filter clone = (Filter) original.accept(reprojector, null); assertNotSame(original, clone); Intersects isClone = (Intersects) clone; assertEquals(isClone.getExpression1(), original.getExpression1()); LineString clonedLs = (LineString) ((Literal) isClone.getExpression2()).getValue(); assertTrue(15 == clonedLs.getCoordinateN(0).x); assertTrue(10 == clonedLs.getCoordinateN(0).y); assertTrue(25 == clonedLs.getCoordinateN(1).x); assertTrue(20 == clonedLs.getCoordinateN(1).y); assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData()); }
public void testIntersectsReferencedGeometry() throws Exception { GeometryFactory gf = new GeometryFactory(); LineString ls = gf.createLineString( new Coordinate[] {new Coordinate(10, 15), new Coordinate(20, 25)}); ls.setUserData(CRS.decode("urn:x-ogc:def:crs:EPSG:6.11.2:4326")); // see if coordinates gets flipped, urn forces lat/lon interpretation Intersects original = ff.intersects(ff.property("line"), ff.literal(ls)); Filter clone = (Filter) original.accept(reprojector, null); assertNotSame(original, clone); Intersects isClone = (Intersects) clone; assertEquals(isClone.getExpression1(), original.getExpression1()); LineString clonedLs = (LineString) isClone.getExpression2().evaluate(null); assertTrue(15 == clonedLs.getCoordinateN(0).x); assertTrue(10 == clonedLs.getCoordinateN(0).y); assertTrue(25 == clonedLs.getCoordinateN(1).x); assertTrue(20 == clonedLs.getCoordinateN(1).y); assertEquals(CRS.decode("EPSG:4326"), clonedLs.getUserData()); }
@Test public void testGeometryFilter() throws Exception { mapping = createSampleDerivedAttributeMappings(); visitor = new UnmappingFilterVisitor(mapping); targetDescriptor = mapping.getTargetFeature(); targetType = (FeatureType) targetDescriptor.getType(); Expression literalGeom = ff.literal(new GeometryFactory().createPoint(new Coordinate(1, 1))); Intersects gf = ff.intersects(ff.property("areaOfInfluence"), literalGeom, MatchAction.ALL); Filter unrolled = (Filter) gf.accept(visitor, null); assertTrue(unrolled instanceof Intersects); assertNotSame(gf, unrolled); assertEquals(MatchAction.ALL, ((Intersects) unrolled).getMatchAction()); Intersects newFilter = (Intersects) unrolled; Expression left = newFilter.getExpression1(); Expression right = newFilter.getExpression2(); assertSame(right, literalGeom); assertTrue(left instanceof Function); Function fe = (Function) left; assertEquals("buffer", fe.getName()); Expression arg0 = (Expression) fe.getParameters().get(0); assertTrue(arg0 instanceof PropertyName); assertEquals("location", ((PropertyName) arg0).getPropertyName()); }
@Test public void testGeometryFilter() throws Exception { mapping = createSampleDerivedAttributeMappings(); visitor = new UnmappingFilterVisitor(mapping); targetDescriptor = mapping.getTargetFeature(); targetType = (FeatureType) targetDescriptor.getType(); Expression literalGeom = ff .literal(new GeometryFactory().createPoint(new Coordinate(1, 1))); Intersects gf = ff.intersects(ff.property("areaOfInfluence"), literalGeom, MatchAction.ALL); Filter unrolled = (Filter) gf.accept(visitor, null); assertTrue(unrolled instanceof Intersects); assertNotSame(gf, unrolled); assertEquals(MatchAction.ALL, ((Intersects) unrolled).getMatchAction()); Intersects newFilter = (Intersects) unrolled; Expression left = newFilter.getExpression1(); Expression right = newFilter.getExpression2(); assertSame(right, literalGeom); assertTrue(left instanceof Function); Function fe = (Function) left; assertEquals("buffer", fe.getName()); Expression arg0 = (Expression) fe.getParameters().get(0); assertTrue(arg0 instanceof PropertyName); assertEquals("location", ((PropertyName) arg0).getPropertyName()); }