@turf/bearing
Advanced tools
Comparing version 6.5.0 to 7.0.0-alpha.0
@@ -27,4 +27,3 @@ import { degreesToRadians, radiansToDegrees } from "@turf/helpers"; | ||
*/ | ||
export default function bearing(start, end, options) { | ||
if (options === void 0) { options = {}; } | ||
export default function bearing(start, end, options = {}) { | ||
// Reverse calculation | ||
@@ -34,10 +33,10 @@ if (options.final === true) { | ||
} | ||
var coordinates1 = getCoord(start); | ||
var coordinates2 = getCoord(end); | ||
var lon1 = degreesToRadians(coordinates1[0]); | ||
var lon2 = degreesToRadians(coordinates2[0]); | ||
var lat1 = degreesToRadians(coordinates1[1]); | ||
var lat2 = degreesToRadians(coordinates2[1]); | ||
var a = Math.sin(lon2 - lon1) * Math.cos(lat2); | ||
var b = Math.cos(lat1) * Math.sin(lat2) - | ||
const coordinates1 = getCoord(start); | ||
const coordinates2 = getCoord(end); | ||
const lon1 = degreesToRadians(coordinates1[0]); | ||
const lon2 = degreesToRadians(coordinates2[0]); | ||
const lat1 = degreesToRadians(coordinates1[1]); | ||
const lat2 = degreesToRadians(coordinates2[1]); | ||
const a = Math.sin(lon2 - lon1) * Math.cos(lat2); | ||
const b = Math.cos(lat1) * Math.sin(lat2) - | ||
Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1); | ||
@@ -56,5 +55,5 @@ return radiansToDegrees(Math.atan2(a, b)); | ||
// Swap start & end | ||
var bear = bearing(end, start); | ||
let bear = bearing(end, start); | ||
bear = (bear + 180) % 360; | ||
return bear; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var helpers_1 = require("@turf/helpers"); | ||
var invariant_1 = require("@turf/invariant"); | ||
const helpers_1 = require("@turf/helpers"); | ||
const invariant_1 = require("@turf/invariant"); | ||
// http://en.wikipedia.org/wiki/Haversine_formula | ||
@@ -29,4 +29,3 @@ // http://www.movable-type.co.uk/scripts/latlong.html | ||
*/ | ||
function bearing(start, end, options) { | ||
if (options === void 0) { options = {}; } | ||
function bearing(start, end, options = {}) { | ||
// Reverse calculation | ||
@@ -36,10 +35,10 @@ if (options.final === true) { | ||
} | ||
var coordinates1 = invariant_1.getCoord(start); | ||
var coordinates2 = invariant_1.getCoord(end); | ||
var lon1 = helpers_1.degreesToRadians(coordinates1[0]); | ||
var lon2 = helpers_1.degreesToRadians(coordinates2[0]); | ||
var lat1 = helpers_1.degreesToRadians(coordinates1[1]); | ||
var lat2 = helpers_1.degreesToRadians(coordinates2[1]); | ||
var a = Math.sin(lon2 - lon1) * Math.cos(lat2); | ||
var b = Math.cos(lat1) * Math.sin(lat2) - | ||
const coordinates1 = invariant_1.getCoord(start); | ||
const coordinates2 = invariant_1.getCoord(end); | ||
const lon1 = helpers_1.degreesToRadians(coordinates1[0]); | ||
const lon2 = helpers_1.degreesToRadians(coordinates2[0]); | ||
const lat1 = helpers_1.degreesToRadians(coordinates1[1]); | ||
const lat2 = helpers_1.degreesToRadians(coordinates2[1]); | ||
const a = Math.sin(lon2 - lon1) * Math.cos(lat2); | ||
const b = Math.cos(lat1) * Math.sin(lat2) - | ||
Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1); | ||
@@ -59,5 +58,5 @@ return helpers_1.radiansToDegrees(Math.atan2(a, b)); | ||
// Swap start & end | ||
var bear = bearing(end, start); | ||
let bear = bearing(end, start); | ||
bear = (bear + 180) % 360; | ||
return bear; | ||
} |
{ | ||
"name": "@turf/bearing", | ||
"version": "6.5.0", | ||
"version": "7.0.0-alpha.0", | ||
"description": "turf bearing module", | ||
@@ -47,3 +47,3 @@ "author": "Turf Authors", | ||
"devDependencies": { | ||
"@turf/destination": "^6.5.0", | ||
"@turf/destination": "^7.0.0-alpha.0", | ||
"@types/tape": "*", | ||
@@ -59,6 +59,7 @@ "benchmark": "*", | ||
"dependencies": { | ||
"@turf/helpers": "^6.5.0", | ||
"@turf/invariant": "^6.5.0" | ||
"@turf/helpers": "^7.0.0-alpha.0", | ||
"@turf/invariant": "^7.0.0-alpha.0", | ||
"tslib": "^2.3.0" | ||
}, | ||
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e" | ||
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189" | ||
} |
@@ -10,11 +10,12 @@ # @turf/bearing | ||
**Parameters** | ||
### Parameters | ||
- `start` **[Coord][2]** starting Point | ||
- `end` **[Coord][2]** ending Point | ||
- `options` **[Object][3]** Optional parameters (optional, default `{}`) | ||
- `options.final` **[boolean][4]** calculates the final bearing if true (optional, default `false`) | ||
* `start` **[Coord][2]** starting Point | ||
* `end` **[Coord][2]** ending Point | ||
* `options` **[Object][3]** Optional parameters (optional, default `{}`) | ||
**Examples** | ||
* `options.final` **[boolean][4]** calculates the final bearing if true (optional, default `false`) | ||
### Examples | ||
```javascript | ||
@@ -21,0 +22,0 @@ var point1 = turf.point([-75.343, 39.984]); |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
9855
69
3
141
1
+ Addedtslib@^2.3.0
+ Added@turf/helpers@7.1.0(transitive)
+ Added@turf/invariant@7.1.0(transitive)
+ Added@types/geojson@7946.0.14(transitive)
+ Addedtslib@2.8.1(transitive)
- Removed@turf/helpers@6.5.0(transitive)
- Removed@turf/invariant@6.5.0(transitive)
Updated@turf/helpers@^7.0.0-alpha.0