length += JTS.orthodromicDistance(coordinates[i], coordinates[i + 1], worldCRS);
JTS.orthodromicDistance( new Coordinate(newCsLatLong[0], newCsLatLong[1]), new Coordinate(newCsLatLong[2], newCsLatLong[3]), JTS.orthodromicDistance( new Coordinate(csLatLong[0], csLatLong[1]), new Coordinate(csLatLong[2], csLatLong[3]),
/** Tests the distance between points function */ @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 double orthodromicDistance(Coordinate a, Coordinate b) { try { return JTS.orthodromicDistance(a,b,WORLD_CRS); } catch (TransformException ex) { throw new IllegalStateException("error computing distance: a=" + a + " b=" + b,ex); } }
Coordinate test; test = new Coordinate(x + halfCrsWidth, y); double deltaX = JTS.orthodromicDistance(coordinate, test, crs); test = new Coordinate(x, y + halfCrsHeight); double deltaY = JTS.orthodromicDistance(coordinate, test, crs); if (Math.abs(deltaX - width / 2) < DISTANCE_PRECISION && Math.abs(deltaY - height / 2) < DISTANCE_PRECISION) {
/** Get the length of a linestring in meters */ public static double getDistance(LineString tripGeometry) { double distance = 0; for (int i = 0; i < tripGeometry.getNumPoints() - 1; i++) { try { distance += JTS.orthodromicDistance(tripGeometry.getCoordinateN(i), tripGeometry.getCoordinateN(i + 1), DefaultGeographicCRS.WGS84); } catch (TransformException e) { throw new RuntimeException(e); } } return distance; } }
/ envelope.getHeight() * imageHeight; double distance_ground = JTS.orthodromicDistance(new Coordinate( newCsLatLong[0], newCsLatLong[1]), new Coordinate( newCsLatLong[2], newCsLatLong[3]), double diagonalGroundDistance = JTS.orthodromicDistance(new Coordinate( csLatLong[0], csLatLong[1]), new Coordinate(csLatLong[2], csLatLong[3]), DefaultGeographicCRS.WGS84);
/ envelope.getHeight() * imageHeight; double distance_ground = JTS.orthodromicDistance(new Coordinate( newCsLatLong[0], newCsLatLong[1]), new Coordinate( newCsLatLong[2], newCsLatLong[3]), double diagonalGroundDistance = JTS.orthodromicDistance(new Coordinate( csLatLong[0], csLatLong[1]), new Coordinate(csLatLong[2], csLatLong[3]), DefaultGeographicCRS.WGS84);
/** * Calculates the distance between two points. If the SRID is 0, a cartesian coordinate system is assumed and {@link * CartesianDistanceCalculator} is used, otherwise {@link JTS#orthodromicDistance(Coordinate, Coordinate, * CoordinateReferenceSystem)} is used. * * @param p1 the source point * @param p2 the target point * @return the distance between <tt>p1</tt> and <tt>p2</tt> or {@code Double.NaN} if the distance cannot be * calculated. * @throws RuntimeException if points have different SRIDs */ @Override public double distance(Point p1, Point p2) { if (p1.getSRID() == p2.getSRID()) { if (p1.getSRID() == 0) { return CartesianDistanceCalculator.getInstance().distance(p1, p2); } else { try { return JTS.orthodromicDistance(p1.getCoordinate(), p2.getCoordinate(), CRSUtils.getCRS(p1.getSRID())); } catch (TransformException e) { e.printStackTrace(); return Double.NaN; } } } else { throw new RuntimeException("Incompatible coordinate reference systems."); } }