s-haversine
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "s-haversine", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">= 0.10.0" |
@@ -8,2 +8,4 @@ # s-haversine | ||
This is great for use with the html5 geolocation api, which provides lat/long coordinates. | ||
## Usage | ||
@@ -22,3 +24,5 @@ Get a pair of latitude/longitude coordinates (eg. from the geolocation api), then use them as the arguments for the `distance` method. Example: | ||
Use the `toDecimal` method if your input is in degrees/minutes/seconds format, such as `40 20 50W` or `40°20'50" S`. | ||
#### Converting deg/min/sec to decimal | ||
This module requires coordinates to be in a signed decimal format. If you have coordinates in degrees/minutes/seconds format, use the `toDecimal` method to convert them. For example, an input such as `40 20 50W` or `40°20'50" S` will return roughly `-40.34722`. | ||
```javascript | ||
@@ -28,2 +32,5 @@ haversine.toDecimal('40 20 50W'); // -40.34722... (degrees) | ||
#### Earth radius | ||
The math involved in the haversine formula depends on knowledge of the Earth's radius. This is configured by default as `6371000` (in meters). If you need to fine tune this or use another radius, you can configure this by setting `haversine.earthRadius` to a number before calling the distance method. | ||
## License | ||
@@ -30,0 +37,0 @@ Copyright (c) 2015, Sebastian Sandqvist <s.github@sparque.me> |
@@ -49,2 +49,10 @@ // ----- dependencies | ||
}); | ||
}); | ||
describe('earth radius', function() { | ||
it('should be configurable', function() { | ||
haversine.earthRadius = 1000000; | ||
expect(haversine.distance(40, 50, 40, 50)).to.equal(0); | ||
expect(haversine.distance(40, -70, -70, 40)).to.not.be.closeTo(14890000, 5000); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34908
98
38