TransformSRSFF extends FunctionBase2 { @Override public NodeValue exec(NodeValue v1, NodeValue v2) { try { if (!(v2.isIRI() || v2.isString())) { throw new ExprEvalException("Not a URI: " + FmtUtils.stringForNode(v2.asNode())); } String srsURI; if (v2.isIRI()) { srsURI = v2.asNode().getURI(); } else { srsURI = v2.asString(); } GeometryWrapper geometry = GeometryWrapper.extract(v1, GeometryLiteralIndex.GeometryIndex.PRIMARY); GeometryWrapper convertedGeom = geometry.transform(srsURI); return convertedGeom.asNodeValue(); } catch (DatatypeFormatException | TransformException | FactoryException ex) { throw new ExprEvalException(ex.getMessage(), ex); } }  @Override NodeValue exec(NodeValue v1, NodeValue v2);  }
@Test public void testExec_string() { NodeValue v1 = NodeValue.makeNode("<http: NodeValue v2 = NodeValue.makeString(SRS_URI.DEFAULT_WKT_CRS84); TransformSRSFF instance = new TransformSRSFF(); NodeValue expResult = NodeValue.makeNode("POINT(10 0)", WKTDatatype.INSTANCE); NodeValue result = instance.exec(v1, v2); assertEquals(expResult, result); }
@Test public void testExec_URI() { NodeValue v1 = NodeValue.makeNode("<http: NodeValue v2 = NodeValue.makeNode(NodeFactory.createURI(SRS_URI.DEFAULT_WKT_CRS84)); TransformSRSFF instance = new TransformSRSFF(); NodeValue expResult = NodeValue.makeNode("POINT(10 0)", WKTDatatype.INSTANCE); NodeValue result = instance.exec(v1, v2); assertEquals(expResult, result); }
@Test(expected = ExprEvalException.class) public void testExec_fail() { NodeValue v1 = NodeValue.makeNode("<http: NodeValue v2 = NodeValue.makeInteger(8); TransformSRSFF instance = new TransformSRSFF(); NodeValue expResult = NodeValue.makeNode("POINT(10 0)", WKTDatatype.INSTANCE); NodeValue result = instance.exec(v1, v2); assertEquals(expResult, result); }