Package org.apache.lucene.expressions.js
Class ExpressionMath
java.lang.Object
org.apache.lucene.expressions.js.ExpressionMath
Helper class holding static methods for js math functions
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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).
-
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.
- 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.
-