@turf/angle 7.0.0-alpha.2 → 7.0.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
@@ -34,26 +34,21 @@ Returns **[number][4]** Angle between the provided points, or its explementary.
34
34
 
35
35
  [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
36
36
 
37
- <!-- This file is automatically generated. Please don't edit it directly:
38
- if you find an error, edit the source file (likely index.js), and re-run
39
- ./scripts/generate-readmes in the turf project. -->
37
+ <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
40
38
 
41
39
  ---
42
40
 
43
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
44
- module collection dedicated to geographic algorithms. It is maintained in the
45
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
46
- PRs and issues.
41
+ This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
47
42
 
48
43
  ### Installation
49
44
 
50
- Install this module individually:
45
+ Install this single module individually:
51
46
 
52
47
  ```sh
53
48
  $ npm install @turf/angle
54
49
  ```
55
50
 
56
- Or install the Turf module that includes it as a function:
51
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
57
52
 
58
53
  ```sh
59
54
  $ npm install @turf/turf
@@ -0,0 +1,42 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.ts
5
+ var _bearing = require('@turf/bearing');
6
+ var _helpers = require('@turf/helpers');
7
+ var _rhumbbearing = require('@turf/rhumb-bearing');
8
+ function angle(startPoint, midPoint, endPoint, options = {}) {
9
+ if (!_helpers.isObject.call(void 0, options)) {
10
+ throw new Error("options is invalid");
11
+ }
12
+ if (!startPoint) {
13
+ throw new Error("startPoint is required");
14
+ }
15
+ if (!midPoint) {
16
+ throw new Error("midPoint is required");
17
+ }
18
+ if (!endPoint) {
19
+ throw new Error("endPoint is required");
20
+ }
21
+ const A = startPoint;
22
+ const O = midPoint;
23
+ const B = endPoint;
24
+ const azimuthAO = _helpers.bearingToAzimuth.call(void 0,
25
+ options.mercator !== true ? _bearing.bearing.call(void 0, A, O) : _rhumbbearing.rhumbBearing.call(void 0, A, O)
26
+ );
27
+ const azimuthBO = _helpers.bearingToAzimuth.call(void 0,
28
+ options.mercator !== true ? _bearing.bearing.call(void 0, B, O) : _rhumbbearing.rhumbBearing.call(void 0, B, O)
29
+ );
30
+ const angleAO = Math.abs(azimuthAO - azimuthBO);
31
+ if (options.explementary === true) {
32
+ return 360 - angleAO;
33
+ }
34
+ return angleAO;
35
+ }
36
+ __name(angle, "angle");
37
+ var turf_angle_default = angle;
38
+
39
+
40
+
41
+ exports.angle = angle; exports.default = turf_angle_default;
42
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AAAA,SAAS,eAAe;AACxB,SAAS,kBAAyB,gBAAgB;AAClD,SAAS,oBAAoB;AAkB7B,SAAS,MACP,YACA,UACA,UACA,UAGI,CAAC,GACG;AAER,MAAI,CAAC,SAAS,OAAO,GAAG;AACtB,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AAGA,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,wBAAwB;AAAA,EAC1C;AACA,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AACA,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAGA,QAAM,IAAI;AACV,QAAM,IAAI;AACV,QAAM,IAAI;AAGV,QAAM,YAAY;AAAA,IAChB,QAAQ,aAAa,OAAO,QAAQ,GAAG,CAAC,IAAI,aAAa,GAAG,CAAC;AAAA,EAC/D;AACA,QAAM,YAAY;AAAA,IAChB,QAAQ,aAAa,OAAO,QAAQ,GAAG,CAAC,IAAI,aAAa,GAAG,CAAC;AAAA,EAC/D;AACA,QAAM,UAAU,KAAK,IAAI,YAAY,SAAS;AAG9C,MAAI,QAAQ,iBAAiB,MAAM;AACjC,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;AA5CS;AA+CT,IAAO,qBAAQ","sourcesContent":["import { bearing } from \"@turf/bearing\";\nimport { bearingToAzimuth, Coord, isObject } from \"@turf/helpers\";\nimport { rhumbBearing } from \"@turf/rhumb-bearing\";\n\n/**\n * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)\n * angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.\n *\n * @name angle\n * @param {Coord} startPoint Start Point Coordinates\n * @param {Coord} midPoint Mid Point Coordinates\n * @param {Coord} endPoint End Point Coordinates\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.explementary=false] Returns the explementary angle instead (360 - angle)\n * @param {boolean} [options.mercator=false] if calculations should be performed over Mercator or WGS84 projection\n * @returns {number} Angle between the provided points, or its explementary.\n * @example\n * turf.angle([5, 5], [5, 6], [3, 4]);\n * //=45\n */\nfunction angle(\n startPoint: Coord,\n midPoint: Coord,\n endPoint: Coord,\n options: {\n explementary?: boolean;\n mercator?: boolean;\n } = {}\n): number {\n // Optional Parameters\n if (!isObject(options)) {\n throw new Error(\"options is invalid\");\n }\n\n // Validation\n if (!startPoint) {\n throw new Error(\"startPoint is required\");\n }\n if (!midPoint) {\n throw new Error(\"midPoint is required\");\n }\n if (!endPoint) {\n throw new Error(\"endPoint is required\");\n }\n\n // Rename to shorter variables\n const A = startPoint;\n const O = midPoint;\n const B = endPoint;\n\n // Main\n const azimuthAO = bearingToAzimuth(\n options.mercator !== true ? bearing(A, O) : rhumbBearing(A, O)\n );\n const azimuthBO = bearingToAzimuth(\n options.mercator !== true ? bearing(B, O) : rhumbBearing(B, O)\n );\n const angleAO = Math.abs(azimuthAO - azimuthBO);\n\n // Explementary angle\n if (options.explementary === true) {\n return 360 - angleAO;\n }\n return angleAO;\n}\n\nexport { angle };\nexport default angle;\n"]}
@@ -0,0 +1,24 @@
1
+ import { Coord } from '@turf/helpers';
2
+
3
+ /**
4
+ * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)
5
+ * angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.
6
+ *
7
+ * @name angle
8
+ * @param {Coord} startPoint Start Point Coordinates
9
+ * @param {Coord} midPoint Mid Point Coordinates
10
+ * @param {Coord} endPoint End Point Coordinates
11
+ * @param {Object} [options={}] Optional parameters
12
+ * @param {boolean} [options.explementary=false] Returns the explementary angle instead (360 - angle)
13
+ * @param {boolean} [options.mercator=false] if calculations should be performed over Mercator or WGS84 projection
14
+ * @returns {number} Angle between the provided points, or its explementary.
15
+ * @example
16
+ * turf.angle([5, 5], [5, 6], [3, 4]);
17
+ * //=45
18
+ */
19
+ declare function angle(startPoint: Coord, midPoint: Coord, endPoint: Coord, options?: {
20
+ explementary?: boolean;
21
+ mercator?: boolean;
22
+ }): number;
23
+
24
+ export { angle, angle as default };
@@ -1,4 +1,5 @@
1
- import { Coord } from "@turf/helpers";
1
+ import { Coord } from '@turf/helpers';
2
+
2
3
  /**
3
4
  * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)
4
5
  * angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.
@@ -19,4 +20,5 @@ declare function angle(startPoint: Coord, midPoint: Coord, endPoint: Coord, opti
19
20
  explementary?: boolean;
20
21
  mercator?: boolean;
21
22
  }): number;
22
- export default angle;
23
+
24
+ export { angle, angle as default };
@@ -0,0 +1,42 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.ts
5
+ import { bearing } from "@turf/bearing";
6
+ import { bearingToAzimuth, isObject } from "@turf/helpers";
7
+ import { rhumbBearing } from "@turf/rhumb-bearing";
8
+ function angle(startPoint, midPoint, endPoint, options = {}) {
9
+ if (!isObject(options)) {
10
+ throw new Error("options is invalid");
11
+ }
12
+ if (!startPoint) {
13
+ throw new Error("startPoint is required");
14
+ }
15
+ if (!midPoint) {
16
+ throw new Error("midPoint is required");
17
+ }
18
+ if (!endPoint) {
19
+ throw new Error("endPoint is required");
20
+ }
21
+ const A = startPoint;
22
+ const O = midPoint;
23
+ const B = endPoint;
24
+ const azimuthAO = bearingToAzimuth(
25
+ options.mercator !== true ? bearing(A, O) : rhumbBearing(A, O)
26
+ );
27
+ const azimuthBO = bearingToAzimuth(
28
+ options.mercator !== true ? bearing(B, O) : rhumbBearing(B, O)
29
+ );
30
+ const angleAO = Math.abs(azimuthAO - azimuthBO);
31
+ if (options.explementary === true) {
32
+ return 360 - angleAO;
33
+ }
34
+ return angleAO;
35
+ }
36
+ __name(angle, "angle");
37
+ var turf_angle_default = angle;
38
+ export {
39
+ angle,
40
+ turf_angle_default as default
41
+ };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { bearing } from \"@turf/bearing\";\nimport { bearingToAzimuth, Coord, isObject } from \"@turf/helpers\";\nimport { rhumbBearing } from \"@turf/rhumb-bearing\";\n\n/**\n * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)\n * angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.\n *\n * @name angle\n * @param {Coord} startPoint Start Point Coordinates\n * @param {Coord} midPoint Mid Point Coordinates\n * @param {Coord} endPoint End Point Coordinates\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.explementary=false] Returns the explementary angle instead (360 - angle)\n * @param {boolean} [options.mercator=false] if calculations should be performed over Mercator or WGS84 projection\n * @returns {number} Angle between the provided points, or its explementary.\n * @example\n * turf.angle([5, 5], [5, 6], [3, 4]);\n * //=45\n */\nfunction angle(\n startPoint: Coord,\n midPoint: Coord,\n endPoint: Coord,\n options: {\n explementary?: boolean;\n mercator?: boolean;\n } = {}\n): number {\n // Optional Parameters\n if (!isObject(options)) {\n throw new Error(\"options is invalid\");\n }\n\n // Validation\n if (!startPoint) {\n throw new Error(\"startPoint is required\");\n }\n if (!midPoint) {\n throw new Error(\"midPoint is required\");\n }\n if (!endPoint) {\n throw new Error(\"endPoint is required\");\n }\n\n // Rename to shorter variables\n const A = startPoint;\n const O = midPoint;\n const B = endPoint;\n\n // Main\n const azimuthAO = bearingToAzimuth(\n options.mercator !== true ? bearing(A, O) : rhumbBearing(A, O)\n );\n const azimuthBO = bearingToAzimuth(\n options.mercator !== true ? bearing(B, O) : rhumbBearing(B, O)\n );\n const angleAO = Math.abs(azimuthAO - azimuthBO);\n\n // Explementary angle\n if (options.explementary === true) {\n return 360 - angleAO;\n }\n return angleAO;\n}\n\nexport { angle };\nexport default angle;\n"],"mappings":";;;;AAAA,SAAS,eAAe;AACxB,SAAS,kBAAyB,gBAAgB;AAClD,SAAS,oBAAoB;AAkB7B,SAAS,MACP,YACA,UACA,UACA,UAGI,CAAC,GACG;AAER,MAAI,CAAC,SAAS,OAAO,GAAG;AACtB,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AAGA,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,wBAAwB;AAAA,EAC1C;AACA,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AACA,MAAI,CAAC,UAAU;AACb,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAGA,QAAM,IAAI;AACV,QAAM,IAAI;AACV,QAAM,IAAI;AAGV,QAAM,YAAY;AAAA,IAChB,QAAQ,aAAa,OAAO,QAAQ,GAAG,CAAC,IAAI,aAAa,GAAG,CAAC;AAAA,EAC/D;AACA,QAAM,YAAY;AAAA,IAChB,QAAQ,aAAa,OAAO,QAAQ,GAAG,CAAC,IAAI,aAAa,GAAG,CAAC;AAAA,EAC/D;AACA,QAAM,UAAU,KAAK,IAAI,YAAY,SAAS;AAG9C,MAAI,QAAQ,iBAAiB,MAAM;AACjC,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;AA5CS;AA+CT,IAAO,qBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/angle",
3
- "version": "7.0.0-alpha.2",
3
+ "version": "7.0.0",
4
4
  "description": "turf angle module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -23,51 +23,56 @@
23
23
  "turf",
24
24
  "angle"
25
25
  ],
26
- "main": "dist/js/index.js",
27
- "module": "dist/es/index.js",
26
+ "type": "module",
27
+ "main": "dist/cjs/index.cjs",
28
+ "module": "dist/esm/index.js",
29
+ "types": "dist/esm/index.d.ts",
28
30
  "exports": {
29
31
  "./package.json": "./package.json",
30
32
  ".": {
31
- "types": "./dist/js/index.d.ts",
32
- "import": "./dist/es/index.js",
33
- "require": "./dist/js/index.js"
33
+ "import": {
34
+ "types": "./dist/esm/index.d.ts",
35
+ "default": "./dist/esm/index.js"
36
+ },
37
+ "require": {
38
+ "types": "./dist/cjs/index.d.cts",
39
+ "default": "./dist/cjs/index.cjs"
40
+ }
34
41
  }
35
42
  },
36
- "types": "dist/js/index.d.ts",
37
43
  "sideEffects": false,
38
44
  "files": [
39
45
  "dist"
40
46
  ],
41
47
  "scripts": {
42
- "bench": "tsx bench.js",
43
- "build": "npm-run-all build:*",
44
- "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
45
- "build:js": "tsc",
46
- "docs": "tsx ../../scripts/generate-readmes",
47
- "test": "npm-run-all test:*",
48
- "test:tape": "tsx test.js"
48
+ "bench": "tsx bench.ts",
49
+ "build": "tsup --config ../../tsup.config.ts",
50
+ "docs": "tsx ../../scripts/generate-readmes.ts",
51
+ "test": "npm-run-all --npm-path npm test:*",
52
+ "test:tape": "tsx test.ts"
49
53
  },
50
54
  "devDependencies": {
51
- "@turf/distance": "^7.0.0-alpha.2",
52
- "@turf/sector": "^7.0.0-alpha.2",
53
- "@turf/truncate": "^7.0.0-alpha.2",
54
- "@types/tape": "*",
55
- "benchmark": "*",
56
- "glob": "*",
57
- "load-json-file": "*",
58
- "npm-run-all": "*",
59
- "tape": "*",
60
- "tslint": "*",
61
- "tsx": "*",
62
- "typescript": "*",
63
- "write-json-file": "*"
55
+ "@turf/distance": "^7.0.0",
56
+ "@turf/sector": "^7.0.0",
57
+ "@turf/truncate": "^7.0.0",
58
+ "@types/benchmark": "^2.1.5",
59
+ "@types/tape": "^4.2.32",
60
+ "benchmark": "^2.1.4",
61
+ "glob": "^10.3.10",
62
+ "load-json-file": "^7.0.1",
63
+ "npm-run-all": "^4.1.5",
64
+ "tape": "^5.7.2",
65
+ "tsup": "^8.0.1",
66
+ "tsx": "^4.6.2",
67
+ "typescript": "^5.2.2",
68
+ "write-json-file": "^5.0.0"
64
69
  },
65
70
  "dependencies": {
66
- "@turf/bearing": "^7.0.0-alpha.2",
67
- "@turf/helpers": "^7.0.0-alpha.2",
68
- "@turf/invariant": "^7.0.0-alpha.2",
69
- "@turf/rhumb-bearing": "^7.0.0-alpha.2",
70
- "tslib": "^2.3.0"
71
+ "@turf/bearing": "^7.0.0",
72
+ "@turf/helpers": "^7.0.0",
73
+ "@turf/invariant": "^7.0.0",
74
+ "@turf/rhumb-bearing": "^7.0.0",
75
+ "tslib": "^2.6.2"
71
76
  },
72
- "gitHead": "dd35b52725945b4fa29a98d9a550733e06cc222e"
77
+ "gitHead": "3d3a7917025fbabe191dbddbc89754b86f9c7739"
73
78
  }
package/dist/es/index.js DELETED
@@ -1,49 +0,0 @@
1
- import bearing from "@turf/bearing";
2
- import { bearingToAzimuth, isObject } from "@turf/helpers";
3
- import rhumbBearing from "@turf/rhumb-bearing";
4
- /**
5
- * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)
6
- * angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.
7
- *
8
- * @name angle
9
- * @param {Coord} startPoint Start Point Coordinates
10
- * @param {Coord} midPoint Mid Point Coordinates
11
- * @param {Coord} endPoint End Point Coordinates
12
- * @param {Object} [options={}] Optional parameters
13
- * @param {boolean} [options.explementary=false] Returns the explementary angle instead (360 - angle)
14
- * @param {boolean} [options.mercator=false] if calculations should be performed over Mercator or WGS84 projection
15
- * @returns {number} Angle between the provided points, or its explementary.
16
- * @example
17
- * turf.angle([5, 5], [5, 6], [3, 4]);
18
- * //=45
19
- */
20
- function angle(startPoint, midPoint, endPoint, options = {}) {
21
- // Optional Parameters
22
- if (!isObject(options)) {
23
- throw new Error("options is invalid");
24
- }
25
- // Validation
26
- if (!startPoint) {
27
- throw new Error("startPoint is required");
28
- }
29
- if (!midPoint) {
30
- throw new Error("midPoint is required");
31
- }
32
- if (!endPoint) {
33
- throw new Error("endPoint is required");
34
- }
35
- // Rename to shorter variables
36
- const A = startPoint;
37
- const O = midPoint;
38
- const B = endPoint;
39
- // Main
40
- const azimuthAO = bearingToAzimuth(options.mercator !== true ? bearing(A, O) : rhumbBearing(A, O));
41
- const azimuthBO = bearingToAzimuth(options.mercator !== true ? bearing(B, O) : rhumbBearing(B, O));
42
- const angleAO = Math.abs(azimuthAO - azimuthBO);
43
- // Explementary angle
44
- if (options.explementary === true) {
45
- return 360 - angleAO;
46
- }
47
- return angleAO;
48
- }
49
- export default angle;
@@ -1 +0,0 @@
1
- {"type":"module"}
package/dist/js/index.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const bearing_1 = tslib_1.__importDefault(require("@turf/bearing"));
5
- const helpers_1 = require("@turf/helpers");
6
- const rhumb_bearing_1 = tslib_1.__importDefault(require("@turf/rhumb-bearing"));
7
- /**
8
- * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)
9
- * angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.
10
- *
11
- * @name angle
12
- * @param {Coord} startPoint Start Point Coordinates
13
- * @param {Coord} midPoint Mid Point Coordinates
14
- * @param {Coord} endPoint End Point Coordinates
15
- * @param {Object} [options={}] Optional parameters
16
- * @param {boolean} [options.explementary=false] Returns the explementary angle instead (360 - angle)
17
- * @param {boolean} [options.mercator=false] if calculations should be performed over Mercator or WGS84 projection
18
- * @returns {number} Angle between the provided points, or its explementary.
19
- * @example
20
- * turf.angle([5, 5], [5, 6], [3, 4]);
21
- * //=45
22
- */
23
- function angle(startPoint, midPoint, endPoint, options = {}) {
24
- // Optional Parameters
25
- if (!helpers_1.isObject(options)) {
26
- throw new Error("options is invalid");
27
- }
28
- // Validation
29
- if (!startPoint) {
30
- throw new Error("startPoint is required");
31
- }
32
- if (!midPoint) {
33
- throw new Error("midPoint is required");
34
- }
35
- if (!endPoint) {
36
- throw new Error("endPoint is required");
37
- }
38
- // Rename to shorter variables
39
- const A = startPoint;
40
- const O = midPoint;
41
- const B = endPoint;
42
- // Main
43
- const azimuthAO = helpers_1.bearingToAzimuth(options.mercator !== true ? bearing_1.default(A, O) : rhumb_bearing_1.default(A, O));
44
- const azimuthBO = helpers_1.bearingToAzimuth(options.mercator !== true ? bearing_1.default(B, O) : rhumb_bearing_1.default(B, O));
45
- const angleAO = Math.abs(azimuthAO - azimuthBO);
46
- // Explementary angle
47
- if (options.explementary === true) {
48
- return 360 - angleAO;
49
- }
50
- return angleAO;
51
- }
52
- exports.default = angle;