@turf/line-slice-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 +9 -8
- package/dist/es/index.js +1 -1
- package/dist/js/index.js +15 -10
- package/index.d.ts +2 -1
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -10,15 +10,16 @@ and returns a subsection of the line in-between those points.
|
|
|
10
10
|
|
|
11
11
|
This can be useful for extracting only the part of a route between two distances.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
|
|
15
|
+
* `line` **([Feature][3]<[LineString][4]> | [LineString][4])** input line
|
|
16
|
+
* `startDist` **[number][5]** distance along the line to starting point
|
|
17
|
+
* `stopDist` **[number][5]** distance along the line to ending point
|
|
18
|
+
* `options` **[Object][6]** Optional parameters (optional, default `{}`)
|
|
20
19
|
|
|
21
|
-
**
|
|
20
|
+
* `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
|
|
21
|
+
|
|
22
|
+
### Examples
|
|
22
23
|
|
|
23
24
|
```javascript
|
|
24
25
|
var line = turf.lineString([[7, 45], [9, 45], [14, 40], [14, 41]]);
|
|
@@ -30,7 +31,7 @@ var sliced = turf.lineSliceAlong(line, start, stop, {units: 'miles'});
|
|
|
30
31
|
var addToMap = [line, start, stop, sliced]
|
|
31
32
|
```
|
|
32
33
|
|
|
33
|
-
Returns **[Feature][3]
|
|
34
|
+
Returns **[Feature][3]<[LineString][4]>** sliced line
|
|
34
35
|
|
|
35
36
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
36
37
|
|
package/dist/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import bearing from '@turf/bearing';
|
|
2
2
|
import distance from '@turf/distance';
|
|
3
3
|
import destination from '@turf/destination';
|
|
4
|
-
import {
|
|
4
|
+
import { isObject, lineString } from '@turf/helpers';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Takes a {@link LineString|line}, a specified distance along the line to a start {@link Point},
|
package/dist/js/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var distance = _interopDefault(require('@turf/distance'));
|
|
7
|
-
var destination = _interopDefault(require('@turf/destination'));
|
|
3
|
+
var bearing = require('@turf/bearing');
|
|
4
|
+
var distance = require('@turf/distance');
|
|
5
|
+
var destination = require('@turf/destination');
|
|
8
6
|
var helpers = require('@turf/helpers');
|
|
9
7
|
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var bearing__default = /*#__PURE__*/_interopDefaultLegacy(bearing);
|
|
11
|
+
var distance__default = /*#__PURE__*/_interopDefaultLegacy(distance);
|
|
12
|
+
var destination__default = /*#__PURE__*/_interopDefaultLegacy(destination);
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Takes a {@link LineString|line}, a specified distance along the line to a start {@link Point},
|
|
12
16
|
* and a specified distance along the line to a stop point
|
|
@@ -53,8 +57,8 @@ function lineSliceAlong(line, startDist, stopDist, options) {
|
|
|
53
57
|
slice.push(coords[i]);
|
|
54
58
|
return helpers.lineString(slice);
|
|
55
59
|
}
|
|
56
|
-
direction =
|
|
57
|
-
interpolated =
|
|
60
|
+
direction = bearing__default['default'](coords[i], coords[i - 1]) - 180;
|
|
61
|
+
interpolated = destination__default['default'](coords[i], overshot, direction, options);
|
|
58
62
|
slice.push(interpolated.geometry.coordinates);
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -64,8 +68,8 @@ function lineSliceAlong(line, startDist, stopDist, options) {
|
|
|
64
68
|
slice.push(coords[i]);
|
|
65
69
|
return helpers.lineString(slice);
|
|
66
70
|
}
|
|
67
|
-
direction =
|
|
68
|
-
interpolated =
|
|
71
|
+
direction = bearing__default['default'](coords[i], coords[i - 1]) - 180;
|
|
72
|
+
interpolated = destination__default['default'](coords[i], overshot, direction, options);
|
|
69
73
|
slice.push(interpolated.geometry.coordinates);
|
|
70
74
|
return helpers.lineString(slice);
|
|
71
75
|
}
|
|
@@ -78,7 +82,7 @@ function lineSliceAlong(line, startDist, stopDist, options) {
|
|
|
78
82
|
return helpers.lineString(slice);
|
|
79
83
|
}
|
|
80
84
|
|
|
81
|
-
travelled +=
|
|
85
|
+
travelled += distance__default['default'](coords[i], coords[i + 1], options);
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
if (travelled < startDist && coords.length === origCoordsLength)
|
|
@@ -89,3 +93,4 @@ function lineSliceAlong(line, startDist, stopDist, options) {
|
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
module.exports = lineSliceAlong;
|
|
96
|
+
module.exports.default = lineSliceAlong;
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/line-slice-along",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf line-slice-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
|
},
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"test:tape": "node -r esm test.js"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@turf/along": "^
|
|
47
|
+
"@turf/along": "^7.0.0-alpha.0",
|
|
47
48
|
"benchmark": "*",
|
|
48
49
|
"load-json-file": "*",
|
|
49
50
|
"npm-run-all": "*",
|
|
@@ -51,10 +52,10 @@
|
|
|
51
52
|
"tape": "*"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"@turf/bearing": "^
|
|
55
|
-
"@turf/destination": "^
|
|
56
|
-
"@turf/distance": "^
|
|
57
|
-
"@turf/helpers": "^
|
|
55
|
+
"@turf/bearing": "^7.0.0-alpha.0",
|
|
56
|
+
"@turf/destination": "^7.0.0-alpha.0",
|
|
57
|
+
"@turf/distance": "^7.0.0-alpha.0",
|
|
58
|
+
"@turf/helpers": "^7.0.0-alpha.0"
|
|
58
59
|
},
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
60
61
|
}
|