Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaxgeller/node-geo-distance
Nodejs wrapper for geo-distance using haversine and Vicenty formulas
https://github.com/jaxgeller/node-geo-distance
Last synced: 16 days ago
JSON representation
Nodejs wrapper for geo-distance using haversine and Vicenty formulas
- Host: GitHub
- URL: https://github.com/jaxgeller/node-geo-distance
- Owner: jaxgeller
- License: mit
- Created: 2014-09-02T21:00:19.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-03-24T18:13:51.000Z (almost 8 years ago)
- Last Synced: 2023-09-19T18:47:05.122Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
wrapper for http://jsperf.com/vincenty-vs-haversine-distance-calculations,
all credit for code to author of that link# Geo Distance formulas
[![Build Status](https://travis-ci.org/jaxgeller/node-geo-distance.svg)](https://travis-ci.org/jaxgeller/node-geo-distance)
+ Vincenty
+ Haversine### Install
`$ npm install node-geo-distance --save`### Use
```js
var geo = require('node-geo-distance');--> {latitude:x, longitude:x}, {latitude:x, longitude:x}, callback(dist)
geo.vincenty(coord1, coord2, callback)--> {latitude:x, longitude:x}, {latitude:x, longitude:x}
geo.vincentySync(coord1, coord2)--> {latitude:x, longitude:x}, {latitude:x, longitude:x}, callback(dist)
geo.haversine(coord1, coord2, callback)--> {latitude:x, longitude:x}, {latitude:x, longitude:x}
geo.haversineSync(coord1, coord2)
```### Examples
```js
var geo = require('node-geo-distance');// White house
var coord1 = {
latitude: 38.8977330,
longitude: -77.0365310
}// Washington Monument
var coord2 = {
latitude: 38.8894840,
longitude: -77.0352790
}geo.vincenty(coord1, coord2, function(dist) {
console.log(dist);
});var vincentyDist = geo.vincentySync(coord1, coord2);
geo.haversine(coord1, coord2, function(dist) {
console.log(dist);
});var haversineDist = geo.haversineSync(coord1, coord2);
```### License
MIT