NearbyFF extends FunctionBase4 { public static final boolean relate(GeometryWrapper geometry1, GeometryWrapper geometry2, double radius, String unitsURI) { try { double distance = geometry1.distance(geometry2, unitsURI); return distance < radius; } catch (FactoryException | MismatchedDimensionException | TransformException ex) { throw new ExprEvalException(ex.getMessage() + ": " + geometry1.asLiteral() + ", " + geometry2.asLiteral() + ", " + Double.toString(radius) + ", " + unitsURI, ex); } }  @Override NodeValue exec(NodeValue v1, NodeValue v2, NodeValue v3, NodeValue v4); static final boolean relate(GeometryWrapper geometry1, GeometryWrapper geometry2, double radius, String unitsURI);  }
@Test public void testRelate() { GeometryWrapper geometry1 = GeometryWrapper.extract("<http: GeometryWrapper geometry2 = GeometryWrapper.extract("<http: double radius = 5.0; String unitsURI = Unit_URI.KILOMETER_URL; boolean expResult = true; boolean result = NearbyFF.relate(geometry1, geometry2, radius, unitsURI); assertEquals(expResult, result); }
@Test public void testRelate_OSGB() { GeometryWrapper geometry1 = GeometryWrapper.extract("<http: GeometryWrapper geometry2 = GeometryWrapper.extract("<http: double radius = 10.1; String unitsURI = Unit_URI.KILOMETER_URL; boolean expResult = true; boolean result = NearbyFF.relate(geometry1, geometry2, radius, unitsURI); assertEquals(expResult, result); }
@Test public void testRelate_OSGB_fail() { GeometryWrapper geometry1 = GeometryWrapper.extract("<http: GeometryWrapper geometry2 = GeometryWrapper.extract("<http: double radius = 9.9; String unitsURI = Unit_URI.KILOMETER_URL; boolean expResult = false; boolean result = NearbyFF.relate(geometry1, geometry2, radius, unitsURI); assertEquals(expResult, result); }
@Test public void testRelate_fail() { GeometryWrapper geometry1 = GeometryWrapper.extract("<http: GeometryWrapper geometry2 = GeometryWrapper.extract("<http: double radius = 5.0; String unitsURI = Unit_URI.KILOMETER_URL; boolean expResult = false; boolean result = NearbyFF.relate(geometry1, geometry2, radius, unitsURI); assertEquals(expResult, result); }