@turf/destination
Advanced tools
Comparing version 5.0.4 to 5.1.0
@@ -1,2 +0,2 @@ | ||
import { Feature, Point, Units, Coord } from '@turf/helpers' | ||
import { Feature, Point, Units, Coord, Properties } from '@turf/helpers' | ||
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export default function destination( | ||
export default function destination<P = Properties>( | ||
origin: Coord, | ||
@@ -12,4 +12,5 @@ distance: number, | ||
options?: { | ||
units?: Units | ||
units?: Units, | ||
properties?: P | ||
} | ||
): Feature<Point>; | ||
): Feature<Point, P>; |
@@ -10,3 +10,3 @@ //http://en.wikipedia.org/wiki/Haversine_formula | ||
* @name destination | ||
* @param {Geometry|Feature<Point>|Array<number>} origin starting point | ||
* @param {Coord} origin starting point | ||
* @param {number} distance distance from the origin point | ||
@@ -16,2 +16,3 @@ * @param {number} bearing ranging from -180 to 180 | ||
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians | ||
* @param {Object} [options.properties={}] Translate properties to Point | ||
* @returns {Feature<Point>} destination point | ||
@@ -36,2 +37,3 @@ * @example | ||
var units = options.units; | ||
var properties = options.properties; | ||
@@ -50,6 +52,8 @@ // Handle input | ||
Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2)); | ||
var lng = radiansToDegrees(longitude2); | ||
var lat = radiansToDegrees(latitude2); | ||
return point([radiansToDegrees(longitude2), radiansToDegrees(latitude2)]); | ||
return point([lng, lat], properties); | ||
} | ||
export default destination; |
10
main.js
@@ -12,3 +12,3 @@ 'use strict'; | ||
* @name destination | ||
* @param {Geometry|Feature<Point>|Array<number>} origin starting point | ||
* @param {Coord} origin starting point | ||
* @param {number} distance distance from the origin point | ||
@@ -18,2 +18,3 @@ * @param {number} bearing ranging from -180 to 180 | ||
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians | ||
* @param {Object} [options.properties={}] Translate properties to Point | ||
* @returns {Feature<Point>} destination point | ||
@@ -36,4 +37,5 @@ * @example | ||
options = options || {}; | ||
if (!helpers.isObject(options)) throw new Error('options is invalid'); | ||
if (!helpers.isObject(options)) { throw new Error('options is invalid'); } | ||
var units = options.units; | ||
var properties = options.properties; | ||
@@ -52,4 +54,6 @@ // Handle input | ||
Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2)); | ||
var lng = helpers.radiansToDegrees(longitude2); | ||
var lat = helpers.radiansToDegrees(latitude2); | ||
return helpers.point([helpers.radiansToDegrees(longitude2), helpers.radiansToDegrees(latitude2)]); | ||
return helpers.point([lng, lat], properties); | ||
} | ||
@@ -56,0 +60,0 @@ |
{ | ||
"name": "@turf/destination", | ||
"version": "5.0.4", | ||
"version": "5.1.0", | ||
"description": "turf destination module", | ||
"main": "main", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"main": "main.js", | ||
"module": "main.mjs", | ||
"types": "index.d.ts", | ||
@@ -12,3 +11,4 @@ "files": [ | ||
"index.d.ts", | ||
"main.js" | ||
"main.js", | ||
"main.mjs" | ||
], | ||
@@ -18,3 +18,4 @@ "scripts": { | ||
"test": "node -r @std/esm test.js", | ||
"bench": "node -r @std/esm bench.js" | ||
"bench": "node -r @std/esm bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
}, | ||
@@ -41,3 +42,3 @@ "repository": { | ||
"@std/esm": "*", | ||
"@turf/truncate": "^5.0.4", | ||
"@turf/truncate": "^5.1.0", | ||
"benchmark": "*", | ||
@@ -47,2 +48,3 @@ "glob": "*", | ||
"rollup": "*", | ||
"rollup-plugin-buble": "*", | ||
"tape": "*", | ||
@@ -52,4 +54,4 @@ "write-json-file": "*" | ||
"dependencies": { | ||
"@turf/helpers": "^5.0.4", | ||
"@turf/invariant": "^5.0.4" | ||
"@turf/helpers": "^5.1.0", | ||
"@turf/invariant": "^5.1.0" | ||
}, | ||
@@ -56,0 +58,0 @@ "@std/esm": { |
@@ -7,7 +7,7 @@ # @turf/destination | ||
Takes a [Point](http://geojson.org/geojson-spec.html#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 [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. | ||
**Parameters** | ||
- `origin` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<[Point](http://geojson.org/geojson-spec.html#point)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** starting point | ||
- `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 | ||
@@ -17,2 +17,3 @@ - `bearing` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** ranging from -180 to 180 | ||
- `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 `{}`) | ||
@@ -35,3 +36,3 @@ **Examples** | ||
Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)<[Point](http://geojson.org/geojson-spec.html#point)>** destination point | ||
Returns **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<[Point](https://tools.ietf.org/html/rfc7946#section-3.1.2)>** destination point | ||
@@ -38,0 +39,0 @@ <!-- This file is automatically generated. Please don't edit it directly: |
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
12310
7
165
60
9
Updated@turf/helpers@^5.1.0
Updated@turf/invariant@^5.1.0