Coder Social home page Coder Social logo

haversine-js's Introduction

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

haversine-js's People

Contributors

brandon93s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.