geo-distances
v1.0.6
Published
A geographical distance calculator. Calculates distance between two points using haversine formula.
Downloads
4
Maintainers
Readme
geo-distances
A geographical distance calculator. Calculates distance between two points in a defined range using haversine formula.
Installation
Install using npm:
$ npm install geo-distances
Example
To get the distance between two points in Kilometers (KM), define starting point and end point in data.json file. Range and Unit of distance can be set as per requirement.
let geoDistances = require('geo-distances'),
starting_point = { "latitude": "53.339428", "longitude": "-6.257664" },
range = '100',
unit = 'km',
filepath = __dirname+'/data.json';
//example data.json
data.json = [{ "latitude": "53.038056", "longitude": "-7.653889" }]
let distances = geoDistances(filepath, starting_point, range, unit);
console.log(distances);
Usage
geo-distances(start, end, [options])
The following types are accepted in the unit
option:
miles
ormi
yards
feet
kilometers
orkm
meters
Example:
starting_point = { "latitude": "57.319428", "longitude": "-2.2571864" },
filepath = __dirname+'/data.json', //remember to provide an array of Objects
unit = 'mi',
range = '10000';
let geoDistances = require('geo-distances')
let distances = geoDistances(filepath, starting_point, range, unit);
//example data.json
data.json = [{ "latitude": "50.9096375", "longitude": "-4.043701" }];