@turf/line-arc 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 +11 -10
- package/dist/es/index.js +12 -13
- package/dist/js/index.d.ts +2 -1
- package/dist/js/index.js +16 -19
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -7,17 +7,18 @@
|
|
|
7
7
|
Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;
|
|
8
8
|
0 bearing is North of center point, positive clockwise.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Parameters
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- `options.steps` **[number][2]** number of steps (optional, default `64`)
|
|
18
|
-
- `options.units` **[string][4]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
|
|
12
|
+
* `center` **[Coord][1]** center point
|
|
13
|
+
* `radius` **[number][2]** radius of the circle
|
|
14
|
+
* `bearing1` **[number][2]** angle, in decimal degrees, of the first radius of the arc
|
|
15
|
+
* `bearing2` **[number][2]** angle, in decimal degrees, of the second radius of the arc
|
|
16
|
+
* `options` **[Object][3]** Optional parameters (optional, default `{}`)
|
|
19
17
|
|
|
20
|
-
**
|
|
18
|
+
* `options.steps` **[number][2]** number of steps (optional, default `64`)
|
|
19
|
+
* `options.units` **[string][4]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
|
|
20
|
+
|
|
21
|
+
### Examples
|
|
21
22
|
|
|
22
23
|
```javascript
|
|
23
24
|
var center = turf.point([-75, 40]);
|
|
@@ -31,7 +32,7 @@ var arc = turf.lineArc(center, radius, bearing1, bearing2);
|
|
|
31
32
|
var addToMap = [center, arc]
|
|
32
33
|
```
|
|
33
34
|
|
|
34
|
-
Returns **[Feature][5]
|
|
35
|
+
Returns **[Feature][5]<[LineString][6]>** line arc
|
|
35
36
|
|
|
36
37
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.1
|
|
37
38
|
|
package/dist/es/index.js
CHANGED
|
@@ -25,30 +25,29 @@ import { lineString } from "@turf/helpers";
|
|
|
25
25
|
* //addToMap
|
|
26
26
|
* var addToMap = [center, arc]
|
|
27
27
|
*/
|
|
28
|
-
export default function lineArc(center, radius, bearing1, bearing2, options) {
|
|
29
|
-
if (options === void 0) { options = {}; }
|
|
28
|
+
export default function lineArc(center, radius, bearing1, bearing2, options = {}) {
|
|
30
29
|
// default params
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
const steps = options.steps || 64;
|
|
31
|
+
const angle1 = convertAngleTo360(bearing1);
|
|
32
|
+
const angle2 = convertAngleTo360(bearing2);
|
|
33
|
+
const properties = !Array.isArray(center) && center.type === "Feature"
|
|
35
34
|
? center.properties
|
|
36
35
|
: {};
|
|
37
36
|
// handle angle parameters
|
|
38
37
|
if (angle1 === angle2) {
|
|
39
38
|
return lineString(circle(center, radius, options).geometry.coordinates[0], properties);
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
const arcStartDegree = angle1;
|
|
41
|
+
const arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;
|
|
42
|
+
let alfa = arcStartDegree;
|
|
43
|
+
const coordinates = [];
|
|
44
|
+
let i = 0;
|
|
46
45
|
while (alfa < arcEndDegree) {
|
|
47
46
|
coordinates.push(destination(center, radius, alfa, options).geometry.coordinates);
|
|
48
47
|
i++;
|
|
49
48
|
alfa = arcStartDegree + (i * 360) / steps;
|
|
50
49
|
}
|
|
51
|
-
if (alfa
|
|
50
|
+
if (alfa >= arcEndDegree) {
|
|
52
51
|
coordinates.push(destination(center, radius, arcEndDegree, options).geometry.coordinates);
|
|
53
52
|
}
|
|
54
53
|
return lineString(coordinates, properties);
|
|
@@ -62,7 +61,7 @@ export default function lineArc(center, radius, bearing1, bearing2, options) {
|
|
|
62
61
|
* @returns {number} angle between 0-360 degrees
|
|
63
62
|
*/
|
|
64
63
|
function convertAngleTo360(alfa) {
|
|
65
|
-
|
|
64
|
+
let beta = alfa % 360;
|
|
66
65
|
if (beta < 0) {
|
|
67
66
|
beta += 360;
|
|
68
67
|
}
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Feature, LineString } from "geojson";
|
|
2
|
+
import { Coord, Units } from "@turf/helpers";
|
|
2
3
|
/**
|
|
3
4
|
* Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;
|
|
4
5
|
* 0 bearing is North of center point, positive clockwise.
|
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 circle_1 = tslib_1.__importDefault(require("@turf/circle"));
|
|
5
|
+
const destination_1 = tslib_1.__importDefault(require("@turf/destination"));
|
|
6
|
+
const helpers_1 = require("@turf/helpers");
|
|
9
7
|
/**
|
|
10
8
|
* Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;
|
|
11
9
|
* 0 bearing is North of center point, positive clockwise.
|
|
@@ -30,30 +28,29 @@ var helpers_1 = require("@turf/helpers");
|
|
|
30
28
|
* //addToMap
|
|
31
29
|
* var addToMap = [center, arc]
|
|
32
30
|
*/
|
|
33
|
-
function lineArc(center, radius, bearing1, bearing2, options) {
|
|
34
|
-
if (options === void 0) { options = {}; }
|
|
31
|
+
function lineArc(center, radius, bearing1, bearing2, options = {}) {
|
|
35
32
|
// default params
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
const steps = options.steps || 64;
|
|
34
|
+
const angle1 = convertAngleTo360(bearing1);
|
|
35
|
+
const angle2 = convertAngleTo360(bearing2);
|
|
36
|
+
const properties = !Array.isArray(center) && center.type === "Feature"
|
|
40
37
|
? center.properties
|
|
41
38
|
: {};
|
|
42
39
|
// handle angle parameters
|
|
43
40
|
if (angle1 === angle2) {
|
|
44
41
|
return helpers_1.lineString(circle_1.default(center, radius, options).geometry.coordinates[0], properties);
|
|
45
42
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
const arcStartDegree = angle1;
|
|
44
|
+
const arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;
|
|
45
|
+
let alfa = arcStartDegree;
|
|
46
|
+
const coordinates = [];
|
|
47
|
+
let i = 0;
|
|
51
48
|
while (alfa < arcEndDegree) {
|
|
52
49
|
coordinates.push(destination_1.default(center, radius, alfa, options).geometry.coordinates);
|
|
53
50
|
i++;
|
|
54
51
|
alfa = arcStartDegree + (i * 360) / steps;
|
|
55
52
|
}
|
|
56
|
-
if (alfa
|
|
53
|
+
if (alfa >= arcEndDegree) {
|
|
57
54
|
coordinates.push(destination_1.default(center, radius, arcEndDegree, options).geometry.coordinates);
|
|
58
55
|
}
|
|
59
56
|
return helpers_1.lineString(coordinates, properties);
|
|
@@ -68,7 +65,7 @@ exports.default = lineArc;
|
|
|
68
65
|
* @returns {number} angle between 0-360 degrees
|
|
69
66
|
*/
|
|
70
67
|
function convertAngleTo360(alfa) {
|
|
71
|
-
|
|
68
|
+
let beta = alfa % 360;
|
|
72
69
|
if (beta < 0) {
|
|
73
70
|
beta += 360;
|
|
74
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/line-arc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.1",
|
|
4
4
|
"description": "turf line-arc module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"exports": {
|
|
26
26
|
"./package.json": "./package.json",
|
|
27
27
|
".": {
|
|
28
|
+
"types": "./dist/js/index.d.ts",
|
|
28
29
|
"import": "./dist/es/index.js",
|
|
29
30
|
"require": "./dist/js/index.js"
|
|
30
31
|
}
|
|
@@ -35,29 +36,30 @@
|
|
|
35
36
|
"dist"
|
|
36
37
|
],
|
|
37
38
|
"scripts": {
|
|
38
|
-
"bench": "
|
|
39
|
+
"bench": "tsx bench.js",
|
|
39
40
|
"build": "npm-run-all build:*",
|
|
40
41
|
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
|
|
41
42
|
"build:js": "tsc",
|
|
42
|
-
"docs": "
|
|
43
|
+
"docs": "tsx ../../scripts/generate-readmes",
|
|
43
44
|
"test": "npm-run-all test:*",
|
|
44
|
-
"test:tape": "
|
|
45
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
45
|
+
"test:tape": "tsx test.js",
|
|
46
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@turf/truncate": "^
|
|
49
|
+
"@turf/truncate": "^7.0.0-alpha.1",
|
|
49
50
|
"benchmark": "*",
|
|
50
51
|
"load-json-file": "*",
|
|
51
52
|
"npm-run-all": "*",
|
|
52
53
|
"tape": "*",
|
|
53
|
-
"
|
|
54
|
+
"tsx": "*",
|
|
54
55
|
"typescript": "*",
|
|
55
56
|
"write-json-file": "*"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
|
-
"@turf/circle": "^
|
|
59
|
-
"@turf/destination": "^
|
|
60
|
-
"@turf/helpers": "^
|
|
59
|
+
"@turf/circle": "^7.0.0-alpha.1",
|
|
60
|
+
"@turf/destination": "^7.0.0-alpha.1",
|
|
61
|
+
"@turf/helpers": "^7.0.0-alpha.1",
|
|
62
|
+
"tslib": "^2.3.0"
|
|
61
63
|
},
|
|
62
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
|
|
63
65
|
}
|