@turf/line-chunk 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 +10 -6
- package/index.d.ts +2 -2
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -7,15 +7,16 @@
|
|
|
7
7
|
Divides a [LineString][1] into chunks of a specified length.
|
|
8
8
|
If the line is shorter than the segment length then the original line is returned.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Parameters
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- `options.units` **[string][9]** units can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
|
|
16
|
-
- `options.reverse` **[boolean][10]** reverses coordinates to start the first chunked segment at the end (optional, default `false`)
|
|
12
|
+
* `geojson` **([FeatureCollection][2] | [Geometry][3] | [Feature][4]<([LineString][5] | [MultiLineString][6])>)** the lines to split
|
|
13
|
+
* `segmentLength` **[number][7]** how long to make each segment
|
|
14
|
+
* `options` **[Object][8]** Optional parameters (optional, default `{}`)
|
|
17
15
|
|
|
18
|
-
**
|
|
16
|
+
* `options.units` **[string][9]** units can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
|
|
17
|
+
* `options.reverse` **[boolean][10]** reverses coordinates to start the first chunked segment at the end (optional, default `false`)
|
|
18
|
+
|
|
19
|
+
### Examples
|
|
19
20
|
|
|
20
21
|
```javascript
|
|
21
22
|
var line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]);
|
|
@@ -26,7 +27,7 @@ var chunk = turf.lineChunk(line, 15, {units: 'miles'});
|
|
|
26
27
|
var addToMap = [chunk];
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
Returns **[FeatureCollection][2]
|
|
30
|
+
Returns **[FeatureCollection][2]<[LineString][5]>** collection of line segments
|
|
30
31
|
|
|
31
32
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
32
33
|
|
package/dist/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import length from '@turf/length';
|
|
2
2
|
import lineSliceAlong from '@turf/line-slice-along';
|
|
3
3
|
import { flattenEach } from '@turf/meta';
|
|
4
|
-
import {
|
|
4
|
+
import { isObject, featureCollection } from '@turf/helpers';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Divides a {@link LineString} into chunks of a specified length.
|
package/dist/js/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var length = _interopDefault(require('@turf/length'));
|
|
6
|
-
var lineSliceAlong = _interopDefault(require('@turf/line-slice-along'));
|
|
3
|
+
var length = require('@turf/length');
|
|
4
|
+
var lineSliceAlong = require('@turf/line-slice-along');
|
|
7
5
|
var meta = require('@turf/meta');
|
|
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 length__default = /*#__PURE__*/_interopDefaultLegacy(length);
|
|
11
|
+
var lineSliceAlong__default = /*#__PURE__*/_interopDefaultLegacy(lineSliceAlong);
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* Divides a {@link LineString} into chunks of a specified length.
|
|
12
15
|
* If the line is shorter than the segment length then the original line is returned.
|
|
@@ -65,7 +68,7 @@ function lineChunk(geojson, segmentLength, options) {
|
|
|
65
68
|
* @returns {void}
|
|
66
69
|
*/
|
|
67
70
|
function sliceLineSegments(line, segmentLength, units, callback) {
|
|
68
|
-
var lineLength =
|
|
71
|
+
var lineLength = length__default['default'](line, { units: units });
|
|
69
72
|
|
|
70
73
|
// If the line is shorter than the segment length then the orginal line is returned.
|
|
71
74
|
if (lineLength <= segmentLength) return callback(line);
|
|
@@ -78,7 +81,7 @@ function sliceLineSegments(line, segmentLength, units, callback) {
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
for (var i = 0; i < numberOfSegments; i++) {
|
|
81
|
-
var outline =
|
|
84
|
+
var outline = lineSliceAlong__default['default'](
|
|
82
85
|
line,
|
|
83
86
|
segmentLength * i,
|
|
84
87
|
segmentLength * (i + 1),
|
|
@@ -89,3 +92,4 @@ function sliceLineSegments(line, segmentLength, units, callback) {
|
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
module.exports = lineChunk;
|
|
95
|
+
module.exports.default = lineChunk;
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/line-chunk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf line-chunk module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git://github.com/Turfjs/turf.git"
|
|
20
20
|
},
|
|
21
|
+
"funding": "https://opencollective.com/turf",
|
|
21
22
|
"publishConfig": {
|
|
22
23
|
"access": "public"
|
|
23
24
|
},
|
|
@@ -49,10 +50,10 @@
|
|
|
49
50
|
"docs": "node ../../scripts/generate-readmes",
|
|
50
51
|
"test": "npm-run-all test:*",
|
|
51
52
|
"test:tape": "node -r esm test.js",
|
|
52
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
53
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@turf/truncate": "^
|
|
56
|
+
"@turf/truncate": "^7.0.0-alpha.0",
|
|
56
57
|
"benchmark": "*",
|
|
57
58
|
"load-json-file": "*",
|
|
58
59
|
"npm-run-all": "*",
|
|
@@ -61,10 +62,10 @@
|
|
|
61
62
|
"write-json-file": "*"
|
|
62
63
|
},
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@turf/helpers": "^
|
|
65
|
-
"@turf/length": "^
|
|
66
|
-
"@turf/line-slice-along": "^
|
|
67
|
-
"@turf/meta": "^
|
|
65
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
66
|
+
"@turf/length": "^7.0.0-alpha.0",
|
|
67
|
+
"@turf/line-slice-along": "^7.0.0-alpha.0",
|
|
68
|
+
"@turf/meta": "^7.0.0-alpha.0"
|
|
68
69
|
},
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
70
71
|
}
|