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 TypeMethodDescriptiondouble
calcDenormalizedDist
(double normedDist) Inverse to calcNormalizedDist.double
calcDist
(double fromLat, double fromLon, double toLat, double toLon) Calculates distance of (from, to) in meter.double
calcDist3D
(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.double
calcNormalizedDist
(double dist) Returns the specified length in normalized meter.double
calcNormalizedDist
(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:DistanceCalcEarth
Calculates 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:
calcDist
in interfaceDistanceCalc
- Overrides:
calcDist
in classDistanceCalcEarth
-
calcDist3D
public double calcDist3D(double fromLat, double fromLon, double fromHeight, double toLat, double toLon, double toHeight) Description copied from class:DistanceCalcEarth
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. 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:
calcDist3D
in interfaceDistanceCalc
- Overrides:
calcDist3D
in classDistanceCalcEarth
-
calcDenormalizedDist
public double calcDenormalizedDist(double normedDist) Description copied from interface:DistanceCalc
Inverse to calcNormalizedDist. Returned the length in meter.- Specified by:
calcDenormalizedDist
in interfaceDistanceCalc
- Overrides:
calcDenormalizedDist
in classDistanceCalcEarth
-
calcNormalizedDist
public double calcNormalizedDist(double dist) Description copied from class:DistanceCalcEarth
Returns the specified length in normalized meter.- Specified by:
calcNormalizedDist
in interfaceDistanceCalc
- Overrides:
calcNormalizedDist
in classDistanceCalcEarth
-
calcNormalizedDist
public double calcNormalizedDist(double fromLat, double fromLon, double toLat, double toLon) Description copied from interface:DistanceCalc
Calculates in normalized meter- Specified by:
calcNormalizedDist
in interfaceDistanceCalc
- Overrides:
calcNormalizedDist
in classDistanceCalcEarth
-
toString
- Overrides:
toString
in classDistanceCalcEarth
-