pincode-distance-calculator

1.1.1 • Public • Published

PINCODE DISTANCE CALCULATOR

Thanks for visiting by mistake.

Installation

npm install pincode-distance-calculator

Usage

const Distance = require('pincode-distance-calculator')

let result = Distance.getDistance(110045,643231) 
//console logging result will return promise { <pending> }

result.then((distance) =>{
    console.log(distance) // will console log the distance
})

Theory

The Distance calculator takes two pincodes as arguments in the getDistance function. An API call is made to get the latlong data of both the pincodes.

The distance is calculated using the Haversine formula which is used to calculate distance between two co-ordintes on a sphere. more on Haversine Formula


Caveats

NOTE : The distance which is returned is not the distance by road, it is instead a distance between two points using a straight line.

image

The function will return the path2 distance in most cases.

This package is good to calculate a distance matrix for comparisons from a single origin. For example :

we have 3 origins and 1 destination, this package can be used to find the closest pincode to that destination.

Package Sidebar

Install

npm i pincode-distance-calculator

Weekly Downloads

3

Version

1.1.1

License

MIT

Unpacked Size

4.68 kB

Total Files

4

Last publish

Collaborators

  • deepakr28