@turf/destination 6.5.0 → 7.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,18 +4,21 @@
4
4
 
5
5
  ## destination
6
6
 
7
- 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.
7
+ Takes a [Point][1] and calculates the location of a destination point given a distance in
8
+ degrees, radians, miles, or kilometers; and bearing in degrees.
9
+ This uses the [Haversine formula][2] to account for global curvature.
8
10
 
9
- **Parameters**
11
+ ### Parameters
10
12
 
11
- - `origin` **[Coord][3]** starting point
12
- - `distance` **[number][4]** distance from the origin point
13
- - `bearing` **[number][4]** ranging from -180 to 180
14
- - `options` **[Object][5]** Optional parameters (optional, default `{}`)
15
- - `options.units` **[string][6]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
16
- - `options.properties` **[Object][5]** Translate properties to Point (optional, default `{}`)
13
+ * `origin` **[Coord][3]** starting point
14
+ * `distance` **[number][4]** distance from the origin point
15
+ * `bearing` **[number][4]** ranging from -180 to 180
16
+ * `options` **[Object][5]** Optional parameters (optional, default `{}`)
17
17
 
18
- **Examples**
18
+ * `options.units` **[string][6]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
19
+ * `options.properties` **[Object][5]** Translate properties to Point (optional, default `{}`)
20
+
21
+ ### Examples
19
22
 
20
23
  ```javascript
21
24
  var point = turf.point([-75.343, 39.984]);
@@ -31,7 +34,7 @@ destination.properties['marker-color'] = '#f00';
31
34
  point.properties['marker-color'] = '#0f0';
32
35
  ```
33
36
 
34
- Returns **[Feature][7]<[Point][8]>** destination point
37
+ Returns **[Feature][7]<[Point][8]>** destination point
35
38
 
36
39
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
37
40
 
package/dist/es/index.js CHANGED
@@ -1,5 +1,3 @@
1
- // http://en.wikipedia.org/wiki/Haversine_formula
2
- // http://www.movable-type.co.uk/scripts/latlong.html
3
1
  import { degreesToRadians, lengthToRadians, point, radiansToDegrees, } from "@turf/helpers";
4
2
  import { getCoord } from "@turf/invariant";
5
3
  /**
@@ -28,20 +26,19 @@ import { getCoord } from "@turf/invariant";
28
26
  * destination.properties['marker-color'] = '#f00';
29
27
  * point.properties['marker-color'] = '#0f0';
30
28
  */
31
- export default function destination(origin, distance, bearing, options) {
32
- if (options === void 0) { options = {}; }
29
+ export default function destination(origin, distance, bearing, options = {}) {
33
30
  // Handle input
34
- var coordinates1 = getCoord(origin);
35
- var longitude1 = degreesToRadians(coordinates1[0]);
36
- var latitude1 = degreesToRadians(coordinates1[1]);
37
- var bearingRad = degreesToRadians(bearing);
38
- var radians = lengthToRadians(distance, options.units);
31
+ const coordinates1 = getCoord(origin);
32
+ const longitude1 = degreesToRadians(coordinates1[0]);
33
+ const latitude1 = degreesToRadians(coordinates1[1]);
34
+ const bearingRad = degreesToRadians(bearing);
35
+ const radians = lengthToRadians(distance, options.units);
39
36
  // Main
40
- var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
37
+ const latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
41
38
  Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearingRad));
42
- var longitude2 = longitude1 +
39
+ const longitude2 = longitude1 +
43
40
  Math.atan2(Math.sin(bearingRad) * Math.sin(radians) * Math.cos(latitude1), Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
44
- var lng = radiansToDegrees(longitude2);
45
- var lat = radiansToDegrees(latitude2);
41
+ const lng = radiansToDegrees(longitude2);
42
+ const lat = radiansToDegrees(latitude2);
46
43
  return point([lng, lat], options.properties);
47
44
  }
