@turf/angle 7.1.0-alpha.70 → 7.2.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.
@@ -18,17 +18,20 @@ function angle(startPoint, midPoint, endPoint, options = {}) {
18
18
  const A = startPoint;
19
19
  const O = midPoint;
20
20
  const B = endPoint;
21
- const azimuthAO = _helpers.bearingToAzimuth.call(void 0,
22
- options.mercator !== true ? _bearing.bearing.call(void 0, A, O) : _rhumbbearing.rhumbBearing.call(void 0, A, O)
21
+ const azimuthOA = _helpers.bearingToAzimuth.call(void 0,
22
+ options.mercator !== true ? _bearing.bearing.call(void 0, O, A) : _rhumbbearing.rhumbBearing.call(void 0, O, A)
23
23
  );
24
- const azimuthBO = _helpers.bearingToAzimuth.call(void 0,
25
- options.mercator !== true ? _bearing.bearing.call(void 0, B, O) : _rhumbbearing.rhumbBearing.call(void 0, B, O)
24
+ let azimuthOB = _helpers.bearingToAzimuth.call(void 0,
25
+ options.mercator !== true ? _bearing.bearing.call(void 0, O, B) : _rhumbbearing.rhumbBearing.call(void 0, O, B)
26
26
  );
27
- const angleAO = Math.abs(azimuthAO - azimuthBO);
27
+ if (azimuthOB < azimuthOA) {
28
+ azimuthOB = azimuthOB + 360;
29
+ }
30
+ const angleAOB = azimuthOB - azimuthOA;
28
31
  if (options.explementary === true) {
29
- return 360 - angleAO;
32
+ return 360 - angleAOB;
30
33
  }
31
- return angleAO;
34
+ return angleAOB;
32
35
  }
33
36
  var turf_angle_default = angle;
34
37
 
@@ -1 +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;AAGA,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"]}
1
+ {"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-angle/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACAA,wCAAwB;AACxB,wCAAkD;AAClD,mDAA6B;AAkB7B,SAAS,KAAA,CACP,UAAA,EACA,QAAA,EACA,QAAA,EACA,QAAA,EAGI,CAAC,CAAA,EACG;AAER,EAAA,GAAA,CAAI,CAAC,+BAAA,OAAgB,CAAA,EAAG;AACtB,IAAA,MAAM,IAAI,KAAA,CAAM,oBAAoB,CAAA;AAAA,EACtC;AAGA,EAAA,GAAA,CAAI,CAAC,UAAA,EAAY;AACf,IAAA,MAAM,IAAI,KAAA,CAAM,wBAAwB,CAAA;AAAA,EAC1C;AACA,EAAA,GAAA,CAAI,CAAC,QAAA,EAAU;AACb,IAAA,MAAM,IAAI,KAAA,CAAM,sBAAsB,CAAA;AAAA,EACxC;AACA,EAAA,GAAA,CAAI,CAAC,QAAA,EAAU;AACb,IAAA,MAAM,IAAI,KAAA,CAAM,sBAAsB,CAAA;AAAA,EACxC;AAGA,EAAA,MAAM,EAAA,EAAI,UAAA;AACV,EAAA,MAAM,EAAA,EAAI,QAAA;AACV,EAAA,MAAM,EAAA,EAAI,QAAA;AAGV,EAAA,MAAM,UAAA,EAAY,uCAAA;AAAA,IAChB,OAAA,CAAQ,SAAA,IAAa,KAAA,EAAO,8BAAA,CAAQ,EAAG,CAAC,EAAA,EAAI,wCAAA,CAAa,EAAG,CAAC;AAAA,EAC/D,CAAA;AACA,EAAA,IAAI,UAAA,EAAY,uCAAA;AAAA,IACd,OAAA,CAAQ,SAAA,IAAa,KAAA,EAAO,8BAAA,CAAQ,EAAG,CAAC,EAAA,EAAI,wCAAA,CAAa,EAAG,CAAC;AAAA,EAC/D,CAAA;AAEA,EAAA,GAAA,CAAI,UAAA,EAAY,SAAA,EAAW;AACzB,IAAA,UAAA,EAAY,UAAA,EAAY,GAAA;AAAA,EAC1B;AACA,EAAA,MAAM,SAAA,EAAW,UAAA,EAAY,SAAA;AAG7B,EAAA,GAAA,CAAI,OAAA,CAAQ,aAAA,IAAiB,IAAA,EAAM;AACjC,IAAA,OAAO,IAAA,EAAM,QAAA;AAAA,EACf;AACA,EAAA,OAAO,QAAA;AACT;AAGA,IAAO,mBAAA,EAAQ,KAAA;ADnCf;AACE;AACA;AACF,4DAAC","file":"/home/runner/work/turf/turf/packages/turf-angle/dist/cjs/index.cjs","sourcesContent":[null,"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 * @function\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 azimuthOA = bearingToAzimuth(\n options.mercator !== true ? bearing(O, A) : rhumbBearing(O, A)\n );\n let azimuthOB = bearingToAzimuth(\n options.mercator !== true ? bearing(O, B) : rhumbBearing(O, B)\n );\n // If OB \"trails\" OA advance OB one revolution so we get the clockwise angle.\n if (azimuthOB < azimuthOA) {\n azimuthOB = azimuthOB + 360;\n }\n const angleAOB = azimuthOB - azimuthOA;\n\n // Explementary angle\n if (options.explementary === true) {\n return 360 - angleAOB;\n }\n return angleAOB;\n}\n\nexport { angle };\nexport default angle;\n"]}
@@ -4,7 +4,7 @@ import { Coord } from '@turf/helpers';
4
4
  * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)
5
5
  * angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.
6
6
  *
7
- * @name angle
7
+ * @function
8
8
  * @param {Coord} startPoint Start Point Coordinates
9
9
  * @param {Coord} midPoint Mid Point Coordinates
10
10
  * @param {Coord} endPoint End Point Coordinates
@@ -4,7 +4,7 @@ import { Coord } from '@turf/helpers';
4
4
  * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)
