Skip to content

Get distance between two coordinates using haversine formula

Notifications You must be signed in to change notification settings

tiaanduplessis/get-haversine-distance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get-haversine-distance

package version package downloads standard-readme compliant package license make a pull request

Get distance between two coordinates using haversine formula

Table of Contents

Install

This project uses node and npm.

$ npm install get-haversine-distance
$ # OR
$ yarn add get-haversine-distance

Usage

const getHaversineDistance = require('get-haversine-distance')

const p1 = {
  lat: 11,
  lng: 12
}

const p2 = {
  lat: 13,
  lng: 14
}

const p3 = {
  x: 11,
  y: 12
}

const p4 = {
  x: 13,
  y: 14
}

console.log(getHaversineDistance(p1, p2)) // 311.08025949241477
console.log(getHaversineDistance(p1, p2, {inMiles: true})) // 193.29679215853378
console.log(getHaversineDistance(p3, p4, {latName: 'x', lngName: 'y'})) // 311.08025949241477

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am 'Add some feature'
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT

About

Get distance between two coordinates using haversine formula

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published