@turf/destination
Advanced tools
Comparing version 6.0.0 to 6.0.1
16
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//http://en.wikipedia.org/wiki/Haversine_formula | ||
//http://www.movable-type.co.uk/scripts/latlong.html | ||
// http://en.wikipedia.org/wiki/Haversine_formula | ||
// http://www.movable-type.co.uk/scripts/latlong.html | ||
var helpers_1 = require("@turf/helpers"); | ||
var invariant_1 = require("@turf/invariant"); | ||
var helpers_1 = require("@turf/helpers"); | ||
/** | ||
* Takes a {@link Point} and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature. | ||
* Takes a {@link Point} and calculates the location of a destination point given a distance in | ||
* degrees, radians, miles, or kilometers; and bearing in degrees. | ||
* This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature. | ||
* | ||
@@ -37,8 +39,8 @@ * @name destination | ||
var latitude1 = helpers_1.degreesToRadians(coordinates1[1]); | ||
var bearing_rad = helpers_1.degreesToRadians(bearing); | ||
var bearingRad = helpers_1.degreesToRadians(bearing); | ||
var radians = helpers_1.lengthToRadians(distance, options.units); | ||
// Main | ||
var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) + | ||
Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearing_rad)); | ||
var longitude2 = longitude1 + Math.atan2(Math.sin(bearing_rad) * Math.sin(radians) * Math.cos(latitude1), Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2)); | ||
Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearingRad)); | ||
var longitude2 = longitude1 + Math.atan2(Math.sin(bearingRad) * Math.sin(radians) * Math.cos(latitude1), Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2)); | ||
var lng = helpers_1.radiansToDegrees(longitude2); | ||
@@ -45,0 +47,0 @@ var lat = helpers_1.radiansToDegrees(latitude2); |
{ | ||
"name": "@turf/destination", | ||
"version": "6.0.0", | ||
"version": "6.0.1", | ||
"description": "turf destination module", | ||
"main": "index", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.ts" | ||
"index.d.ts" | ||
], | ||
@@ -42,3 +43,5 @@ "scripts": { | ||
"tape": "*", | ||
"write-json-file": "*" | ||
"write-json-file": "*", | ||
"tslint": "*", | ||
"@types/tape": "*" | ||
}, | ||
@@ -45,0 +48,0 @@ "dependencies": { |
@@ -7,12 +7,12 @@ # @turf/destination | ||
Takes a [Point](https://tools.ietf.org/html/rfc7946#section-3.1.2) and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature. | ||
Takes a [Point][1] and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the [Haversine formula][2] to account for global curvature. | ||
**Parameters** | ||
- `origin` **[Coord](https://tools.ietf.org/html/rfc7946#section-3.1.1)** starting point | ||
- `distance` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** distance from the origin point | ||
- `bearing` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** ranging from -180 to 180 | ||
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Optional parameters (optional, default `{}`) | ||
- `options.units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** miles, kilometers, degrees, or radians (optional, default `'kilometers'`) | ||
- `options.properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Translate properties to Point (optional, default `{}`) | ||
- `origin` **[Coord][3]** starting point | ||
- `distance` **[number][4]** distance from the origin point | ||
- `bearing` **[number][4]** ranging from -180 to 180 | ||
- `options` **[Object][5]** Optional parameters (optional, default `{}`) | ||
- `options.units` **[string][6]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`) | ||
- `options.properties` **[Object][5]** Translate properties to Point (optional, default `{}`) | ||
@@ -35,4 +35,20 @@ **Examples** | ||
Returns **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<[Point](https://tools.ietf.org/html/rfc7946#section-3.1.2)>** destination point | ||
Returns **[Feature][7]<[Point][8]>** destination point | ||
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 | ||
[2]: http://en.wikipedia.org/wiki/Haversine_formula | ||
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.1 | ||
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number | ||
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object | ||
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String | ||
[7]: https://tools.ietf.org/html/rfc7946#section-3.2 | ||
[8]: https://tools.ietf.org/html/rfc7946#section-3.1.2 | ||
<!-- This file is automatically generated. Please don't edit it directly: | ||
@@ -39,0 +55,0 @@ if you find an error, edit the source file (likely index.js), and re-run |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
76
0
8205
9
80