Skip to content

🚗 Small Library for calculating distances between points.

Notifications You must be signed in to change notification settings

jcblw/distance.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distance.js Build Status

Greenkeeper badge

A Small Utility to calulate distance from a latitude and longitude points.

Warning Javascript in general is not the greatest at math when dealing with large numbers... You have been warned

Distance().from([lat, lng]).to([lat, lng]).unit('miles')
// returns kilometers by default
var home = Distance().from([lat, lng]);
var nearby = [];
var locations = [/*...*/];
for(var i = 0; i < locations.length; i += 1){
  var location = locations[i];
  // use the same instance over and over
  if(home.to(location.center).unit('miles') < 3){
    nearby.push(location)
  }  
}
Available length units
  • kilometers
  • miles
  • feet

Unit conversion is handled in the prototype of Number and is subject to change

more methods to be added

Development

All new features for distance.js must be accompanied by a test to prove feature works. Bug fixes do not need new test but it is recommended.

Install packages

Install Grunt

npm install
Grunt methods
grunt build
grunt test

About

🚗 Small Library for calculating distances between points.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published