FilterFunction_offset extends FunctionExpressionImpl implements 
        GeometryTransformation { public ReferencedEnvelope invert(ReferencedEnvelope renderingEnvelope) { Double offsetX = getExpression(1).evaluate(null, Double.class); Double offsetY = getExpression(2).evaluate(null, Double.class); if (offsetX != null && offsetY != null) { ReferencedEnvelope offseted = new ReferencedEnvelope(renderingEnvelope); offseted.translate(-offsetX, -offsetY); return offseted; } else { return null; } } FilterFunction_offset(); int getArgCount(); Object evaluate(Object feature); ReferencedEnvelope invert(ReferencedEnvelope renderingEnvelope); static FunctionName NAME; }
@Test public void testInvert() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Function function = ff.function("offset", ff.property("the_geom"), ff.literal(1), ff.literal(2)); assertTrue(function instanceof GeometryTransformation); GeometryTransformation gt = (GeometryTransformation) function; ReferencedEnvelope re = new ReferencedEnvelope(0, 1, 0, 1, DefaultGeographicCRS.WGS84); ReferencedEnvelope inverted = gt.invert(re); ReferencedEnvelope expected = new ReferencedEnvelope(-1, 0, -2, -1, DefaultGeographicCRS.WGS84); assertEquals(expected, inverted); }