Skip to content

Latest commit

 

History

History
87 lines (53 loc) · 1.53 KB

readme.md

File metadata and controls

87 lines (53 loc) · 1.53 KB

haversine-js Build Status

Implementation of the haversine formula to calculate the great-circle distance between two points on a sphere given their longitudes and latitudes 🌎

Install

$ npm install --save haversine-js

Usage

const haversine = require('haversine-js');

const atlanta = {
  latitude: 33.7490,
  longitude: -84.3880
};

const london = {
  latitude: 51.5074,
  longitude: -0.1278
};

const options = {
    radius: haversine.EARTH.MILE
};

haversine(atlanta, london, options).toFixed(0);
//=> 4207

API

haversine(start, end, [,options])

start, end

Type: object

Object containing the longitude/latitude coordinate pair for either point.

const start = {
    longitude: 33.7490,
    latitude: 84.3880
};

options

radius

Type: number
Default: haversine.EARTH.MILE

The radius of the sphere.

isRadians

Type: boolean
Default: false

Set to true if the longitude/latitude values are in radians.

Constants

Radii

Constant Value
EARTH.MILE 3959
EARTH.KM 6371
EARTH.M 6371000
EARTH.NMI 3440

License

MIT © Brandon Smith

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy