Package com.graphhopper.util
Class DistancePlaneProjection
java.lang.Object
com.graphhopper.util.DistanceCalcEarth
com.graphhopper.util.DistancePlaneProjection
- All Implemented Interfaces:
DistanceCalc
Calculates the approximate distance of two points on earth. Very good results if delat_lon is
not too big (see DistanceCalcTest), e.g. the distance is small.
http://en.wikipedia.org/wiki/Geographical_distance#Spherical_Earth_projected_to_a_plane
http://stackoverflow.com/q/1006654
http://en.wikipedia.org/wiki/Mercator_projection#Mathematics_of_the_Mercator_projection http://gis.stackexchange.com/questions/4906/why-is-law-of-cosines-more-preferable-than-haversine-when-calculating-distance-b
- Author:
- Peter Karich
-
Field Summary
FieldsFields inherited from class com.graphhopper.util.DistanceCalcEarth
C, DIST_EARTH, KM_MILE, METERS_PER_DEGREE, R, R_EQ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecalcDenormalizedDist(double normedDist) Inverse to calcNormalizedDist.doublecalcDist(double fromLat, double fromLon, double toLat, double toLon) Calculates distance of (from, to) in meter.doublecalcDist3D(double fromLat, double fromLon, double fromHeight, double toLat, double toLon, double toHeight) This implements a rather quick solution to calculate 3D distances on earth using euclidean geometry mixed with Haversine formula used for the on earth distance.doublecalcNormalizedDist(double dist) Returns the specified length in normalized meter.doublecalcNormalizedDist(double fromLat, double fromLon, double toLat, double toLon) Calculates in normalized metertoString()Methods inherited from class com.graphhopper.util.DistanceCalcEarth
calcCircumference, calcCrossingPointToEdge, calcDistance, calcDistance, calcNormalizedEdgeDistance, calcNormalizedEdgeDistance3D, createBBox, hasElevationDiff, intermediatePoint, isCrossBoundary, isDateLineCrossOver, projectCoordinate, validEdgeDistance
-
Field Details
-
DIST_PLANE
-
-
Constructor Details
-
DistancePlaneProjection
public DistancePlaneProjection()
-
-
Method Details
-
calcDist
public double calcDist(double fromLat, double fromLon, double toLat, double toLon) Description copied from class:DistanceCalcEarthCalculates distance of (from, to) in meter.http://en.wikipedia.org/wiki/Haversine_formula a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2) c = 2.atan2(√a, √(1−a)) d = R.c
- Specified by:
calcDistin interfaceDistanceCalc- Overrides:
calcDistin classDistanceCalcEarth
-
calcDist3D
public double calcDist3D(double fromLat, double fromLon, double fromHeight, double toLat, double toLon, double toHeight) Description copied from class:DistanceCalcEarthThis implements a rather quick solution to calculate 3D distances on earth using euclidean geometry mixed with Haversine formula used for the on earth distance. The haversine formula makes not so much sense as it is only important for large distances where then the rather smallish heights would becomes negligible.- Specified by:
calcDist3Din interfaceDistanceCalc- Overrides:
calcDist3Din classDistanceCalcEarth
-
calcDenormalizedDist
public double calcDenormalizedDist(double normedDist) Description copied from interface:DistanceCalcInverse to calcNormalizedDist. Returned the length in meter.- Specified by:
calcDenormalizedDistin interfaceDistanceCalc- Overrides:
calcDenormalizedDistin classDistanceCalcEarth
-
calcNormalizedDist
public double calcNormalizedDist(double dist) Description copied from class:DistanceCalcEarthReturns the specified length in normalized meter.- Specified by:
calcNormalizedDistin interfaceDistanceCalc- Overrides:
calcNormalizedDistin classDistanceCalcEarth
-
calcNormalizedDist
public double calcNormalizedDist(double fromLat, double fromLon, double toLat, double toLon) Description copied from interface:DistanceCalcCalculates in normalized meter- Specified by:
calcNormalizedDistin interfaceDistanceCalc- Overrides:
calcNormalizedDistin classDistanceCalcEarth
-
toString
- Overrides:
toStringin classDistanceCalcEarth
-