@Test public void testBBOX() { ff.bbox("geom", 0, 0, 10, 10, "EPSG:4326").accept(visitor, null); assertTrue(visitor.hasSpatialFilter); }
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 testBboxNoReprojection() { // no reprojection needed in fact Filter bbox = ff.bbox(ff.property("geom"), 10, 10, 20, 20, "EPSG:4326"); Filter clone = (Filter) bbox.accept(reprojector, null); assertNotSame(bbox, clone); assertEquals(bbox, clone); }
@Test public void testBbox() { Filter f = ff.bbox("geom", -10, -10, 10, 10, null); Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testSpatialDefaulter() throws Exception { // a spatial filter in the same SRS as the geometry StyleBuilder sb = new StyleBuilder(); PolygonSymbolizer ps = sb.createPolygonSymbolizer(); Style style = sb.createStyle(ps); Rule rule = style.featureTypeStyles().get(0).rules().get(0); rule.setFilter(ff.bbox("geom", 1, 1, 4, 4, null)); content.addLayer(new FeatureLayer(squareFS, style)); RendererBaseTest.showRender("Spatial without CRS", renderer, TIME, bounds); assertEquals(2, renderedIds.size()); }
@Test public void testSpatialNoReprojection() throws Exception { // a spatial filter in the same SRS as the geometry StyleBuilder sb = new StyleBuilder(); PolygonSymbolizer ps = sb.createPolygonSymbolizer(); Style style = sb.createStyle(ps); Rule rule = style.featureTypeStyles().get(0).rules().get(0); rule.setFilter(ff.bbox("geom", 1, 1, 4, 4, "EPSG:4326")); content.addLayer(new FeatureLayer(squareFS, style)); RendererBaseTest.showRender("Spatial with default CRS", renderer, TIME, bounds); assertEquals(2, renderedIds.size()); }
@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()); } }
public void testBboxFilter() throws Exception { if (!isGeographySupportAvailable()) { return; } // should match only "r2" BBOX bbox = ff.bbox(aname("geo"), -120, 25, -100, 40, "EPSG:4326"); FeatureCollection features = dataStore.getFeatureSource(tname("geopoint")).getFeatures(bbox); assertEquals(2, features.size()); }
@Test public void testOr() { Filter f = ff.or( ff.bbox("geom", -10, -10, 10, 10, null), ff.equals(ff.property("att"), ff.literal("10"))); Envelope env = (Envelope) f.accept(visitor, null); assertEquals(infinity, env); }
@Test public void testAndIsNull() throws Exception { final Filter f = ff.and(ff.bbox("geom", -10, -10, 10, 10, null), ff.isNull(ff.literal("someDate"))); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testAndIsNil() throws Exception { final Filter f = ff.and( ff.bbox("geom", -10, -10, 10, 10, null), ff.isNil(ff.literal("someDate"), null)); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); } }
@Test public void testAnd() { Filter f = ff.and( ff.bbox("geom", -10, -10, 10, 10, null), ff.equals(ff.property("att"), ff.literal("10"))); Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testAndTemporalDuring() throws Exception { final Period p = period("2016-01-01T00:00:00.000-0500", "2106-01-02T00:00:00.000-0500"); final Filter f = ff.and( ff.bbox("geom", -10, -10, 10, 10, null), ff.during(ff.literal("someDate"), ff.literal(p))); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testAndTemporalEnds() throws Exception { final Instant start = instant("2016-01-01T00:00:00.000-0500"); final Filter f = ff.and( ff.bbox("geom", -10, -10, 10, 10, null), ff.ends(ff.literal("someDate"), ff.literal(start))); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testAndTemporalTOverlaps() throws Exception { final Period p = period("2016-01-01T00:00:00.000-0500", "2106-01-02T00:00:00.000-0500"); final Filter f = ff.and( ff.bbox("geom", -10, -10, 10, 10, null), ff.toverlaps(ff.literal("someDate"), ff.literal(p))); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testAndTemporalMetBy() throws Exception { final Period p = period("2016-01-01T00:00:00.000-0500", "2106-01-02T00:00:00.000-0500"); final Filter f = ff.and( ff.bbox("geom", -10, -10, 10, 10, null), ff.metBy(ff.literal("someDate"), ff.literal(p))); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testAndTemporalBefore() throws Exception { final Instant start = instant("2016-01-01T00:00:00.000-0500"); final Filter f = ff.and( ff.bbox("geom", -10, -10, 10, 10, null), ff.before(ff.literal("someDate"), ff.literal(start))); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testAndTemporalMeets() throws Exception { final Period p = period("2016-01-01T00:00:00.000-0500", "2106-01-02T00:00:00.000-0500"); final Filter f = ff.and( ff.bbox("geom", -10, -10, 10, 10, null), ff.meets(ff.literal("someDate"), ff.literal(p))); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testAndTemporalOverlappedBy() throws Exception { final Period p = period("2016-01-01T00:00:00.000-0500", "2106-01-02T00:00:00.000-0500"); final Filter f = ff.and( ff.bbox("geom", -10, -10, 10, 10, null), ff.overlappedBy(ff.literal("someDate"), ff.literal(p))); final Envelope env = (Envelope) f.accept(visitor, null); assertEquals(new Envelope(-10, 10, -10, 10), env); }
@Test public void testAndDWithin() { Point geom = new GeometryFactory().createPoint(new Coordinate(0, 0)); Filter filter = ff.dwithin(ff.property("geom"), ff.literal(geom), 100, "metre"); filter = ff.and(filter, ff.bbox(ff.property("geom"), 50, 50, 150, 150, null)); Envelope env = (Envelope) filter.accept(visitor, null); assertEquals(new Envelope(50, 100, 50, 100), env); }