haversine-js
Implementation of the haversine formula to calculate the great-circle distance between two points on a sphere given their longitudes and latitudes 🌎
Install
$ npm install --save haversine-js
Usage
const haversine = ; const atlanta = latitude: 337490 longitude: -843880; const london = latitude: 515074 longitude: -01278; const options = radius: haversineEARTHMILE; ;//=> 4207
API
haversine(start, end, [,options])
start, end
Type: object
Object containing the longitude/latitude coordinate pair for either point.
const start = longitude: 337490 latitude: 843880;
options
radius
Type: number
Default: haversine.EARTH.MILE
The radius of the sphere.
isRadians
Type: boolean
Default: false
Set to true if the longitude/latitude values are in radians.
Constants
Radii
Constant | Value |
---|---|
EARTH.MILE | 3959 |
EARTH.KM | 6371 |
EARTH.M | 6371000 |
EARTH.NMI | 3440 |
License
MIT © Brandon Smith