5
5
  * angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.
6
6
  *
7
- * @name angle
7
+ * @function
8
8
  * @param {Coord} startPoint Start Point Coordinates
9
9
  * @param {Coord} midPoint Mid Point Coordinates
10
10
  * @param {Coord} endPoint End Point Coordinates
package/dist/esm/index.js CHANGED
@@ -18,17 +18,20 @@ function angle(startPoint, midPoint, endPoint, options = {}) {
18
18
  const A = startPoint;
19
19
  const O = midPoint;
20
20
  const B = endPoint;
21
- const azimuthAO = bearingToAzimuth(
22
- options.mercator !== true ? bearing(A, O) : rhumbBearing(A, O)
21
+ const azimuthOA = bearingToAzimuth(
22
+ options.mercator !== true ? bearing(O, A) : rhumbBearing(O, A)
23
23
  );
24
- const azimuthBO = bearingToAzimuth(
25
- options.mercator !== true ? bearing(B, O) : rhumbBearing(B, O)
24
+ let azimuthOB = bearingToAzimuth(
25
+ options.mercator !== true ? bearing(O, B) : rhumbBearing(O, B)
26
26
  );
27
- const angleAO = Math.abs(azimuthAO - azimuthBO);
27
+ if (azimuthOB < azimuthOA) {
28
+ azimuthOB = azimuthOB + 360;
29
+ }
30
+ const angleAOB = azimuthOB - azimuthOA;
28
31
  if (options.explementary === true) {
29
- return 360 - angleAO;
32
+ return 360 - angleAOB;
30
33
  }
31
- return angleAO;
34
+ return angleAOB;
32
35
  }
33
36
  var turf_angle_default = angle;
34
37
  export {
@@ -1 +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;AAGA,IAAO,qBAAQ;","names":[]}
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 * @function\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 azimuthOA = bearingToAzimuth(\n options.mercator !== true ? bearing(O, A) : rhumbBearing(O, A)\n );\n let azimuthOB = bearingToAzimuth(\n options.mercator !== true ? bearing(O, B) : rhumbBearing(O, B)\n );\n // If OB \"trails\" OA advance OB one revolution so we get the clockwise angle.\n if (azimuthOB < azimuthOA) {\n azimuthOB = azimuthOB + 360;\n }\n const angleAOB = azimuthOB - azimuthOA;\n\n // Explementary angle\n if (options.explementary === true) {\n return 360 - angleAOB;\n }\n return angleAOB;\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,MAAI,YAAY;AAAA,IACd,QAAQ,aAAa,OAAO,QAAQ,GAAG,CAAC,IAAI,aAAa,GAAG,CAAC;AAAA,EAC/D;AAEA,MAAI,YAAY,WAAW;AACzB,gBAAY,YAAY;AAAA,EAC1B;AACA,QAAM,WAAW,YAAY;AAG7B,MAAI,QAAQ,iBAAiB,MAAM;AACjC,WAAO,MAAM;AAAA,EACf;AACA,SAAO;AACT;AAGA,IAAO,qBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/angle",
3
- "version": "7.1.0-alpha.70+948cdafaf",
3
+ "version": "7.2.0",
4
4
  "description": "turf angle module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -52,28 +52,28 @@
52
52
  "test:tape": "tsx test.ts"
53
53
  },
54
54
  "devDependencies": {
55
- "@turf/distance": "^7.1.0-alpha.70+948cdafaf",
56
- "@turf/sector": "^7.1.0-alpha.70+948cdafaf",
57
- "@turf/truncate": "^7.1.0-alpha.70+948cdafaf",
55
+ "@turf/distance": "^7.2.0",
56
+ "@turf/sector": "^7.2.0",
57
+ "@turf/truncate": "^7.2.0",
58
58
  "@types/benchmark": "^2.1.5",
59
- "@types/tape": "^4.2.32",
59
+ "@types/tape": "^4.13.4",
60
60
  "benchmark": "^2.1.4",
61
61
  "glob": "^10.3.10",
62
62
  "load-json-file": "^7.0.1",
63
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",
64
+ "tape": "^5.9.0",
65
+ "tsup": "^8.3.5",
66
+ "tsx": "^4.19.2",
67
+ "typescript": "^5.5.4",
68
68
  "write-json-file": "^5.0.0"
69
69
  },
70
70
  "dependencies": {
71
- "@turf/bearing": "^7.1.0-alpha.70+948cdafaf",
72
- "@turf/helpers": "^7.1.0-alpha.70+948cdafaf",
73
- "@turf/invariant": "^7.1.0-alpha.70+948cdafaf",
74
- "@turf/rhumb-bearing": "^7.1.0-alpha.70+948cdafaf",
71
+ "@turf/bearing": "^7.2.0",
72
+ "@turf/helpers": "^7.2.0",
73
+ "@turf/invariant": "^7.2.0",
74
+ "@turf/rhumb-bearing": "^7.2.0",
75
75
  "@types/geojson": "^7946.0.10",
76
- "tslib": "^2.6.2"
76
+ "tslib": "^2.8.1"
77
77
  },
78
- "gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067"
78
+ "gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867"
79
79
  }