@turf/line-slice 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 +6 -6
- package/dist/es/index.js +0 -0
- package/dist/js/index.js +8 -5
- package/index.d.ts +2 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -10,13 +10,13 @@ The start & stop points don't need to fall exactly on the line.
|
|
|
10
10
|
|
|
11
11
|
This can be useful for extracting only the part of a route between waypoints.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Parameters
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
* `startPt` **[Coord][3]** starting point
|
|
16
|
+
* `stopPt` **[Coord][3]** stopping point
|
|
17
|
+
* `line` **([Feature][4]<[LineString][5]> | [LineString][5])** line to slice
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
### Examples
|
|
20
20
|
|
|
21
21
|
```javascript
|
|
22
22
|
var line = turf.lineString([
|
|
@@ -36,7 +36,7 @@ var sliced = turf.lineSlice(start, stop, line);
|
|
|
36
36
|
var addToMap = [start, stop, line]
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Returns **[Feature][4]
|
|
39
|
+
Returns **[Feature][4]<[LineString][5]>** sliced line
|
|
40
40
|
|
|
41
41
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
42
42
|
|
package/dist/es/index.js
CHANGED
|
File without changes
|
package/dist/js/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
4
|
-
|
|
5
3
|
var invariant = require('@turf/invariant');
|
|
6
4
|
var helpers = require('@turf/helpers');
|
|
7
|
-
var nearestPointOnLine =
|
|
5
|
+
var nearestPointOnLine = require('@turf/nearest-point-on-line');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var nearestPointOnLine__default = /*#__PURE__*/_interopDefaultLegacy(nearestPointOnLine);
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Takes a {@link LineString|line}, a start {@link Point}, and a stop point
|
|
@@ -41,8 +43,8 @@ function lineSlice(startPt, stopPt, line) {
|
|
|
41
43
|
if (invariant.getType(line) !== "LineString")
|
|
42
44
|
throw new Error("line must be a LineString");
|
|
43
45
|
|
|
44
|
-
var startVertex =
|
|
45
|
-
var stopVertex =
|
|
46
|
+
var startVertex = nearestPointOnLine__default['default'](line, startPt);
|
|
47
|
+
var stopVertex = nearestPointOnLine__default['default'](line, stopPt);
|
|
46
48
|
var ends;
|
|
47
49
|
if (startVertex.properties.index <= stopVertex.properties.index) {
|
|
48
50
|
ends = [startVertex, stopVertex];
|
|
@@ -62,3 +64,4 @@ function lineSlice(startPt, stopPt, line) {
|
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
module.exports = lineSlice;
|
|
67
|
+
module.exports.default = lineSlice;
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/line-slice",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf line-slice 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
|
},
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"test:tape": "node -r esm test.js"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"@turf/truncate": "^
|
|
51
|
+
"@turf/truncate": "^7.0.0-alpha.0",
|
|
51
52
|
"benchmark": "*",
|
|
52
53
|
"load-json-file": "*",
|
|
53
54
|
"npm-run-all": "*",
|
|
@@ -56,9 +57,9 @@
|
|
|
56
57
|
"write-json-file": "*"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"@turf/helpers": "^
|
|
60
|
-
"@turf/invariant": "^
|
|
61
|
-
"@turf/nearest-point-on-line": "^
|
|
60
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
61
|
+
"@turf/invariant": "^7.0.0-alpha.0",
|
|
62
|
+
"@turf/nearest-point-on-line": "^7.0.0-alpha.0"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
64
65
|
}
|