@Test public void test() { final CoordinateCircleDistanceFn fn = new CoordinateCircleDistanceFn(); final double d1 = fn.measure(new Coordinate(90, 0), new Coordinate(89, 0)); final double d2 = fn.measure(new Coordinate(89, 0), new Coordinate(90, 0)); final double d3close = fn.measure( new Coordinate(10.000000001, 89.00000010), new Coordinate(10.000000002, 89.00000001)); final double dateLineclose = fn.measure(new Coordinate(-179.9999999, 0.00001), new Coordinate(179.9999999, 0.00001)); assertEquals(d1, d2, 0.0000001); assertEquals(111319.49079322655, d1, 0.00001); assertTrue(d3close < 0.04); assertTrue(dateLineclose < 0.03); }
@Override public double measure(final Coordinate c1, final Coordinate c2) { try { return JTS.orthodromicDistance(c1, c2, getCRS()); } catch (final TransformException e) { throw new RuntimeException("Failed to transform coordinates to provided CRS", e); } catch (final java.lang.AssertionError ae) { LOGGER.info("when distance is too close(0.05 meter), it fails the tolerance test", ae); final GeodeticCalculator calc = new GeodeticCalculator(getCRS()); calc.setStartingGeographicPoint(c1.x, c1.y); calc.setDestinationGeographicPoint(c2.x, c2.y); return ((DefaultEllipsoid) calc.getEllipsoid()).orthodromicDistance( calc.getStartingGeographicPoint().getX(), calc.getStartingGeographicPoint().getY(), calc.getDestinationGeographicPoint().getX(), calc.getDestinationGeographicPoint().getY()); } }
CoordinateCircleDistanceFn implements DistanceFn<Coordinate> { @Override public double measure(final Coordinate c1, final Coordinate c2) { try { return JTS.orthodromicDistance(c1, c2, getCRS()); } catch (final TransformException e) { throw new RuntimeException("Failed to transform coordinates to provided CRS", e); } catch (final java.lang.AssertionError ae) { LOGGER.info("when distance is too close(0.05 meter), it fails the tolerance test", ae); final GeodeticCalculator calc = new GeodeticCalculator(getCRS()); calc.setStartingGeographicPoint(c1.x, c1.y); calc.setDestinationGeographicPoint(c2.x, c2.y); return ((DefaultEllipsoid) calc.getEllipsoid()).orthodromicDistance( calc.getStartingGeographicPoint().getX(), calc.getStartingGeographicPoint().getY(), calc.getDestinationGeographicPoint().getX(), calc.getDestinationGeographicPoint().getY()); } } }
CoordinateCircleDistanceFn implements DistanceFn<Coordinate> { @Override public double measure(final Coordinate c1, final Coordinate c2) { try { return JTS.orthodromicDistance(c1, c2, getCRS()); } catch (final TransformException e) { throw new RuntimeException("Failed to transform coordinates to provided CRS", e); } catch (final java.lang.AssertionError ae) { LOGGER.info("when distance is too close(0.05 meter), it fails the tolerance test", ae); final GeodeticCalculator calc = new GeodeticCalculator(getCRS()); calc.setStartingGeographicPoint(c1.x, c1.y); calc.setDestinationGeographicPoint(c2.x, c2.y); return ((DefaultEllipsoid) calc.getEllipsoid()).orthodromicDistance( calc.getStartingGeographicPoint().getX(), calc.getStartingGeographicPoint().getY(), calc.getDestinationGeographicPoint().getX(), calc.getDestinationGeographicPoint().getY()); } }  }
CoordinateCircleDistanceFn implements DistanceFn<Coordinate> { @Override public double measure(final Coordinate c1, final Coordinate c2) { try { return JTS.orthodromicDistance(c1, c2, getCRS()); } catch (final TransformException e) { throw new RuntimeException("Failed to transform coordinates to provided CRS", e); } catch (final java.lang.AssertionError ae) { LOGGER.info("when distance is too close(0.05 meter), it fails the tolerance test", ae); final GeodeticCalculator calc = new GeodeticCalculator(getCRS()); calc.setStartingGeographicPoint(c1.x, c1.y); calc.setDestinationGeographicPoint(c2.x, c2.y); return ((DefaultEllipsoid) calc.getEllipsoid()).orthodromicDistance( calc.getStartingGeographicPoint().getX(), calc.getStartingGeographicPoint().getY(), calc.getDestinationGeographicPoint().getX(), calc.getDestinationGeographicPoint().getY()); } }  @Override double measure(final Coordinate c1, final Coordinate c2); }
CoordinateCircleDistanceFn implements DistanceFn<Coordinate> { @Override public double measure(final Coordinate c1, final Coordinate c2) { try { return JTS.orthodromicDistance(c1, c2, getCRS()); } catch (final TransformException e) { throw new RuntimeException("Failed to transform coordinates to provided CRS", e); } catch (final java.lang.AssertionError ae) { LOGGER.info("when distance is too close(0.05 meter), it fails the tolerance test", ae); final GeodeticCalculator calc = new GeodeticCalculator(getCRS()); calc.setStartingGeographicPoint(c1.x, c1.y); calc.setDestinationGeographicPoint(c2.x, c2.y); return ((DefaultEllipsoid) calc.getEllipsoid()).orthodromicDistance( calc.getStartingGeographicPoint().getX(), calc.getStartingGeographicPoint().getY(), calc.getDestinationGeographicPoint().getX(), calc.getDestinationGeographicPoint().getY()); } }  @Override double measure(final Coordinate c1, final Coordinate c2);  }