@@ -1,4 +1,5 @@
1
- import { Coord, Feature, Point, Properties, Units } from "@turf/helpers";
1
+ import { Feature, Point, GeoJsonProperties } from "geojson";
2
+ import { Coord, Units } from "@turf/helpers";
2
3
  /**
3
4
  * Takes a {@link Point} and calculates the location of a destination point given a distance in
4
5
  * degrees, radians, miles, or kilometers; and bearing in degrees.
@@ -25,7 +26,7 @@ import { Coord, Feature, Point, Properties, Units } from "@turf/helpers";
25
26
  * destination.properties['marker-color'] = '#f00';
26
27
  * point.properties['marker-color'] = '#0f0';
27
28
  */
28
- export default function destination<P = Properties>(origin: Coord, distance: number, bearing: number, options?: {
29
+ export default function destination<P = GeoJsonProperties>(origin: Coord, distance: number, bearing: number, options?: {
29
30
  units?: Units;
30
31
  properties?: P;
31
32
  }): Feature<Point, P>;
package/dist/js/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // http://en.wikipedia.org/wiki/Haversine_formula
4
- // http://www.movable-type.co.uk/scripts/latlong.html
5
- var helpers_1 = require("@turf/helpers");
6
- var invariant_1 = require("@turf/invariant");
3
+ const helpers_1 = require("@turf/helpers");
4
+ const invariant_1 = require("@turf/invariant");
7
5
  /**
8
6
  * Takes a {@link Point} and calculates the location of a destination point given a distance in
9
7
  * degrees, radians, miles, or kilometers; and bearing in degrees.
@@ -30,21 +28,20 @@ var invariant_1 = require("@turf/invariant");
30
28
  * destination.properties['marker-color'] = '#f00';
31
29
  * point.properties['marker-color'] = '#0f0';
32
30
  */
33
- function destination(origin, distance, bearing, options) {
34
- if (options === void 0) { options = {}; }
31
+ function destination(origin, distance, bearing, options = {}) {
35
32
  // Handle input
36
- var coordinates1 = invariant_1.getCoord(origin);
37
- var longitude1 = helpers_1.degreesToRadians(coordinates1[0]);
38
- var latitude1 = helpers_1.degreesToRadians(coordinates1[1]);
39
- var bearingRad = helpers_1.degreesToRadians(bearing);
40
- var radians = helpers_1.lengthToRadians(distance, options.units);
33
+ const coordinates1 = invariant_1.getCoord(origin);
34
+ const longitude1 = helpers_1.degreesToRadians(coordinates1[0]);
35
+ const latitude1 = helpers_1.degreesToRadians(coordinates1[1]);
36
+ const bearingRad = helpers_1.degreesToRadians(bearing);
37
+ const radians = helpers_1.lengthToRadians(distance, options.units);
41
38
  // Main
42
- var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
39
+ const latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
43
40
  Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearingRad));
44
- var longitude2 = longitude1 +
41
+ const longitude2 = longitude1 +
45
42
  Math.atan2(Math.sin(bearingRad) * Math.sin(radians) * Math.cos(latitude1), Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
46
- var lng = helpers_1.radiansToDegrees(longitude2);
47
- var lat = helpers_1.radiansToDegrees(latitude2);
43
+ const lng = helpers_1.radiansToDegrees(longitude2);
44
+ const lat = helpers_1.radiansToDegrees(latitude2);
48
45
  return helpers_1.point([lng, lat], options.properties);
49
46
  }
50
47
  exports.default = destination;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/destination",
3
- "version": "6.5.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf destination module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  "test:tape": "ts-node -r esm test.js"
49
49
  },
50
50
  "devDependencies": {
51
- "@turf/truncate": "^6.5.0",
51
+ "@turf/truncate": "^7.0.0-alpha.0",
52
52
  "@types/tape": "*",
53
53
  "benchmark": "*",
54
54
  "glob": "*",
@@ -61,8 +61,9 @@
61
61
  "write-json-file": "*"
62
62
  },
63
63
  "dependencies": {
64
- "@turf/helpers": "^6.5.0",
65
- "@turf/invariant": "^6.5.0"
64
+ "@turf/helpers": "^7.0.0-alpha.0",
65
+ "@turf/invariant": "^7.0.0-alpha.0",
66
+ "tslib": "^2.3.0"
66
67
  },
67
- "gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
68
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
68
69
  }