Class DistancePlaneProjection

java.lang.Object
com.graphhopper.util.DistanceCalcEarth
com.graphhopper.util.DistancePlaneProjection
All Implemented Interfaces:
DistanceCalc

public class DistancePlaneProjection extends DistanceCalcEarth
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 Details

  • 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 interface DistanceCalc
      Overrides:
      calcDist in class DistanceCalcEarth
    • 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 interface DistanceCalc
      Overrides:
      calcDist3D in class DistanceCalcEarth
    • calcDenormalizedDist

      public double calcDenormalizedDist(double normedDist)
      Description copied from interface: DistanceCalc
      Inverse to calcNormalizedDist. Returned the length in meter.
      Specified by:
      calcDenormalizedDist in interface DistanceCalc
      Overrides:
      calcDenormalizedDist in class DistanceCalcEarth
    • calcNormalizedDist

      public double calcNormalizedDist(double dist)
      Description copied from class: DistanceCalcEarth
      Returns the specified length in normalized meter.
      Specified by:
      calcNormalizedDist in interface DistanceCalc
      Overrides:
      calcNormalizedDist in class DistanceCalcEarth
    • 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 interface DistanceCalc
      Overrides:
      calcNormalizedDist in class DistanceCalcEarth
    • toString

      public String toString()
      Overrides:
      toString in class DistanceCalcEarth