Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

s-haversine

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

s-haversine - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc