@turf/along 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
@@ -6,14 +6,15 @@
6
6
 
7
7
  Takes a [LineString][1] and returns a [Point][2] at a specified distance along the line.
8
8
 
9
- **Parameters**
9
+ ### Parameters
10
10
 
11
- - `line` **[Feature][3]<[LineString][4]>** input line
12
- - `distance` **[number][5]** distance along the line
13
- - `options` **[Object][6]?** Optional parameters
14
- - `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`)
11
+ * `line` **[Feature][3]<[LineString][4]>** input line
12
+ * `distance` **[number][5]** distance along the line
13
+ * `options` **[Object][6]?** Optional parameters
15
14
 
16
- **Examples**
15
+ * `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`)
16
+
17
+ ### Examples
17
18
 
18
19
  ```javascript
19
20
  var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);
@@ -25,7 +26,7 @@ var along = turf.along(line, 200, options);
25
26
  var addToMap = [along, line]
26
27
  ```
27
28
 
28
- Returns **[Feature][3]&lt;[Point][8]>** Point `distance` `units` along the line
29
+ Returns **[Feature][3]<[Point][8]>** Point `distance` `units` along the line
29
30
 
30
31
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
31
32
 
package/dist/es/index.js CHANGED
@@ -21,24 +21,23 @@ import { getGeom } from "@turf/invariant";
21
21
  * //addToMap
22
22
  * var addToMap = [along, line]
23
23
  */
24
- export default function along(line, distance, options) {
25
- if (options === void 0) { options = {}; }
24
+ export default function along(line, distance, options = {}) {
26
25
  // Get Coords
27
- var geom = getGeom(line);
28
- var coords = geom.coordinates;
29
- var travelled = 0;
30
- for (var i = 0; i < coords.length; i++) {
26
+ const geom = getGeom(line);
27
+ const coords = geom.coordinates;
28
+ let travelled = 0;
29
+ for (let i = 0; i < coords.length; i++) {
31
30
  if (distance >= travelled && i === coords.length - 1) {
32
31
  break;
33
32
  }
34
33
  else if (travelled >= distance) {
35
- var overshot = distance - travelled;
34
+ const overshot = distance - travelled;
36
35
  if (!overshot) {
37
36
  return point(coords[i]);
38
37
  }
39
38
  else {
40
- var direction = bearing(coords[i], coords[i - 1]) - 180;
41
- var interpolated = destination(coords[i], overshot, direction, options);
39
+ const direction = bearing(coords[i], coords[i - 1]) - 180;
40
+ const interpolated = destination(coords[i], overshot, direction, options);
42
41
  return interpolated;
43
42
  }
44
43
  }
@@ -1,4 +1,5 @@
1
- import { Feature, LineString, Point, Units } from "@turf/helpers";
1
+ import { Feature, LineString, Point } from "geojson";
2
+ import { Units } from "@turf/helpers";
2
3
  /**
3
4
  * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.
4
5
  *
package/dist/js/index.js CHANGED
@@ -1,13 +1,11 @@
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 bearing_1 = __importDefault(require("@turf/bearing"));
7
- var destination_1 = __importDefault(require("@turf/destination"));
8
- var distance_1 = __importDefault(require("@turf/distance"));
9
- var helpers_1 = require("@turf/helpers");
10
- var invariant_1 = require("@turf/invariant");
3
+ const tslib_1 = require("tslib");
4
+ const bearing_1 = tslib_1.__importDefault(require("@turf/bearing"));
5
+ const destination_1 = tslib_1.__importDefault(require("@turf/destination"));
6
+ const distance_1 = tslib_1.__importDefault(require("@turf/distance"));
7
+ const helpers_1 = require("@turf/helpers");
8
+ const invariant_1 = require("@turf/invariant");
11
9
  /**
12
10
  * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.
13
11
  *
@@ -26,24 +24,23 @@ var invariant_1 = require("@turf/invariant");
26
24
  * //addToMap
27
25
  * var addToMap = [along, line]
28
26
  */
29
- function along(line, distance, options) {
30
- if (options === void 0) { options = {}; }
27
+ function along(line, distance, options = {}) {
31
28
  // Get Coords
32
- var geom = invariant_1.getGeom(line);
33
- var coords = geom.coordinates;
34
- var travelled = 0;
35
- for (var i = 0; i < coords.length; i++) {
29
+ const geom = invariant_1.getGeom(line);
30
+ const coords = geom.coordinates;
31
+ let travelled = 0;
32
+ for (let i = 0; i < coords.length; i++) {
36
33
  if (distance >= travelled && i === coords.length - 1) {
37
34
  break;
38
35
  }
39
36
  else if (travelled >= distance) {
40
- var overshot = distance - travelled;
37
+ const overshot = distance - travelled;
41
38
  if (!overshot) {
42
39
  return helpers_1.point(coords[i]);
43
40
  }
44
41
  else {
45
- var direction = bearing_1.default(coords[i], coords[i - 1]) - 180;
46
- var interpolated = destination_1.default(coords[i], overshot, direction, options);
42
+ const direction = bearing_1.default(coords[i], coords[i - 1]) - 180;
43
+ const interpolated = destination_1.default(coords[i], overshot, direction, options);
47
44
  return interpolated;
48
45
  }
49
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/along",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf along 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
  },
@@ -56,11 +57,12 @@
56
57
  "typescript": "*"
57
58
  },
58
59
  "dependencies": {
59
- "@turf/bearing": "^6.4.0",
60
- "@turf/destination": "^6.4.0",
61
- "@turf/distance": "^6.4.0",
62
- "@turf/helpers": "^6.4.0",
63
- "@turf/invariant": "^6.4.0"
60
+ "@turf/bearing": "^7.0.0-alpha.0",
61
+ "@turf/destination": "^7.0.0-alpha.0",
62
+ "@turf/distance": "^7.0.0-alpha.0",
63
+ "@turf/helpers": "^7.0.0-alpha.0",
64
+ "@turf/invariant": "^7.0.0-alpha.0",
65
+ "tslib": "^2.3.0"
64
66
  },
65
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
67
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
66
68
  }