Class ExpressionMath


public final class ExpressionMath extends Object
Helper class holding static methods for js math functions
  • Method Details

    • haversinKilometers

      public static double haversinKilometers(double lat1, double lon1, double lat2, double lon2)
      Returns the Haversine distance in kilometers between two points specified in decimal degrees (latitude/longitude). This works correctly even if the dateline is between the two points.

      Error is at most 4E-1 (40cm) from the actual haversine distance, but is typically much smaller for reasonable distances: around 1E-5 (0.01mm) for distances less than 1000km.

      lat1 - Latitude of the first point.
      lon1 - Longitude of the first point.
      lat2 - Latitude of the second point.
      lon2 - Longitude of the second point.
      distance in kilometers.