Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TankofVines/node-vincenty
Repacked some vanilla JS that calculates metric distance between two latitude and longitude coordinates
https://github.com/TankofVines/node-vincenty
Last synced: 4 months ago
JSON representation
Repacked some vanilla JS that calculates metric distance between two latitude and longitude coordinates
- Host: GitHub
- URL: https://github.com/TankofVines/node-vincenty
- Owner: TankofVines
- Created: 2013-01-24T20:44:36.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-03-31T20:42:11.000Z (over 9 years ago)
- Last Synced: 2024-08-14T04:28:25.780Z (4 months ago)
- Language: JavaScript
- Size: 160 KB
- Stars: 22
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
node-vincenty
=============Repackaged some vanilla js that calculates metric distance between two latitude and longitude coordinates based on Chris Veness' script here:
http://www.movable-type.co.uk/scripts/latlong-vincenty.html
http://www.movable-type.co.uk/scripts/latlong-vincenty-direct.htmlThe module exports two functions:
distVincenty(lat1, long1, lat2, long2, callback) which accepts four parameters representing the latitude and longitude of the input coordinates.
destVincenty(lat1, lon1, brng, dist) which calculates the destination point given the starting latitude and longitude with a given bearing and distanceInstall:
npm install node-vincenty
Usage:
var vincenty = require('node-vincenty');
Examples:
// these are synchronous
console.log( vincenty.distVincenty(30.5, -100.6, 31.7, -101.8) );
console.log( vincenty.destVincenty(30.5, -100.6, 175518.816, -40.4035) );// these are asynchronous
vincenty.distVincenty(30.5, -100.6, 31.7, -101.8, function (distance) {
console.log(distance);
});vincenty.distVincenty(30.5, -100.6, 31.7, -101.8, function (distance, initialBearing, finalBearing) {
console.log(distance, initialBearing, finalBearing);
});vincenty.destVincenty(30.5, -100.6, 175518.816, -40.4035, function (lat, lon, finalBearing) {
console.log(lat, lon, finalBearing);
});Outputs:
{ distance: '175518.816',
initialBearing: -40.40353176919702,
finalBearing: -41.02342255854039 }
{ lat: 30.50034497548687,
lon: -100.59986425485471,
finalBearing: -161.1839311037904 }
175518.816
175518.816 -40.40353176919702 -41.02342255854039
30.50034497548687 -100.59986425485471 -161.1839311037904