@turf/angle 6.4.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 +9 -8
- package/dist/es/index.js +7 -8
- package/dist/js/index.d.ts +0 -0
- package/dist/js/index.js +11 -14
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -7,16 +7,17 @@
|
|
|
7
7
|
Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)
|
|
8
8
|
angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Parameters
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- `options.explementary` **[boolean][3]** Returns the explementary angle instead (360 - angle) (optional, default `false`)
|
|
17
|
-
- `options.mercator` **[boolean][3]** if calculations should be performed over Mercator or WGS84 projection (optional, default `false`)
|
|
12
|
+
* `startPoint` **[Coord][1]** Start Point Coordinates
|
|
13
|
+
* `midPoint` **[Coord][1]** Mid Point Coordinates
|
|
14
|
+
* `endPoint` **[Coord][1]** End Point Coordinates
|
|
15
|
+
* `options` **[Object][2]** Optional parameters (optional, default `{}`)
|
|
18
16
|
|
|
19
|
-
**
|
|
17
|
+
* `options.explementary` **[boolean][3]** Returns the explementary angle instead (360 - angle) (optional, default `false`)
|
|
18
|
+
* `options.mercator` **[boolean][3]** if calculations should be performed over Mercator or WGS84 projection (optional, default `false`)
|
|
19
|
+
|
|
20
|
+
### Examples
|
|
20
21
|
|
|
21
22
|
```javascript
|
|
22
23
|
turf.angle([5, 5], [5, 6], [3, 4]);
|
package/dist/es/index.js
CHANGED
|
@@ -17,8 +17,7 @@ import rhumbBearing from "@turf/rhumb-bearing";
|
|
|
17
17
|
* turf.angle([5, 5], [5, 6], [3, 4]);
|
|
18
18
|
* //=45
|
|
19
19
|
*/
|
|
20
|
-
function angle(startPoint, midPoint, endPoint, options) {
|
|
21
|
-
if (options === void 0) { options = {}; }
|
|
20
|
+
function angle(startPoint, midPoint, endPoint, options = {}) {
|
|
22
21
|
// Optional Parameters
|
|
23
22
|
if (!isObject(options)) {
|
|
24
23
|
throw new Error("options is invalid");
|
|
@@ -34,13 +33,13 @@ function angle(startPoint, midPoint, endPoint, options) {
|
|
|
34
33
|
throw new Error("endPoint is required");
|
|
35
34
|
}
|
|
36
35
|
// Rename to shorter variables
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const A = startPoint;
|
|
37
|
+
const O = midPoint;
|
|
38
|
+
const B = endPoint;
|
|
40
39
|
// Main
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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);
|
|
44
43
|
// Explementary angle
|
|
45
44
|
if (options.explementary === true) {
|
|
46
45
|
return 360 - angleAO;
|
package/dist/js/index.d.ts
CHANGED
|
File without changes
|
package/dist/js/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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"));
|
|
9
7
|
/**
|
|
10
8
|
* Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)
|
|
11
9
|
* angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.
|
|
@@ -22,8 +20,7 @@ var rhumb_bearing_1 = __importDefault(require("@turf/rhumb-bearing"));
|
|
|
22
20
|
* turf.angle([5, 5], [5, 6], [3, 4]);
|
|
23
21
|
* //=45
|
|
24
22
|
*/
|
|
25
|
-
function angle(startPoint, midPoint, endPoint, options) {
|
|
26
|
-
if (options === void 0) { options = {}; }
|
|
23
|
+
function angle(startPoint, midPoint, endPoint, options = {}) {
|
|
27
24
|
// Optional Parameters
|
|
28
25
|
if (!helpers_1.isObject(options)) {
|
|
29
26
|
throw new Error("options is invalid");
|
|
@@ -39,13 +36,13 @@ function angle(startPoint, midPoint, endPoint, options) {
|
|
|
39
36
|
throw new Error("endPoint is required");
|
|
40
37
|
}
|
|
41
38
|
// Rename to shorter variables
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
const A = startPoint;
|
|
40
|
+
const O = midPoint;
|
|
41
|
+
const B = endPoint;
|
|
45
42
|
// Main
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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);
|
|
49
46
|
// Explementary angle
|
|
50
47
|
if (options.explementary === true) {
|
|
51
48
|
return 360 - angleAO;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/angle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf angle module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git://github.com/Turfjs/turf.git"
|
|
17
17
|
},
|
|
18
|
+
"funding": "https://opencollective.com/turf",
|
|
18
19
|
"publishConfig": {
|
|
19
20
|
"access": "public"
|
|
20
21
|
},
|
|
@@ -46,9 +47,9 @@
|
|
|
46
47
|
"test:tape": "ts-node -r esm test.js"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@turf/distance": "^
|
|
50
|
-
"@turf/sector": "^
|
|
51
|
-
"@turf/truncate": "^
|
|
50
|
+
"@turf/distance": "^7.0.0-alpha.0",
|
|
51
|
+
"@turf/sector": "^7.0.0-alpha.0",
|
|
52
|
+
"@turf/truncate": "^7.0.0-alpha.0",
|
|
52
53
|
"@types/tape": "*",
|
|
53
54
|
"benchmark": "*",
|
|
54
55
|
"glob": "*",
|
|
@@ -61,10 +62,11 @@
|
|
|
61
62
|
"write-json-file": "*"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@turf/bearing": "^
|
|
65
|
-
"@turf/helpers": "^
|
|
66
|
-
"@turf/invariant": "^
|
|
67
|
-
"@turf/rhumb-bearing": "^
|
|
65
|
+
"@turf/bearing": "^7.0.0-alpha.0",
|
|
66
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
67
|
+
"@turf/invariant": "^7.0.0-alpha.0",
|
|
68
|
+
"@turf/rhumb-bearing": "^7.0.0-alpha.0",
|
|
69
|
+
"tslib": "^2.3.0"
|
|
68
70
|
},
|
|
69
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
70
72
|
}
|