Java Code Examples for org.geotools.referencing.GeodeticCalculator#getOrthodromicDistance()
The following examples show how to use
org.geotools.referencing.GeodeticCalculator#getOrthodromicDistance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestENU.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
public void testWithGeotools() throws MatrixException { Coordinate c1 = new Coordinate(11, 46, 0); Coordinate c2 = new Coordinate(11.001, 46.001, 0); GeodeticCalculator gc = new GeodeticCalculator(DefaultGeographicCRS.WGS84); gc.setStartingGeographicPoint(c1.x, c1.y); gc.setDestinationGeographicPoint(c2.x, c2.y); double orthodromicDistance = gc.getOrthodromicDistance(); ENU enu = new ENU(c1); Coordinate ce1 = enu.wgs84ToEnu(c1); Coordinate ce2 = enu.wgs84ToEnu(c2); double distance = ce1.distance(ce2); assertTrue(isDeltaOk(orthodromicDistance, distance)); Coordinate c1Back = enu.enuToWgs84(ce1); Coordinate c2Back = enu.enuToWgs84(ce2); assertEquals(0, c1.distance(c1Back), 0.000001); assertEquals(0, c2.distance(c2Back), 0.000001); }
Example 2
Source File: ConfigurationDtoPostProcessor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
private double getUnitLength(String mapCrsKey, Bbox mapBounds) throws LayerException { try { if (null == mapBounds) { throw new LayerException(ExceptionCode.MAP_MAX_EXTENT_MISSING); } Crs crs = geoService.getCrs2(mapCrsKey); GeodeticCalculator calculator = new GeodeticCalculator(crs); Coordinate center = new Coordinate(0.5 * (mapBounds.getX() + mapBounds.getMaxX()), 0.5 * (mapBounds.getY() + mapBounds.getMaxY())); calculator.setStartingPosition(new DirectPosition2D(crs, center.getX(), center.getY())); calculator.setDestinationPosition(new DirectPosition2D(crs, center.getX() + 1, center.getY())); return calculator.getOrthodromicDistance(); } catch (TransformException e) { throw new LayerException(e, ExceptionCode.TRANSFORMER_CREATE_LAYER_TO_MAP_FAILED); } }
Example 3
Source File: GeoUtils.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Computes the distance between two points. * * @param from the origin point. * @param to the end point. * @return the orthodromic distance between the given points. */ public static double getDistanceBetweenTwoPoints( Point2D from, Point2D to) { GeodeticCalculator calc = new GeodeticCalculator(); calc.setStartingGeographicPoint( from ); calc.setDestinationGeographicPoint( to); return calc.getOrthodromicDistance(); }
Example 4
Source File: OmsGeopaparazzi4Converter.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Extracts profile information from logs. * * @param log the log to analyze. * @param size the number of points in the log (as off: int size = log.points.size(); ) * @param xProfile the array of to put the progressive distance in. * @param yProfile the array of to put the elevation in. * @param xPlanim the array of to put the x coord in. * @param yPlanim the array of to put the y coord in. * @param timestampArray the array of to put the times in. */ public static void populateProfilesForSingleLog( GpsLog log, int size, double[] xProfile, double[] yProfile, double[] xPlanim, double[] yPlanim, long[] timestampArray ) { GeodeticCalculator gc = new GeodeticCalculator(DefaultGeographicCRS.WGS84); double runningDistance = 0; for( int i = 0; i < size - 1; i++ ) { GpsPoint p1 = log.points.get(i); GpsPoint p2 = log.points.get(i + 1); double lon1 = p1.lon; double lat1 = p1.lat; double altim1 = p1.altim; long utc1 = p1.utctime; double lon2 = p2.lon; double lat2 = p2.lat; double altim2 = p2.altim; long utc2 = p2.utctime; gc.setStartingGeographicPoint(lon1, lat1); gc.setDestinationGeographicPoint(lon2, lat2); double distance = gc.getOrthodromicDistance(); runningDistance += distance; if (i == 0) { xProfile[i] = 0.0; yProfile[i] = altim1; xPlanim[i] = lon1; yPlanim[i] = lat1; timestampArray[i] = utc1; } xProfile[i + 1] = runningDistance; yProfile[i + 1] = altim2; xPlanim[i + 1] = lon2; yPlanim[i + 1] = lat2; timestampArray[i + 1] = utc2; } }
Example 5
Source File: HM.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
public static double distanceLL( double lon1, double lat1, double lon2, double lat2 ) { GeodeticCalculator gc = new GeodeticCalculator(DefaultGeographicCRS.WGS84); gc.setStartingGeographicPoint(lon1, lat1); gc.setDestinationGeographicPoint(lon2, lat2); double distance = gc.getOrthodromicDistance(); return distance; }
Example 6
Source File: GeoDistanceUtil.java From searoute with European Union Public License 1.2 | 4 votes |
public static double getDistanceKM(double slon, double slat, double dlon, double dlat){ GeodeticCalculator gc = new GeodeticCalculator(); gc.setStartingGeographicPoint(slon, slat); gc.setDestinationGeographicPoint(dlon, dlat); return gc.getOrthodromicDistance() * 0.001; }