@turf/line-chunk 7.2.0 → 7.3.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 +2 -2
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ If the line is shorter than the segment length then the original line is returne
|
|
|
13
13
|
* `segmentLength` **[number][6]** how long to make each segment
|
|
14
14
|
* `options` **[Object][7]** Optional parameters (optional, default `{}`)
|
|
15
15
|
|
|
16
|
-
* `options.units` **
|
|
16
|
+
* `options.units` **Units** Supports all valid Turf [Units][8] (optional, default `'kilometers'`)
|
|
17
17
|
* `options.reverse` **[boolean][9]** reverses coordinates to start the first chunked segment at the end (optional, default `false`)
|
|
18
18
|
|
|
19
19
|
### Examples
|
|
@@ -43,7 +43,7 @@ Returns **[FeatureCollection][2]<[LineString][1]>** collection of line segments
|
|
|
43
43
|
|
|
44
44
|
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
45
45
|
|
|
46
|
-
[8]: https://
|
|
46
|
+
[8]: https://turfjs.org/docs/api/types/Units
|
|
47
47
|
|
|
48
48
|
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
49
49
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -38,9 +38,9 @@ function sliceLineSegments(line, segmentLength, units, callback) {
|
|
|
38
38
|
callback(outline, i);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
var
|
|
41
|
+
var index_default = lineChunk;
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
exports.default =
|
|
45
|
+
exports.default = index_default; exports.lineChunk = lineChunk;
|
|
46
46
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @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AA;AAAA,MACrB,EAAE,MAAa;AAAA,IACjB,CAAA;AACA,IAAA,QAAA,CAAS,OAAA,EAAS,CAAC,CAAA;AAAA,EACrB;AACF;AAGA,IAAO,cAAA,EAAQ,SAAA;AD9Cf;AACE;AACA;AACF,+DAAC","file":"/home/runner/work/turf/turf/packages/turf-line-chunk/dist/cjs/index.cjs","sourcesContent":[null,"import { length } from \"@turf/length\";\nimport { lineSliceAlong } from \"@turf/line-slice-along\";\nimport { flattenEach } from \"@turf/meta\";\nimport { featureCollection, isObject } from \"@turf/helpers\";\n\n/**\n * Divides a {@link LineString} into chunks of a specified length.\n * If the line is shorter than the segment length then the original line is returned.\n *\n * @function\n * @param {FeatureCollection|Geometry|Feature<LineString|MultiLineString>} geojson the lines to split\n * @param {number} segmentLength how long to make each segment\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}\n * @param {boolean} [options.reverse=false] reverses coordinates to start the first chunked segment at the end\n * @returns {FeatureCollection<LineString>} collection of line segments\n * @example\n * var line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]);\n *\n * var chunk = turf.lineChunk(line, 15, {units: 'miles'});\n *\n * //addToMap\n * var addToMap = [chunk];\n */\nfunction lineChunk(geojson, segmentLength, options) {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var units = options.units;\n var reverse = options.reverse;\n\n // Validation\n if (!geojson) throw new Error(\"geojson is required\");\n if (segmentLength <= 0)\n throw new Error(\"segmentLength must be greater than 0\");\n\n // Container\n var results = [];\n\n // Flatten each feature to simple LineString\n flattenEach(geojson, function (feature) {\n // reverses coordinates to start the first chunked segment at the end\n if (reverse)\n feature.geometry.coordinates = feature.geometry.coordinates.reverse();\n\n sliceLineSegments(feature, segmentLength, units, function (segment) {\n results.push(segment);\n });\n });\n return featureCollection(results);\n}\n\n/**\n * Slice Line Segments\n *\n * @private\n * @param {Feature<LineString>} line GeoJSON LineString\n * @param {number} segmentLength how long to make each segment\n * @param {Units}[units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}\n * @param {Function} callback iterate over sliced line segments\n * @returns {void}\n */\nfunction sliceLineSegments(line, segmentLength, units, callback) {\n var lineLength = length(line, { units: units });\n\n // If the line is shorter than the segment length then the orginal line is returned.\n if (lineLength <= segmentLength) return callback(line);\n\n var numberOfSegments = lineLength / segmentLength;\n\n // If numberOfSegments is integer, no need to plus 1\n if (!Number.isInteger(numberOfSegments)) {\n numberOfSegments = Math.floor(numberOfSegments) + 1;\n }\n\n for (var i = 0; i < numberOfSegments; i++) {\n var outline = lineSliceAlong(\n line,\n segmentLength * i,\n segmentLength * (i + 1),\n { units: units }\n );\n callback(outline, i);\n }\n}\n\nexport { lineChunk };\nexport default lineChunk;\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -38,9 +38,9 @@ function sliceLineSegments(line, segmentLength, units, callback) {
|
|
|
38
38
|
callback(outline, i);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
var
|
|
41
|
+
var index_default = lineChunk;
|
|
42
42
|
export {
|
|
43
|
-
|
|
43
|
+
index_default as default,
|
|
44
44
|
lineChunk
|
|
45
45
|
};
|
|
46
46
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.js"],"sourcesContent":["import { length } from \"@turf/length\";\nimport { lineSliceAlong } from \"@turf/line-slice-along\";\nimport { flattenEach } from \"@turf/meta\";\nimport { featureCollection, isObject } from \"@turf/helpers\";\n\n/**\n * Divides a {@link LineString} into chunks of a specified length.\n * If the line is shorter than the segment length then the original line is returned.\n *\n * @function\n * @param {FeatureCollection|Geometry|Feature<LineString|MultiLineString>} geojson the lines to split\n * @param {number} segmentLength how long to make each segment\n * @param {Object} [options={}] Optional parameters\n * @param {
|
|
1
|
+
{"version":3,"sources":["../../index.js"],"sourcesContent":["import { length } from \"@turf/length\";\nimport { lineSliceAlong } from \"@turf/line-slice-along\";\nimport { flattenEach } from \"@turf/meta\";\nimport { featureCollection, isObject } from \"@turf/helpers\";\n\n/**\n * Divides a {@link LineString} into chunks of a specified length.\n * If the line is shorter than the segment length then the original line is returned.\n *\n * @function\n * @param {FeatureCollection|Geometry|Feature<LineString|MultiLineString>} geojson the lines to split\n * @param {number} segmentLength how long to make each segment\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}\n * @param {boolean} [options.reverse=false] reverses coordinates to start the first chunked segment at the end\n * @returns {FeatureCollection<LineString>} collection of line segments\n * @example\n * var line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]);\n *\n * var chunk = turf.lineChunk(line, 15, {units: 'miles'});\n *\n * //addToMap\n * var addToMap = [chunk];\n */\nfunction lineChunk(geojson, segmentLength, options) {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var units = options.units;\n var reverse = options.reverse;\n\n // Validation\n if (!geojson) throw new Error(\"geojson is required\");\n if (segmentLength <= 0)\n throw new Error(\"segmentLength must be greater than 0\");\n\n // Container\n var results = [];\n\n // Flatten each feature to simple LineString\n flattenEach(geojson, function (feature) {\n // reverses coordinates to start the first chunked segment at the end\n if (reverse)\n feature.geometry.coordinates = feature.geometry.coordinates.reverse();\n\n sliceLineSegments(feature, segmentLength, units, function (segment) {\n results.push(segment);\n });\n });\n return featureCollection(results);\n}\n\n/**\n * Slice Line Segments\n *\n * @private\n * @param {Feature<LineString>} line GeoJSON LineString\n * @param {number} segmentLength how long to make each segment\n * @param {Units}[units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}\n * @param {Function} callback iterate over sliced line segments\n * @returns {void}\n */\nfunction sliceLineSegments(line, segmentLength, units, callback) {\n var lineLength = length(line, { units: units });\n\n // If the line is shorter than the segment length then the orginal line is returned.\n if (lineLength <= segmentLength) return callback(line);\n\n var numberOfSegments = lineLength / segmentLength;\n\n // If numberOfSegments is integer, no need to plus 1\n if (!Number.isInteger(numberOfSegments)) {\n numberOfSegments = Math.floor(numberOfSegments) + 1;\n }\n\n for (var i = 0; i < numberOfSegments; i++) {\n var outline = lineSliceAlong(\n line,\n segmentLength * i,\n segmentLength * (i + 1),\n { units: units }\n );\n callback(outline, i);\n }\n}\n\nexport { lineChunk };\nexport default lineChunk;\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,gBAAgB;AAqB5C,SAAS,UAAU,SAAS,eAAe,SAAS;AAElD,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO,EAAG,OAAM,IAAI,MAAM,oBAAoB;AAC5D,MAAI,QAAQ,QAAQ;AACpB,MAAI,UAAU,QAAQ;AAGtB,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,qBAAqB;AACnD,MAAI,iBAAiB;AACnB,UAAM,IAAI,MAAM,sCAAsC;AAGxD,MAAI,UAAU,CAAC;AAGf,cAAY,SAAS,SAAU,SAAS;AAEtC,QAAI;AACF,cAAQ,SAAS,cAAc,QAAQ,SAAS,YAAY,QAAQ;AAEtE,sBAAkB,SAAS,eAAe,OAAO,SAAU,SAAS;AAClE,cAAQ,KAAK,OAAO;AAAA,IACtB,CAAC;AAAA,EACH,CAAC;AACD,SAAO,kBAAkB,OAAO;AAClC;AAYA,SAAS,kBAAkB,MAAM,eAAe,OAAO,UAAU;AAC/D,MAAI,aAAa,OAAO,MAAM,EAAE,MAAa,CAAC;AAG9C,MAAI,cAAc,cAAe,QAAO,SAAS,IAAI;AAErD,MAAI,mBAAmB,aAAa;AAGpC,MAAI,CAAC,OAAO,UAAU,gBAAgB,GAAG;AACvC,uBAAmB,KAAK,MAAM,gBAAgB,IAAI;AAAA,EACpD;AAEA,WAAS,IAAI,GAAG,IAAI,kBAAkB,KAAK;AACzC,QAAI,UAAU;AAAA,MACZ;AAAA,MACA,gBAAgB;AAAA,MAChB,iBAAiB,IAAI;AAAA,MACrB,EAAE,MAAa;AAAA,IACjB;AACA,aAAS,SAAS,CAAC;AAAA,EACrB;AACF;AAGA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/line-chunk",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.3.0",
|
|
4
|
+
"description": "Divides a LineString into chunks of a specified length.",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Tim Channell <@tcql>",
|
|
@@ -59,23 +59,23 @@
|
|
|
59
59
|
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@turf/truncate": "
|
|
62
|
+
"@turf/truncate": "7.3.0",
|
|
63
63
|
"@types/benchmark": "^2.1.5",
|
|
64
|
-
"@types/tape": "^
|
|
64
|
+
"@types/tape": "^5.8.1",
|
|
65
65
|
"benchmark": "^2.1.4",
|
|
66
66
|
"load-json-file": "^7.0.1",
|
|
67
67
|
"npm-run-all": "^4.1.5",
|
|
68
68
|
"tape": "^5.9.0",
|
|
69
|
-
"tsup": "^8.
|
|
70
|
-
"tsx": "^4.19.
|
|
71
|
-
"write-json-file": "^
|
|
69
|
+
"tsup": "^8.4.0",
|
|
70
|
+
"tsx": "^4.19.4",
|
|
71
|
+
"write-json-file": "^6.0.0"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@turf/helpers": "
|
|
75
|
-
"@turf/length": "
|
|
76
|
-
"@turf/line-slice-along": "
|
|
77
|
-
"@turf/meta": "
|
|
74
|
+
"@turf/helpers": "7.3.0",
|
|
75
|
+
"@turf/length": "7.3.0",
|
|
76
|
+
"@turf/line-slice-along": "7.3.0",
|
|
77
|
+
"@turf/meta": "7.3.0",
|
|
78
78
|
"@types/geojson": "^7946.0.10"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "9f58a103e8f9a587ab640307ed03ba5233913ddd"
|
|
81
81
|
}
|