@Test public void testOrthodromicDistance() throws Exception { final Parser parser = new Parser(); final DefaultProjectedCRS crs = (DefaultProjectedCRS) parser.parseObject(NAD83_BC); double d = JTS.orthodromicDistance( new Coordinate(1402848.1938534670, 651571.1729878788), new Coordinate(1389481.3104009738, 641990.9430108378), crs); double realValue = 16451.33114; assertEquals(realValue, d, 0.1); }
public static synchronized double orthodromicDistance( final Coordinate p1, final Coordinate p2, final CoordinateReferenceSystem crs) throws TransformException { ensureNonNull("p1", p1); ensureNonNull("p2", p2); ensureNonNull("crs", crs); GeodeticCalculator gc = (GeodeticCalculator) CALCULATORS.get(crs); if (gc == null) { gc = new GeodeticCalculator(crs); CALCULATORS.put(crs, gc); } assert crs.equals(gc.getCoordinateReferenceSystem()) : crs; final GeneralDirectPosition pos = POSITIONS[Math.min(POSITIONS.length - 1, crs.getCoordinateSystem().getDimension())]; pos.setCoordinateReferenceSystem(crs); copy(p1, pos.ordinates); gc.setStartingPosition(pos); copy(p2, pos.ordinates); gc.setDestinationPosition(pos); return gc.getOrthodromicDistance(); }
JTS { public static synchronized double orthodromicDistance( final Coordinate p1, final Coordinate p2, final CoordinateReferenceSystem crs) throws TransformException { ensureNonNull("p1", p1); ensureNonNull("p2", p2); ensureNonNull("crs", crs); GeodeticCalculator gc = (GeodeticCalculator) CALCULATORS.get(crs); if (gc == null) { gc = new GeodeticCalculator(crs); CALCULATORS.put(crs, gc); } assert crs.equals(gc.getCoordinateReferenceSystem()) : crs; final GeneralDirectPosition pos = POSITIONS[Math.min(POSITIONS.length - 1, crs.getCoordinateSystem().getDimension())]; pos.setCoordinateReferenceSystem(crs); copy(p1, pos.ordinates); gc.setStartingPosition(pos); copy(p2, pos.ordinates); gc.setDestinationPosition(pos); return gc.getOrthodromicDistance(); } }
JTS { public static synchronized double orthodromicDistance( final Coordinate p1, final Coordinate p2, final CoordinateReferenceSystem crs) throws TransformException { ensureNonNull("p1", p1); ensureNonNull("p2", p2); ensureNonNull("crs", crs); GeodeticCalculator gc = (GeodeticCalculator) CALCULATORS.get(crs); if (gc == null) { gc = new GeodeticCalculator(crs); CALCULATORS.put(crs, gc); } assert crs.equals(gc.getCoordinateReferenceSystem()) : crs; final GeneralDirectPosition pos = POSITIONS[Math.min(POSITIONS.length - 1, crs.getCoordinateSystem().getDimension())]; pos.setCoordinateReferenceSystem(crs); copy(p1, pos.ordinates); gc.setStartingPosition(pos); copy(p2, pos.ordinates); gc.setDestinationPosition(pos); return gc.getOrthodromicDistance(); } private  JTS(); }
JTS { public static synchronized double orthodromicDistance( final Coordinate p1, final Coordinate p2, final CoordinateReferenceSystem crs) throws TransformException { ensureNonNull("p1", p1); ensureNonNull("p2", p2); ensureNonNull("crs", crs); GeodeticCalculator gc = (GeodeticCalculator) CALCULATORS.get(crs); if (gc == null) { gc = new GeodeticCalculator(crs); CALCULATORS.put(crs, gc); } assert crs.equals(gc.getCoordinateReferenceSystem()) : crs; final GeneralDirectPosition pos = POSITIONS[Math.min(POSITIONS.length - 1, crs.getCoordinateSystem().getDimension())]; pos.setCoordinateReferenceSystem(crs); copy(p1, pos.ordinates); gc.setStartingPosition(pos); copy(p2, pos.ordinates); gc.setDestinationPosition(pos); return gc.getOrthodromicDistance(); } private  JTS(); static Envelope transform(final Envelope envelope, final MathTransform transform); static Envelope transform(
            final Envelope sourceEnvelope,
            Envelope targetEnvelope,
            final MathTransform transform,
            int npoints); static ReferencedEnvelope3D transformTo3D(
            final ReferencedEnvelope sourceEnvelope,
            CoordinateReferenceSystem targetCRS,
            boolean lenient,
            int npoints); static ReferencedEnvelope transformTo2D(
            final ReferencedEnvelope sourceEnvelope,
            CoordinateReferenceSystem targetCRS,
            boolean lenient,
            int npoints); static Geometry transform(final Geometry geom, final MathTransform transform); static Coordinate transform(
            final Coordinate source, Coordinate dest, final MathTransform transform); static Envelope toGeographic(
            final Envelope envelope, final CoordinateReferenceSystem crs); static ReferencedEnvelope toGeographic(final ReferencedEnvelope envelope); static void xform(final MathTransform transform, final double[] src, final double[] dest); static synchronized double orthodromicDistance(
            final Coordinate p1, final Coordinate p2, final CoordinateReferenceSystem crs); static DirectPosition toDirectPosition(
            final Coordinate point, final CoordinateReferenceSystem crs); static void copy(final Coordinate point, final double[] ordinates); static Geometry toGeometry(final Shape shape); static Geometry toGeometry(final Shape shape, final GeometryFactory factory); static Envelope2D getEnvelope2D(
            final Envelope envelope, final CoordinateReferenceSystem crs); static Point toGeometry(DirectPosition position); static Point toGeometry(DirectPosition position, GeometryFactory factory); static Polygon toGeometry(Envelope envelope); static Polygon toGeometry(final Envelope envelope, GeometryFactory factory); static ReferencedEnvelope toEnvelope(Geometry geom); static Polygon toGeometry(ReferencedEnvelope bbox); static Polygon toGeometry(BoundingBox bbox, GeometryFactory factory, int npoints); static Geometry toGeographic(Geometry geom, final CoordinateReferenceSystem crs); static Polygon toGeometry(BoundingBox bbox); static Polygon toGeometry(BoundingBox bbox, final GeometryFactory factory); static void checkCoordinatesRange(Geometry geom, CoordinateReferenceSystem crs); static Geometry smooth(final Geometry geom, double fit); static Geometry smooth(final Geometry geom, double fit, final GeometryFactory factory); static CoordinateSequence createCS(
            CoordinateSequenceFactory csFactory, int size, int dimension); static CoordinateSequence createCS(
            CoordinateSequenceFactory csFactory, int size, int dimension, int measures); static ReferencedEnvelope bounds(Geometry geometry, CoordinateReferenceSystem crs); static Geometry removeCollinearVertices(final Geometry g); static Geometry removeCollinearVertices(final Geometry geometry, int minPoints); static List<Polygon> makeValid(Polygon polygon, boolean removeHoles); static Rectangle2D toRectangle2D(Envelope envelope); static Envelope toEnvelope(Rectangle2D rectangle); static Polygon toPolygon(java.awt.Polygon polygon); static Polygon toPolygon(java.awt.Rectangle rectangle); static Polygon toPolygon(Rectangle2D rectangle); static boolean equals(Envelope e1, Envelope e2, double tolerance); static boolean equals(BoundingBox a, BoundingBox b, double tolerance); }
