JSPM

node-geo-distance

1.2.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 3002
    • Score
      100M100P100Q119601F
    • License MIT

    A wrapper for haversine and vincenty distance formulas

    Package Exports

    • node-geo-distance

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-geo-distance) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    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

    • Vincenty
    • Haversine

    Install

    $ npm install node-geo-distance --save

    Use

    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

    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);