Haversine formula implementation in Java to calculate the great-circle distance between two pairs of latitude and longitude coordinates.
Features
The HaversineAlgorithm.java
class have tow implemented methods and both return the great-circle distance between tow points, using the Haversine formula.
- The
distanceInKm(...)
method return their result in the Kilometers (Km) unit type. - The
distanceInMi(...)
method return their result in the Miles (Mi) unit type, through a simple conversion of Km to Mi.
Unit test
To ensure accurate results from the Haversine formula implementation, the HaversineAlgorithm.java
class are fully reviewed by unit tests, that can be found in class HaversineAlgorithmTest.java
.
License
Copyright 2017, Juliano Macedo. See LICENSE file for details.