JTS { public static synchronized double orthodromicDistance( final Coordinate p1, final Coordinate p2, final CoordinateReferenceSystem crs) throws TransformException { ensureNonNull("p1", p1); ensureNonNull("p2", p2); ensureNonNull("crs", crs); GeodeticCalculator gc = (GeodeticCalculator) CALCULATORS.get(crs); if (gc == null) { gc = new GeodeticCalculator(crs); CALCULATORS.put(crs, gc); } assert crs.equals(gc.getCoordinateReferenceSystem()) : crs; final GeneralDirectPosition pos = POSITIONS[Math.min(POSITIONS.length - 1, crs.getCoordinateSystem().getDimension())]; pos.setCoordinateReferenceSystem(crs); copy(p1, pos.ordinates); gc.setStartingPosition(pos); copy(p2, pos.ordinates); gc.setDestinationPosition(pos); return gc.getOrthodromicDistance(); } private  JTS(); static Envelope transform(final Envelope envelope, final MathTransform transform); static Envelope transform(
            final Envelope sourceEnvelope,
            Envelope targetEnvelope,
            final MathTransform transform,
            int npoints); static ReferencedEnvelope3D transformTo3D(
            final ReferencedEnvelope sourceEnvelope,
            CoordinateReferenceSystem targetCRS,
            boolean lenient,
            int npoints); static ReferencedEnvelope transformTo2D(
            final ReferencedEnvelope sourceEnvelope,
            CoordinateReferenceSystem targetCRS,
            boolean lenient,
            int npoints); static Geometry transform(final Geometry geom, final MathTransform transform); static Coordinate transform(
            final Coordinate source, Coordinate dest, final MathTransform transform); static Envelope toGeographic(
            final Envelope envelope, final CoordinateReferenceSystem crs); static ReferencedEnvelope toGeographic(final ReferencedEnvelope envelope); static void xform(final MathTransform transform, final double[] src, final double[] dest); static synchronized double orthodromicDistance(
            final Coordinate p1, final Coordinate p2, final CoordinateReferenceSystem crs); static DirectPosition toDirectPosition(
            final Coordinate point, final CoordinateReferenceSystem crs); static void copy(final Coordinate point, final double[] ordinates); static Geometry toGeometry(final Shape shape); static Geometry toGeometry(final Shape shape, final GeometryFactory factory); static Envelope2D getEnvelope2D(
            final Envelope envelope, final CoordinateReferenceSystem crs); static Point toGeometry(DirectPosition position); static Point toGeometry(DirectPosition position, GeometryFactory factory); static Polygon toGeometry(Envelope envelope); static Polygon toGeometry(final Envelope envelope, GeometryFactory factory); static ReferencedEnvelope toEnvelope(Geometry geom); static Polygon toGeometry(ReferencedEnvelope bbox); static Polygon toGeometry(BoundingBox bbox, GeometryFactory factory, int npoints); static Geometry toGeographic(Geometry geom, final CoordinateReferenceSystem crs); static Polygon toGeometry(BoundingBox bbox); static Polygon toGeometry(BoundingBox bbox, final GeometryFactory factory); static void checkCoordinatesRange(Geometry geom, CoordinateReferenceSystem crs); static Geometry smooth(final Geometry geom, double fit); static Geometry smooth(final Geometry geom, double fit, final GeometryFactory factory); static CoordinateSequence createCS(
            CoordinateSequenceFactory csFactory, int size, int dimension); static CoordinateSequence createCS(
            CoordinateSequenceFactory csFactory, int size, int dimension, int measures); static ReferencedEnvelope bounds(Geometry geometry, CoordinateReferenceSystem crs); static Geometry removeCollinearVertices(final Geometry g); static Geometry removeCollinearVertices(final Geometry geometry, int minPoints); static List<Polygon> makeValid(Polygon polygon, boolean removeHoles); static Rectangle2D toRectangle2D(Envelope envelope); static Envelope toEnvelope(Rectangle2D rectangle); static Polygon toPolygon(java.awt.Polygon polygon); static Polygon toPolygon(java.awt.Rectangle rectangle); static Polygon toPolygon(Rectangle2D rectangle); static boolean equals(Envelope e1, Envelope e2, double tolerance); static boolean equals(BoundingBox a, BoundingBox b, double tolerance); static final AffineTransformation Y_INVERSION; }