@turf/line-arc 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 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
- **Parameters**
10
+ ### Parameters
11
11
 
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 `{}`)
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
- **Examples**
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]<[LineString][6]>** line arc
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
- var steps = options.steps || 64;
32
- var angle1 = convertAngleTo360(bearing1);
33
- var angle2 = convertAngleTo360(bearing2);
34
- var properties = !Array.isArray(center) && center.type === "Feature"
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
- var arcStartDegree = angle1;
42
- var arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;
43
- var alfa = arcStartDegree;
44
- var coordinates = [];
45
- var i = 0;
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 > arcEndDegree) {
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
- var beta = alfa % 360;
64
+ let beta = alfa % 360;
66
65
  if (beta < 0) {
67
66
  beta += 360;
68
67
  }
@@ -1,4 +1,5 @@
1
- import { Coord, Feature, LineString, Units } from "@turf/helpers";
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
- var circle_1 = __importDefault(require("@turf/circle"));
7
- var destination_1 = __importDefault(require("@turf/destination"));
8
- var helpers_1 = require("@turf/helpers");
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
- var steps = options.steps || 64;
37
- var angle1 = convertAngleTo360(bearing1);
38
- var angle2 = convertAngleTo360(bearing2);
39
- var properties = !Array.isArray(center) && center.type === "Feature"
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
- var arcStartDegree = angle1;
47
- var arcEndDegree = angle1 < angle2 ? angle2 : angle2 + 360;
48
- var alfa = arcStartDegree;
49
- var coordinates = [];
50
- var i = 0;
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 > arcEndDegree) {
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
- var beta = alfa % 360;
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": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf line-arc module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -12,6 +12,7 @@
12
12
  "type": "git",
13
13
  "url": "git://github.com/Turfjs/turf.git"
14
14
  },
15
+ "funding": "https://opencollective.com/turf",
15
16
  "publishConfig": {
16
17
  "access": "public"
17
18
  },
@@ -41,10 +42,10 @@
41
42
  "docs": "node ../../scripts/generate-readmes",
42
43
  "test": "npm-run-all test:*",
43
44
  "test:tape": "ts-node -r esm test.js",
44
- "test:types": "tsc --esModuleInterop --noEmit types.ts"
45
+ "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
45
46
  },
46
47
  "devDependencies": {
47
- "@turf/truncate": "^6.4.0",
48
+ "@turf/truncate": "^7.0.0-alpha.0",
48
49
  "benchmark": "*",
49
50
  "load-json-file": "*",
50
51
  "npm-run-all": "*",
@@ -54,9 +55,10 @@
54
55
  "write-json-file": "*"
55
56
  },
56
57
  "dependencies": {
57
- "@turf/circle": "^6.4.0",
58
- "@turf/destination": "^6.4.0",
59
- "@turf/helpers": "^6.4.0"
58
+ "@turf/circle": "^7.0.0-alpha.0",
59
+ "@turf/destination": "^7.0.0-alpha.0",
60
+ "@turf/helpers": "^7.0.0-alpha.0",
61
+ "tslib": "^2.3.0"
60
62
  },
61
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
63
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
62
64
  }