IntersectionFF extends FunctionBase2 { @Override public NodeValue exec(NodeValue v1, NodeValue v2) { try { GeometryWrapper geometry1 = GeometryWrapper.extract(v1, GeometryIndex.PRIMARY); GeometryWrapper geometry2 = GeometryWrapper.extract(v2, GeometryIndex.SECONDARY); GeometryWrapper intersection = geometry1.intersection(geometry2); return intersection.asNodeValue(); } catch (DatatypeFormatException ex) { throw new ExprEvalException(ex.getMessage(), ex); } catch (FactoryException | MismatchedDimensionException | TransformException ex) { throw new ExprEvalException(ex.getMessage() + ": " + FmtUtils.stringForNode(v1.asNode()) + ", " + FmtUtils.stringForNode(v2.asNode()), ex); } }  @Override NodeValue exec(NodeValue v1, NodeValue v2);  }
@Test public void testExec_point_polygon() { NodeValue v1 = NodeValue.makeNode("<http: NodeValue v2 = NodeValue.makeNode("<http: IntersectionFF instance = new IntersectionFF(); NodeValue expResult = NodeValue.makeNode("<http: NodeValue result = instance.exec(v1, v2); assertEquals(expResult, result); }
@Test public void testExec_linestring_polygon() { NodeValue v1 = NodeValue.makeNode("<http: NodeValue v2 = NodeValue.makeNode("<http: IntersectionFF instance = new IntersectionFF(); NodeValue expResult = NodeValue.makeNode("<http: NodeValue result = instance.exec(v1, v2); assertEquals(expResult, result); }
@Test public void testExec_linestring_polygon_empty() { NodeValue v1 = NodeValue.makeNode("<http: NodeValue v2 = NodeValue.makeNode("<http: IntersectionFF instance = new IntersectionFF(); NodeValue expResult = NodeValue.makeNode("<http: NodeValue result = instance.exec(v1, v2); assertEquals(expResult, result); }