Package org.apache.lucene.expressions.js

## Class ExpressionMath

- java.lang.Object
- - org.apache.lucene.expressions.js.ExpressionMath

-     public final class ExpressionMath
      extends Object

  Helper class holding static methods for js math functions

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `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).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### 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.

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