Comparing version 1.1.1 to 1.1.2
@@ -103,8 +103,11 @@ 'use strict'; | ||
static calculateBearing(point1, point2) { | ||
const dLongitude = point2.longitude - point1.longitude; | ||
const y = (cos(point1.latitude) * sin(point2.latitude)) - (sin(point1.latitude) * cos(point2.latitude) * cos(dLongitude)); | ||
const x = sin(dLongitude) * cos(point2.latitude); | ||
const bearing = deg2rad(atan2(x, y)); | ||
const φ1 = deg2rad(point1.latitude), φ2 = deg2rad(point2.latitude); | ||
const Δλ = deg2rad(point2.longitude - point1.longitude); | ||
return 360 - (bearing + 360) % 360; | ||
// see http://mathforum.org/library/drmath/view/55417.html | ||
const y = sin(Δλ) * cos(φ2); | ||
const x = cos(φ1) * sin(φ2) - sin(φ1) * cos(φ2) * cos(Δλ); | ||
const θ = atan2(y, x); | ||
return (rad2deg(θ) + 360) % 360; | ||
} | ||
@@ -111,0 +114,0 @@ |
{ | ||
"name": "geo-point", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "geo point", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -65,3 +65,3 @@ 'use strict'; | ||
new GeoPoint(51.5, 1.15) | ||
)).should.equals(360); | ||
)).should.equals(89); | ||
@@ -71,3 +71,8 @@ GeoPoint.calculateBearing( | ||
new GeoPoint(52, 0) | ||
).should.equals(360); | ||
).should.equals(0); | ||
Math.round(GeoPoint.calculateBearing( | ||
new GeoPoint(-6.231624, 106.802569), | ||
new GeoPoint(-6.22063, 106.61694) | ||
)).should.equals(273); | ||
}); | ||
@@ -74,0 +79,0 @@ |
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
13734
275