@turf/rhumb-bearing 6.5.0 → 7.0.0-alpha.1

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
@@ -7,14 +7,15 @@
7
7
  Takes two [points][1] and finds the bearing angle between them along a Rhumb line
8
8
  i.e. the angle measured in degrees start the north line (0 degrees)
9
9
 
10
- **Parameters**
10
+ ### Parameters
11
11
 
12
- - `start` **[Coord][2]** starting Point
13
- - `end` **[Coord][2]** ending Point
14
- - `options` **[Object][3]?** Optional parameters
15
- - `options.final` **[boolean][4]** calculates the final bearing if true (optional, default `false`)
12
+ * `start` **[Coord][2]** starting Point
13
+ * `end` **[Coord][2]** ending Point
14
+ * `options` **[Object][3]?** Optional parameters
16
15
 
17
- **Examples**
16
+ * `options.final` **[boolean][4]** calculates the final bearing if true (optional, default `false`)
17
+
18
+ ### Examples
18
19
 
19
20
  ```javascript
20
21
  var point1 = turf.point([-75.343, 39.984], {"marker-color": "#F00"});
package/dist/es/index.js CHANGED
@@ -22,16 +22,15 @@ import { getCoord } from "@turf/invariant";
22
22
  * point1.properties.bearing = bearing;
23
23
  * point2.properties.bearing = bearing;
24
24
  */
25
- function rhumbBearing(start, end, options) {
26
- if (options === void 0) { options = {}; }
27
- var bear360;
25
+ function rhumbBearing(start, end, options = {}) {
26
+ let bear360;
28
27
  if (options.final) {
29
28
  bear360 = calculateRhumbBearing(getCoord(end), getCoord(start));
30
29
  }
31
30
  else {
32
31
  bear360 = calculateRhumbBearing(getCoord(start), getCoord(end));
33
32
  }
34
- var bear180 = bear360 > 180 ? -(360 - bear360) : bear360;
33
+ const bear180 = bear360 > 180 ? -(360 - bear360) : bear360;
35
34
  return bear180;
36
35
  }
37
36
  /**
@@ -52,9 +51,9 @@ function calculateRhumbBearing(from, to) {
52
51
  // Δλ => deltaLambda
53
52
  // Δψ => deltaPsi
54
53
  // θ => theta
55
- var phi1 = degreesToRadians(from[1]);
56
- var phi2 = degreesToRadians(to[1]);
57
- var deltaLambda = degreesToRadians(to[0] - from[0]);
54
+ const phi1 = degreesToRadians(from[1]);
55
+ const phi2 = degreesToRadians(to[1]);
56
+ let deltaLambda = degreesToRadians(to[0] - from[0]);
58
57
  // if deltaLambdaon over 180° take shorter rhumb line across the anti-meridian:
59
58
  if (deltaLambda > Math.PI) {
60
59
  deltaLambda -= 2 * Math.PI;
@@ -62,8 +61,8 @@ function calculateRhumbBearing(from, to) {
62
61
  if (deltaLambda < -Math.PI) {
63
62
  deltaLambda += 2 * Math.PI;
64
63
  }
65
- var deltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
66
- var theta = Math.atan2(deltaLambda, deltaPsi);
64
+ const deltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
65
+ const theta = Math.atan2(deltaLambda, deltaPsi);
67
66
  return (radiansToDegrees(theta) + 360) % 360;
68
67
  }
69
68
  export default rhumbBearing;
File without changes
package/dist/js/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // https://en.wikipedia.org/wiki/Rhumb_line
4
- var helpers_1 = require("@turf/helpers");
5
- var invariant_1 = require("@turf/invariant");
4
+ const helpers_1 = require("@turf/helpers");
5
+ const invariant_1 = require("@turf/invariant");
6
6
  /**
7
7
  * Takes two {@link Point|points} and finds the bearing angle between them along a Rhumb line
8
8
  * i.e. the angle measured in degrees start the north line (0 degrees)
@@ -24,16 +24,15 @@ var invariant_1 = require("@turf/invariant");
24
24
  * point1.properties.bearing = bearing;
25
25
  * point2.properties.bearing = bearing;
26
26
  */
27
- function rhumbBearing(start, end, options) {
28
- if (options === void 0) { options = {}; }
29
- var bear360;
27
+ function rhumbBearing(start, end, options = {}) {
28
+ let bear360;
30
29
  if (options.final) {
31
30
  bear360 = calculateRhumbBearing(invariant_1.getCoord(end), invariant_1.getCoord(start));
32
31
  }
33
32
  else {
34
33
  bear360 = calculateRhumbBearing(invariant_1.getCoord(start), invariant_1.getCoord(end));
35
34
  }
36
- var bear180 = bear360 > 180 ? -(360 - bear360) : bear360;
35
+ const bear180 = bear360 > 180 ? -(360 - bear360) : bear360;
37
36
  return bear180;
38
37
  }
39
38
  /**
@@ -54,9 +53,9 @@ function calculateRhumbBearing(from, to) {
54
53
  // Δλ => deltaLambda
55
54
  // Δψ => deltaPsi
56
55
  // θ => theta
57
- var phi1 = helpers_1.degreesToRadians(from[1]);
58
- var phi2 = helpers_1.degreesToRadians(to[1]);
59
- var deltaLambda = helpers_1.degreesToRadians(to[0] - from[0]);
56
+ const phi1 = helpers_1.degreesToRadians(from[1]);
57
+ const phi2 = helpers_1.degreesToRadians(to[1]);
58
+ let deltaLambda = helpers_1.degreesToRadians(to[0] - from[0]);
60
59
  // if deltaLambdaon over 180° take shorter rhumb line across the anti-meridian:
61
60
  if (deltaLambda > Math.PI) {
62
61
  deltaLambda -= 2 * Math.PI;
@@ -64,8 +63,8 @@ function calculateRhumbBearing(from, to) {
64
63
  if (deltaLambda < -Math.PI) {
65
64
  deltaLambda += 2 * Math.PI;
66
65
  }
67
- var deltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
68
- var theta = Math.atan2(deltaLambda, deltaPsi);
66
+ const deltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
67
+ const theta = Math.atan2(deltaLambda, deltaPsi);
69
68
  return (helpers_1.radiansToDegrees(theta) + 360) % 360;
70
69
  }
71
70
  exports.default = rhumbBearing;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/rhumb-bearing",
3
- "version": "6.5.0",
3
+ "version": "7.0.0-alpha.1",
4
4
  "description": "turf rhumb-bearing module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -33,6 +33,7 @@
33
33
  "exports": {
34
34
  "./package.json": "./package.json",
35
35
  ".": {
36
+ "types": "./dist/js/index.d.ts",
36
37
  "import": "./dist/es/index.js",
37
38
  "require": "./dist/js/index.js"
38
39
  }
@@ -43,28 +44,29 @@
43
44
  "dist"
44
45
  ],
45
46
  "scripts": {
46
- "bench": "ts-node bench.js",
47
+ "bench": "tsx bench.js",
47
48
  "build": "npm-run-all build:*",
48
49
  "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
49
50
  "build:js": "tsc",
50
- "docs": "node ../../scripts/generate-readmes",
51
+ "docs": "tsx ../../scripts/generate-readmes",
51
52
  "test": "npm-run-all test:*",
52
- "test:tape": "ts-node -r esm test.js"
53
+ "test:tape": "tsx test.js"
53
54
  },
54
55
  "devDependencies": {
55
- "@turf/destination": "^6.5.0",
56
+ "@turf/destination": "^7.0.0-alpha.1",
56
57
  "@types/tape": "*",
57
58
  "benchmark": "*",
58
59
  "npm-run-all": "*",
59
60
  "tape": "*",
60
- "ts-node": "*",
61
61
  "tslint": "*",
62
+ "tsx": "*",
62
63
  "typescript": "*",
63
64
  "write-json-file": "*"
64
65
  },
65
66
  "dependencies": {
66
- "@turf/helpers": "^6.5.0",
67
- "@turf/invariant": "^6.5.0"
67
+ "@turf/helpers": "^7.0.0-alpha.1",
68
+ "@turf/invariant": "^7.0.0-alpha.1",
69
+ "tslib": "^2.3.0"
68
70
  },
69
- "gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
71
+ "gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
70
72
  }