All Projects → dcousens → haversine-distance

dcousens / haversine-distance

Licence: MIT license
Haversine formula in Javascript. In meters. Nothing more.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to haversine-distance

geo
Geospatial primitives and algorithms for Crystal
Stars: ✭ 17 (-51.43%)
Mutual labels:  haversine
geodist
Golang package to compute the distance between two geographic latitude, longitude coordinates
Stars: ✭ 133 (+280%)
Mutual labels:  haversine
haversine-geolocation
Get distances between two points or get closest position to current point. Based on the Haversine Formula
Stars: ✭ 20 (-42.86%)
Mutual labels:  haversine

haversine-distance

build status Version

js-standard-style

Haversine formula in Javascript. In meters. Nothing more.

Example

Import

const haversine = require('haversine-distance')
// or
import haversine from 'haversine-distance'

Usage

const a = { latitude: 37.8136, longitude: 144.9631 }
const b = { latitude: 33.8650, longitude: 151.2094 }

console.log(haversine(a, b)) // 714504.18 (in meters)

Alternative forms such as lat, lng and lon work too, with mixed support:

const a = { lat: 37.8136, lng: 144.9631 }
const b = { lat: 33.8650, lon: 151.2094 }

console.log(haversine(a, b)) // 714504.18 (in meters)

GeoJSON support

const a = [144.9631, 37.8136]
const b = [151.2094, 33.865]

console.log(haversine(a, b)) // 714504.18 (in meters)

License MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].