@turf/line-arc 7.0.0-alpha.2 → 7.1.0-alpha.7
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 +5 -10
- package/dist/cjs/index.cjs +43 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +33 -0
- package/dist/{js → esm}/index.d.ts +7 -4
- package/dist/esm/index.js +43 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +35 -28
- package/dist/es/index.js +0 -69
- package/dist/es/package.json +0 -1
- package/dist/js/index.js +0 -73
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Creates a circular arc, of a circle of the given radius and center point, betwee
|
|
|
15
15
|
* `bearing2` **[number][2]** angle, in decimal degrees, of the second radius of the arc
|
|
16
16
|
* `options` **[Object][3]** Optional parameters (optional, default `{}`)
|
|
17
17
|
|
|
18
|
-
* `options.steps` **[number][2]** number of steps (optional, default `64`)
|
|
18
|
+
* `options.steps` **[number][2]** number of steps (straight segments) that will constitute the arc (optional, default `64`)
|
|
19
19
|
* `options.units` **[string][4]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
|
|
20
20
|
|
|
21
21
|
### Examples
|
|
@@ -46,26 +46,21 @@ Returns **[Feature][5]<[LineString][6]>** line arc
|
|
|
46
46
|
|
|
47
47
|
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
48
48
|
|
|
49
|
-
<!-- This file is automatically generated. Please don't edit it directly
|
|
50
|
-
if you find an error, edit the source file (likely index.js), and re-run
|
|
51
|
-
./scripts/generate-readmes in the turf project. -->
|
|
49
|
+
<!-- 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. -->
|
|
52
50
|
|
|
53
51
|
---
|
|
54
52
|
|
|
55
|
-
This module is part of the [Turfjs project](
|
|
56
|
-
module collection dedicated to geographic algorithms. It is maintained in the
|
|
57
|
-
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
58
|
-
PRs and issues.
|
|
53
|
+
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.
|
|
59
54
|
|
|
60
55
|
### Installation
|
|
61
56
|
|
|
62
|
-
Install this module individually:
|
|
57
|
+
Install this single module individually:
|
|
63
58
|
|
|
64
59
|
```sh
|
|
65
60
|
$ npm install @turf/line-arc
|
|
66
61
|
```
|
|
67
62
|
|
|
68
|
-
Or install the
|
|
63
|
+
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
|
69
64
|
|
|
70
65
|
```sh
|
|
71
66
|
$ npm install @turf/turf
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
2
|
+
var _circle = require('@turf/circle');
|
|
3
|
+
var _destination = require('@turf/destination');
|
|
4
|
+
var _helpers = require('@turf/helpers');
|
|
5
|
+
function lineArc(center, radius, bearing1, bearing2, options = {}) {
|
|
6
|
+
const steps = options.steps || 64;
|
|
7
|
+
const angle1 = convertAngleTo360(bearing1);
|
|
8
|
+
const angle2 = convertAngleTo360(bearing2);
|
|
9
|
+
const properties = !Array.isArray(center) && center.type === "Feature" ? center.properties : {};
|
|
10
|
+
if (angle1 === angle2) {
|
|
11
|
+
return _helpers.lineString.call(void 0,
|
|
12
|
+
_circle.circle.call(void 0, center, radius, options).geometry.coordinates[0],
|
|
13
|
+
properties
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
const arcStartDegree = angle1;
|
|
17
|
+
const arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;
|
|
18
|
+
let alpha = arcStartDegree;
|
|
19
|
+
const coordinates = [];
|
|
20
|
+
let i = 0;
|
|
21
|
+
const arcStep = (arcEndDegree - arcStartDegree) / steps;
|
|
22
|
+
while (alpha <= arcEndDegree) {
|
|
23
|
+
coordinates.push(
|
|
24
|
+
_destination.destination.call(void 0, center, radius, alpha, options).geometry.coordinates
|
|
25
|
+
);
|
|
26
|
+
i++;
|
|
27
|
+
alpha = arcStartDegree + i * arcStep;
|
|
28
|
+
}
|
|
29
|
+
return _helpers.lineString.call(void 0, coordinates, properties);
|
|
30
|
+
}
|
|
31
|
+
function convertAngleTo360(alpha) {
|
|
32
|
+
let beta = alpha % 360;
|
|
33
|
+
if (beta < 0) {
|
|
34
|
+
beta += 360;
|
|
35
|
+
}
|
|
36
|
+
return beta;
|
|
37
|
+
}
|
|
38
|
+
var turf_line_arc_default = lineArc;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
exports.default = turf_line_arc_default; exports.lineArc = lineArc;
|
|
43
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAgB,kBAAyB;AA0BzC,SAAS,QACP,QACA,QACA,UACA,UACA,UAGI,CAAC,GACgB;AAErB,QAAM,QAAQ,QAAQ,SAAS;AAE/B,QAAM,SAAS,kBAAkB,QAAQ;AACzC,QAAM,SAAS,kBAAkB,QAAQ;AACzC,QAAM,aACJ,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,YACtC,OAAO,aACP,CAAC;AAGP,MAAI,WAAW,QAAQ;AACrB,WAAO;AAAA,MACL,OAAO,QAAQ,QAAQ,OAAO,EAAE,SAAS,YAAY,CAAC;AAAA,MACtD;AAAA,IACF;AAAA,EACF;AACA,QAAM,iBAAiB;AACvB,QAAM,eAAe,SAAS,SAAS,SAAS,SAAS;AAEzD,MAAI,QAAQ;AACZ,QAAM,cAAc,CAAC;AACrB,MAAI,IAAI;AAER,QAAM,WAAW,eAAe,kBAAkB;AAGlD,SAAO,SAAS,cAAc;AAC5B,gBAAY;AAAA,MACV,YAAY,QAAQ,QAAQ,OAAO,OAAO,EAAE,SAAS;AAAA,IACvD;AACA;AACA,YAAQ,iBAAiB,IAAI;AAAA,EAC/B;AACA,SAAO,WAAW,aAAa,UAAU;AAC3C;AAUA,SAAS,kBAAkB,OAAe;AACxC,MAAI,OAAO,QAAQ;AACnB,MAAI,OAAO,GAAG;AACZ,YAAQ;AAAA,EACV;AACA,SAAO;AACT;AAGA,IAAO,wBAAQ","sourcesContent":["import { Feature, LineString } from \"geojson\";\nimport { circle } from \"@turf/circle\";\nimport { destination } from \"@turf/destination\";\nimport { Coord, lineString, Units } from \"@turf/helpers\";\n\n/**\n * Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;\n * 0 bearing is North of center point, positive clockwise.\n *\n * @name lineArc\n * @param {Coord} center center point\n * @param {number} radius radius of the circle\n * @param {number} bearing1 angle, in decimal degrees, of the first radius of the arc\n * @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.steps=64] number of steps (straight segments) that will constitute the arc\n * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians\n * @returns {Feature<LineString>} line arc\n * @example\n * var center = turf.point([-75, 40]);\n * var radius = 5;\n * var bearing1 = 25;\n * var bearing2 = 47;\n *\n * var arc = turf.lineArc(center, radius, bearing1, bearing2);\n *\n * //addToMap\n * var addToMap = [center, arc]\n */\nfunction lineArc(\n center: Coord,\n radius: number,\n bearing1: number,\n bearing2: number,\n options: {\n steps?: number;\n units?: Units;\n } = {}\n): Feature<LineString> {\n // default params\n const steps = options.steps || 64;\n\n const angle1 = convertAngleTo360(bearing1);\n const angle2 = convertAngleTo360(bearing2);\n const properties =\n !Array.isArray(center) && center.type === \"Feature\"\n ? center.properties\n : {};\n\n // handle angle parameters\n if (angle1 === angle2) {\n return lineString(\n circle(center, radius, options).geometry.coordinates[0],\n properties\n );\n }\n const arcStartDegree = angle1;\n const arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;\n\n let alpha = arcStartDegree;\n const coordinates = [];\n let i = 0;\n // How many degrees we'll swing around between each step.\n const arcStep = (arcEndDegree - arcStartDegree) / steps;\n // Add coords to the list, increasing the angle from our start bearing\n // (alpha) by arcStep degrees until we reach the end bearing.\n while (alpha <= arcEndDegree) {\n coordinates.push(\n destination(center, radius, alpha, options).geometry.coordinates\n );\n i++;\n alpha = arcStartDegree + i * arcStep;\n }\n return lineString(coordinates, properties);\n}\n\n/**\n * Takes any angle in degrees\n * and returns a valid angle between 0-360 degrees\n *\n * @private\n * @param {number} alpha angle between -180-180 degrees\n * @returns {number} angle between 0-360 degrees\n */\nfunction convertAngleTo360(alpha: number) {\n let beta = alpha % 360;\n if (beta < 0) {\n beta += 360;\n }\n return beta;\n}\n\nexport { lineArc };\nexport default lineArc;\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Feature, LineString } from 'geojson';
|
|
2
|
+
import { Coord, Units } from '@turf/helpers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;
|
|
6
|
+
* 0 bearing is North of center point, positive clockwise.
|
|
7
|
+
*
|
|
8
|
+
* @name lineArc
|
|
9
|
+
* @param {Coord} center center point
|
|
10
|
+
* @param {number} radius radius of the circle
|
|
11
|
+
* @param {number} bearing1 angle, in decimal degrees, of the first radius of the arc
|
|
12
|
+
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc
|
|
13
|
+
* @param {Object} [options={}] Optional parameters
|
|
14
|
+
* @param {number} [options.steps=64] number of steps (straight segments) that will constitute the arc
|
|
15
|
+
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
|
|
16
|
+
* @returns {Feature<LineString>} line arc
|
|
17
|
+
* @example
|
|
18
|
+
* var center = turf.point([-75, 40]);
|
|
19
|
+
* var radius = 5;
|
|
20
|
+
* var bearing1 = 25;
|
|
21
|
+
* var bearing2 = 47;
|
|
22
|
+
*
|
|
23
|
+
* var arc = turf.lineArc(center, radius, bearing1, bearing2);
|
|
24
|
+
*
|
|
25
|
+
* //addToMap
|
|
26
|
+
* var addToMap = [center, arc]
|
|
27
|
+
*/
|
|
28
|
+
declare function lineArc(center: Coord, radius: number, bearing1: number, bearing2: number, options?: {
|
|
29
|
+
steps?: number;
|
|
30
|
+
units?: Units;
|
|
31
|
+
}): Feature<LineString>;
|
|
32
|
+
|
|
33
|
+
export { lineArc as default, lineArc };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Feature, LineString } from
|
|
2
|
-
import { Coord, Units } from
|
|
1
|
+
import { Feature, LineString } from 'geojson';
|
|
2
|
+
import { Coord, Units } from '@turf/helpers';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;
|
|
5
6
|
* 0 bearing is North of center point, positive clockwise.
|
|
@@ -10,7 +11,7 @@ import { Coord, Units } from "@turf/helpers";
|
|
|
10
11
|
* @param {number} bearing1 angle, in decimal degrees, of the first radius of the arc
|
|
11
12
|
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc
|
|
12
13
|
* @param {Object} [options={}] Optional parameters
|
|
13
|
-
* @param {number} [options.steps=64] number of steps
|
|
14
|
+
* @param {number} [options.steps=64] number of steps (straight segments) that will constitute the arc
|
|
14
15
|
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
|
|
15
16
|
* @returns {Feature<LineString>} line arc
|
|
16
17
|
* @example
|
|
@@ -24,7 +25,9 @@ import { Coord, Units } from "@turf/helpers";
|
|
|
24
25
|
* //addToMap
|
|
25
26
|
* var addToMap = [center, arc]
|
|
26
27
|
*/
|
|
27
|
-
|
|
28
|
+
declare function lineArc(center: Coord, radius: number, bearing1: number, bearing2: number, options?: {
|
|
28
29
|
steps?: number;
|
|
29
30
|
units?: Units;
|
|
30
31
|
}): Feature<LineString>;
|
|
32
|
+
|
|
33
|
+
export { lineArc as default, lineArc };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// index.ts
|
|
2
|
+
import { circle } from "@turf/circle";
|
|
3
|
+
import { destination } from "@turf/destination";
|
|
4
|
+
import { lineString } from "@turf/helpers";
|
|
5
|
+
function lineArc(center, radius, bearing1, bearing2, options = {}) {
|
|
6
|
+
const steps = options.steps || 64;
|
|
7
|
+
const angle1 = convertAngleTo360(bearing1);
|
|
8
|
+
const angle2 = convertAngleTo360(bearing2);
|
|
9
|
+
const properties = !Array.isArray(center) && center.type === "Feature" ? center.properties : {};
|
|
10
|
+
if (angle1 === angle2) {
|
|
11
|
+
return lineString(
|
|
12
|
+
circle(center, radius, options).geometry.coordinates[0],
|
|
13
|
+
properties
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
const arcStartDegree = angle1;
|
|
17
|
+
const arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;
|
|
18
|
+
let alpha = arcStartDegree;
|
|
19
|
+
const coordinates = [];
|
|
20
|
+
let i = 0;
|
|
21
|
+
const arcStep = (arcEndDegree - arcStartDegree) / steps;
|
|
22
|
+
while (alpha <= arcEndDegree) {
|
|
23
|
+
coordinates.push(
|
|
24
|
+
destination(center, radius, alpha, options).geometry.coordinates
|
|
25
|
+
);
|
|
26
|
+
i++;
|
|
27
|
+
alpha = arcStartDegree + i * arcStep;
|
|
28
|
+
}
|
|
29
|
+
return lineString(coordinates, properties);
|
|
30
|
+
}
|
|
31
|
+
function convertAngleTo360(alpha) {
|
|
32
|
+
let beta = alpha % 360;
|
|
33
|
+
if (beta < 0) {
|
|
34
|
+
beta += 360;
|
|
35
|
+
}
|
|
36
|
+
return beta;
|
|
37
|
+
}
|
|
38
|
+
var turf_line_arc_default = lineArc;
|
|
39
|
+
export {
|
|
40
|
+
turf_line_arc_default as default,
|
|
41
|
+
lineArc
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, LineString } from \"geojson\";\nimport { circle } from \"@turf/circle\";\nimport { destination } from \"@turf/destination\";\nimport { Coord, lineString, Units } from \"@turf/helpers\";\n\n/**\n * Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;\n * 0 bearing is North of center point, positive clockwise.\n *\n * @name lineArc\n * @param {Coord} center center point\n * @param {number} radius radius of the circle\n * @param {number} bearing1 angle, in decimal degrees, of the first radius of the arc\n * @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc\n * @param {Object} [options={}] Optional parameters\n * @param {number} [options.steps=64] number of steps (straight segments) that will constitute the arc\n * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians\n * @returns {Feature<LineString>} line arc\n * @example\n * var center = turf.point([-75, 40]);\n * var radius = 5;\n * var bearing1 = 25;\n * var bearing2 = 47;\n *\n * var arc = turf.lineArc(center, radius, bearing1, bearing2);\n *\n * //addToMap\n * var addToMap = [center, arc]\n */\nfunction lineArc(\n center: Coord,\n radius: number,\n bearing1: number,\n bearing2: number,\n options: {\n steps?: number;\n units?: Units;\n } = {}\n): Feature<LineString> {\n // default params\n const steps = options.steps || 64;\n\n const angle1 = convertAngleTo360(bearing1);\n const angle2 = convertAngleTo360(bearing2);\n const properties =\n !Array.isArray(center) && center.type === \"Feature\"\n ? center.properties\n : {};\n\n // handle angle parameters\n if (angle1 === angle2) {\n return lineString(\n circle(center, radius, options).geometry.coordinates[0],\n properties\n );\n }\n const arcStartDegree = angle1;\n const arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;\n\n let alpha = arcStartDegree;\n const coordinates = [];\n let i = 0;\n // How many degrees we'll swing around between each step.\n const arcStep = (arcEndDegree - arcStartDegree) / steps;\n // Add coords to the list, increasing the angle from our start bearing\n // (alpha) by arcStep degrees until we reach the end bearing.\n while (alpha <= arcEndDegree) {\n coordinates.push(\n destination(center, radius, alpha, options).geometry.coordinates\n );\n i++;\n alpha = arcStartDegree + i * arcStep;\n }\n return lineString(coordinates, properties);\n}\n\n/**\n * Takes any angle in degrees\n * and returns a valid angle between 0-360 degrees\n *\n * @private\n * @param {number} alpha angle between -180-180 degrees\n * @returns {number} angle between 0-360 degrees\n */\nfunction convertAngleTo360(alpha: number) {\n let beta = alpha % 360;\n if (beta < 0) {\n beta += 360;\n }\n return beta;\n}\n\nexport { lineArc };\nexport default lineArc;\n"],"mappings":";AACA,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAC5B,SAAgB,kBAAyB;AA0BzC,SAAS,QACP,QACA,QACA,UACA,UACA,UAGI,CAAC,GACgB;AAErB,QAAM,QAAQ,QAAQ,SAAS;AAE/B,QAAM,SAAS,kBAAkB,QAAQ;AACzC,QAAM,SAAS,kBAAkB,QAAQ;AACzC,QAAM,aACJ,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,SAAS,YACtC,OAAO,aACP,CAAC;AAGP,MAAI,WAAW,QAAQ;AACrB,WAAO;AAAA,MACL,OAAO,QAAQ,QAAQ,OAAO,EAAE,SAAS,YAAY,CAAC;AAAA,MACtD;AAAA,IACF;AAAA,EACF;AACA,QAAM,iBAAiB;AACvB,QAAM,eAAe,SAAS,SAAS,SAAS,SAAS;AAEzD,MAAI,QAAQ;AACZ,QAAM,cAAc,CAAC;AACrB,MAAI,IAAI;AAER,QAAM,WAAW,eAAe,kBAAkB;AAGlD,SAAO,SAAS,cAAc;AAC5B,gBAAY;AAAA,MACV,YAAY,QAAQ,QAAQ,OAAO,OAAO,EAAE,SAAS;AAAA,IACvD;AACA;AACA,YAAQ,iBAAiB,IAAI;AAAA,EAC/B;AACA,SAAO,WAAW,aAAa,UAAU;AAC3C;AAUA,SAAS,kBAAkB,OAAe;AACxC,MAAI,OAAO,QAAQ;AACnB,MAAI,OAAO,GAAG;AACZ,YAAQ;AAAA,EACV;AACA,SAAO;AACT;AAGA,IAAO,wBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/line-arc",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0-alpha.7+0ce6ecca0",
|
|
4
4
|
"description": "turf line-arc module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,46 +20,53 @@
|
|
|
20
20
|
"turf",
|
|
21
21
|
"gif"
|
|
22
22
|
],
|
|
23
|
-
"
|
|
24
|
-
"
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "dist/cjs/index.cjs",
|
|
25
|
+
"module": "dist/esm/index.js",
|
|
26
|
+
"types": "dist/esm/index.d.ts",
|
|
25
27
|
"exports": {
|
|
26
28
|
"./package.json": "./package.json",
|
|
27
29
|
".": {
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/esm/index.d.ts",
|
|
32
|
+
"default": "./dist/esm/index.js"
|
|
33
|
+
},
|
|
34
|
+
"require": {
|
|
35
|
+
"types": "./dist/cjs/index.d.cts",
|
|
36
|
+
"default": "./dist/cjs/index.cjs"
|
|
37
|
+
}
|
|
31
38
|
}
|
|
32
39
|
},
|
|
33
|
-
"types": "dist/js/index.d.ts",
|
|
34
40
|
"sideEffects": false,
|
|
35
41
|
"files": [
|
|
36
42
|
"dist"
|
|
37
43
|
],
|
|
38
44
|
"scripts": {
|
|
39
|
-
"bench": "tsx bench.
|
|
40
|
-
"build": "
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"test": "
|
|
45
|
-
"test:tape": "tsx test.js",
|
|
46
|
-
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
45
|
+
"bench": "tsx bench.ts",
|
|
46
|
+
"build": "tsup --config ../../tsup.config.ts",
|
|
47
|
+
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
48
|
+
"test": "npm-run-all --npm-path npm test:*",
|
|
49
|
+
"test:tape": "tsx test.ts",
|
|
50
|
+
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
49
|
-
"@turf/truncate": "^7.
|
|
50
|
-
"benchmark": "
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
53
|
+
"@turf/truncate": "^7.1.0-alpha.7+0ce6ecca0",
|
|
54
|
+
"@types/benchmark": "^2.1.5",
|
|
55
|
+
"@types/tape": "^4.2.32",
|
|
56
|
+
"benchmark": "^2.1.4",
|
|
57
|
+
"load-json-file": "^7.0.1",
|
|
58
|
+
"npm-run-all": "^4.1.5",
|
|
59
|
+
"tape": "^5.7.2",
|
|
60
|
+
"tsup": "^8.0.1",
|
|
61
|
+
"tsx": "^4.6.2",
|
|
62
|
+
"typescript": "^5.2.2",
|
|
63
|
+
"write-json-file": "^5.0.0"
|
|
57
64
|
},
|
|
58
65
|
"dependencies": {
|
|
59
|
-
"@turf/circle": "^7.
|
|
60
|
-
"@turf/destination": "^7.
|
|
61
|
-
"@turf/helpers": "^7.
|
|
62
|
-
"tslib": "^2.
|
|
66
|
+
"@turf/circle": "^7.1.0-alpha.7+0ce6ecca0",
|
|
67
|
+
"@turf/destination": "^7.1.0-alpha.7+0ce6ecca0",
|
|
68
|
+
"@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
|
|
69
|
+
"tslib": "^2.6.2"
|
|
63
70
|
},
|
|
64
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
|
|
65
72
|
}
|
package/dist/es/index.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import circle from "@turf/circle";
|
|
2
|
-
import destination from "@turf/destination";
|
|
3
|
-
import { lineString } from "@turf/helpers";
|
|
4
|
-
/**
|
|
5
|
-
* Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;
|
|
6
|
-
* 0 bearing is North of center point, positive clockwise.
|
|
7
|
-
*
|
|
8
|
-
* @name lineArc
|
|
9
|
-
* @param {Coord} center center point
|
|
10
|
-
* @param {number} radius radius of the circle
|
|
11
|
-
* @param {number} bearing1 angle, in decimal degrees, of the first radius of the arc
|
|
12
|
-
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc
|
|
13
|
-
* @param {Object} [options={}] Optional parameters
|
|
14
|
-
* @param {number} [options.steps=64] number of steps
|
|
15
|
-
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
|
|
16
|
-
* @returns {Feature<LineString>} line arc
|
|
17
|
-
* @example
|
|
18
|
-
* var center = turf.point([-75, 40]);
|
|
19
|
-
* var radius = 5;
|
|
20
|
-
* var bearing1 = 25;
|
|
21
|
-
* var bearing2 = 47;
|
|
22
|
-
*
|
|
23
|
-
* var arc = turf.lineArc(center, radius, bearing1, bearing2);
|
|
24
|
-
*
|
|
25
|
-
* //addToMap
|
|
26
|
-
* var addToMap = [center, arc]
|
|
27
|
-
*/
|
|
28
|
-
export default function lineArc(center, radius, bearing1, bearing2, options = {}) {
|
|
29
|
-
// default params
|
|
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"
|
|
34
|
-
? center.properties
|
|
35
|
-
: {};
|
|
36
|
-
// handle angle parameters
|
|
37
|
-
if (angle1 === angle2) {
|
|
38
|
-
return lineString(circle(center, radius, options).geometry.coordinates[0], properties);
|
|
39
|
-
}
|
|
40
|
-
const arcStartDegree = angle1;
|
|
41
|
-
const arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;
|
|
42
|
-
let alfa = arcStartDegree;
|
|
43
|
-
const coordinates = [];
|
|
44
|
-
let i = 0;
|
|
45
|
-
while (alfa < arcEndDegree) {
|
|
46
|
-
coordinates.push(destination(center, radius, alfa, options).geometry.coordinates);
|
|
47
|
-
i++;
|
|
48
|
-
alfa = arcStartDegree + (i * 360) / steps;
|
|
49
|
-
}
|
|
50
|
-
if (alfa >= arcEndDegree) {
|
|
51
|
-
coordinates.push(destination(center, radius, arcEndDegree, options).geometry.coordinates);
|
|
52
|
-
}
|
|
53
|
-
return lineString(coordinates, properties);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Takes any angle in degrees
|
|
57
|
-
* and returns a valid angle between 0-360 degrees
|
|
58
|
-
*
|
|
59
|
-
* @private
|
|
60
|
-
* @param {number} alfa angle between -180-180 degrees
|
|
61
|
-
* @returns {number} angle between 0-360 degrees
|
|
62
|
-
*/
|
|
63
|
-
function convertAngleTo360(alfa) {
|
|
64
|
-
let beta = alfa % 360;
|
|
65
|
-
if (beta < 0) {
|
|
66
|
-
beta += 360;
|
|
67
|
-
}
|
|
68
|
-
return beta;
|
|
69
|
-
}
|
package/dist/es/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module"}
|
package/dist/js/index.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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");
|
|
7
|
-
/**
|
|
8
|
-
* Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;
|
|
9
|
-
* 0 bearing is North of center point, positive clockwise.
|
|
10
|
-
*
|
|
11
|
-
* @name lineArc
|
|
12
|
-
* @param {Coord} center center point
|
|
13
|
-
* @param {number} radius radius of the circle
|
|
14
|
-
* @param {number} bearing1 angle, in decimal degrees, of the first radius of the arc
|
|
15
|
-
* @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc
|
|
16
|
-
* @param {Object} [options={}] Optional parameters
|
|
17
|
-
* @param {number} [options.steps=64] number of steps
|
|
18
|
-
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
|
|
19
|
-
* @returns {Feature<LineString>} line arc
|
|
20
|
-
* @example
|
|
21
|
-
* var center = turf.point([-75, 40]);
|
|
22
|
-
* var radius = 5;
|
|
23
|
-
* var bearing1 = 25;
|
|
24
|
-
* var bearing2 = 47;
|
|
25
|
-
*
|
|
26
|
-
* var arc = turf.lineArc(center, radius, bearing1, bearing2);
|
|
27
|
-
*
|
|
28
|
-
* //addToMap
|
|
29
|
-
* var addToMap = [center, arc]
|
|
30
|
-
*/
|
|
31
|
-
function lineArc(center, radius, bearing1, bearing2, options = {}) {
|
|
32
|
-
// default params
|
|
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"
|
|
37
|
-
? center.properties
|
|
38
|
-
: {};
|
|
39
|
-
// handle angle parameters
|
|
40
|
-
if (angle1 === angle2) {
|
|
41
|
-
return helpers_1.lineString(circle_1.default(center, radius, options).geometry.coordinates[0], properties);
|
|
42
|
-
}
|
|
43
|
-
const arcStartDegree = angle1;
|
|
44
|
-
const arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;
|
|
45
|
-
let alfa = arcStartDegree;
|
|
46
|
-
const coordinates = [];
|
|
47
|
-
let i = 0;
|
|
48
|
-
while (alfa < arcEndDegree) {
|
|
49
|
-
coordinates.push(destination_1.default(center, radius, alfa, options).geometry.coordinates);
|
|
50
|
-
i++;
|
|
51
|
-
alfa = arcStartDegree + (i * 360) / steps;
|
|
52
|
-
}
|
|
53
|
-
if (alfa >= arcEndDegree) {
|
|
54
|
-
coordinates.push(destination_1.default(center, radius, arcEndDegree, options).geometry.coordinates);
|
|
55
|
-
}
|
|
56
|
-
return helpers_1.lineString(coordinates, properties);
|
|
57
|
-
}
|
|
58
|
-
exports.default = lineArc;
|
|
59
|
-
/**
|
|
60
|
-
* Takes any angle in degrees
|
|
61
|
-
* and returns a valid angle between 0-360 degrees
|
|
62
|
-
*
|
|
63
|
-
* @private
|
|
64
|
-
* @param {number} alfa angle between -180-180 degrees
|
|
65
|
-
* @returns {number} angle between 0-360 degrees
|
|
66
|
-
*/
|
|
67
|
-
function convertAngleTo360(alfa) {
|
|
68
|
-
let beta = alfa % 360;
|
|
69
|
-
if (beta < 0) {
|
|
70
|
-
beta += 360;
|
|
71
|
-
}
|
|
72
|
-
return beta;
|
|
73
|
-
}
|