Package org.apache.lucene.expressions.js
Class ExpressionMath
- java.lang.Object
-
- org.apache.lucene.expressions.js.ExpressionMath
-
public final class ExpressionMath extends java.lang.Object
Helper class holding static methods for js math functions
-
-
Field Summary
Fields Modifier and Type Field Description private static double
TO_KILOMETERS
-
Constructor Summary
Constructors Modifier Constructor Description private
ExpressionMath()
-
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).
-
-
-
Field Detail
-
TO_KILOMETERS
private static final double TO_KILOMETERS
- See Also:
- Constant Field Values
-
-
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.
-
-