@turf/line-slice 7.0.0 → 7.1.0-alpha.70

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
@@ -14,7 +14,7 @@ This can be useful for extracting only the part of a route between waypoints.
14
14
 
15
15
  * `startPt` **[Coord][3]** starting point
16
16
  * `stopPt` **[Coord][3]** stopping point
17
- * `line` **([Feature][4]<[LineString][5]> | [LineString][5])** line to slice
17
+ * `line` **([Feature][4]<[LineString][1]> | [LineString][1])** line to slice
18
18
 
19
19
  ### Examples
20
20
 
@@ -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]<[LineString][5]>** sliced line
39
+ Returns **[Feature][4]<[LineString][1]>** sliced line
40
40
 
41
41
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
42
42
 
@@ -46,8 +46,6 @@ Returns **[Feature][4]<[LineString][5]>** sliced line
46
46
 
47
47
  [4]: https://tools.ietf.org/html/rfc7946#section-3.2
48
48
 
49
- [5]: https://tools.ietf.org/html/rfc7946#section-3.1.4
50
-
51
49
  <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
52
50
 
53
51
  ---
@@ -1,7 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // index.js
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.js
5
2
  var _invariant = require('@turf/invariant');
6
3
  var _helpers = require('@turf/helpers');
7
4
  var _nearestpointonline = require('@turf/nearest-point-on-line');
@@ -24,7 +21,6 @@ function lineSlice(startPt, stopPt, line) {
24
21
  clipCoords.push(ends[1].geometry.coordinates);
25
22
  return _helpers.lineString.call(void 0, clipCoords, line.properties);
26
23
  }
27
- __name(lineSlice, "lineSlice");
28
24
  var turf_line_slice_default = lineSlice;
29
25
 
30
26
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.js"],"names":[],"mappings":";;;;AAAA,SAAS,WAAW,eAAe;AACnC,SAAS,cAAc,kBAAkB;AACzC,SAAS,0BAA0B;AA+BnC,SAAS,UAAU,SAAS,QAAQ,MAAM;AAExC,MAAI,SAAS,UAAU,IAAI;AAC3B,MAAI,QAAQ,IAAI,MAAM;AACpB,UAAM,IAAI,MAAM,2BAA2B;AAE7C,MAAI,cAAc,mBAAmB,MAAM,OAAO;AAClD,MAAI,aAAa,mBAAmB,MAAM,MAAM;AAChD,MAAI;AACJ,MAAI,YAAY,WAAW,SAAS,WAAW,WAAW,OAAO;AAC/D,WAAO,CAAC,aAAa,UAAU;AAAA,EACjC,OAAO;AACL,WAAO,CAAC,YAAY,WAAW;AAAA,EACjC;AACA,MAAI,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW;AAC9C,WACM,IAAI,KAAK,CAAC,EAAE,WAAW,QAAQ,GACnC,IAAI,KAAK,CAAC,EAAE,WAAW,QAAQ,GAC/B,KACA;AACA,eAAW,KAAK,OAAO,CAAC,CAAC;AAAA,EAC3B;AACA,aAAW,KAAK,KAAK,CAAC,EAAE,SAAS,WAAW;AAC5C,SAAO,WAAW,YAAY,KAAK,UAAU;AAC/C;AAxBS;AA2BT,IAAO,0BAAQ","sourcesContent":["import { getCoords, getType } from \"@turf/invariant\";\nimport { lineString as linestring } from \"@turf/helpers\";\nimport { nearestPointOnLine } from \"@turf/nearest-point-on-line\";\n\n/**\n * Takes a {@link LineString|line}, a start {@link Point}, and a stop point\n * and returns a subsection of the line in-between those points.\n * The start & stop points don't need to fall exactly on the line.\n *\n * This can be useful for extracting only the part of a route between waypoints.\n *\n * @name lineSlice\n * @param {Coord} startPt starting point\n * @param {Coord} stopPt stopping point\n * @param {Feature<LineString>|LineString} line line to slice\n * @returns {Feature<LineString>} sliced line\n * @example\n * var line = turf.lineString([\n * [-77.031669, 38.878605],\n * [-77.029609, 38.881946],\n * [-77.020339, 38.884084],\n * [-77.025661, 38.885821],\n * [-77.021884, 38.889563],\n * [-77.019824, 38.892368]\n * ]);\n * var start = turf.point([-77.029609, 38.881946]);\n * var stop = turf.point([-77.021884, 38.889563]);\n *\n * var sliced = turf.lineSlice(start, stop, line);\n *\n * //addToMap\n * var addToMap = [start, stop, line]\n */\nfunction lineSlice(startPt, stopPt, line) {\n // Validation\n var coords = getCoords(line);\n if (getType(line) !== \"LineString\")\n throw new Error(\"line must be a LineString\");\n\n var startVertex = nearestPointOnLine(line, startPt);\n var stopVertex = nearestPointOnLine(line, stopPt);\n var ends;\n if (startVertex.properties.index <= stopVertex.properties.index) {\n ends = [startVertex, stopVertex];\n } else {\n ends = [stopVertex, startVertex];\n }\n var clipCoords = [ends[0].geometry.coordinates];\n for (\n var i = ends[0].properties.index + 1;\n i < ends[1].properties.index + 1;\n i++\n ) {\n clipCoords.push(coords[i]);\n }\n clipCoords.push(ends[1].geometry.coordinates);\n return linestring(clipCoords, line.properties);\n}\n\nexport { lineSlice };\nexport default lineSlice;\n"]}
1
+ {"version":3,"sources":["../../index.js"],"names":[],"mappings":";AAAA,SAAS,WAAW,eAAe;AACnC,SAAS,cAAc,kBAAkB;AACzC,SAAS,0BAA0B;AA+BnC,SAAS,UAAU,SAAS,QAAQ,MAAM;AAExC,MAAI,SAAS,UAAU,IAAI;AAC3B,MAAI,QAAQ,IAAI,MAAM;AACpB,UAAM,IAAI,MAAM,2BAA2B;AAE7C,MAAI,cAAc,mBAAmB,MAAM,OAAO;AAClD,MAAI,aAAa,mBAAmB,MAAM,MAAM;AAChD,MAAI;AACJ,MAAI,YAAY,WAAW,SAAS,WAAW,WAAW,OAAO;AAC/D,WAAO,CAAC,aAAa,UAAU;AAAA,EACjC,OAAO;AACL,WAAO,CAAC,YAAY,WAAW;AAAA,EACjC;AACA,MAAI,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW;AAC9C,WACM,IAAI,KAAK,CAAC,EAAE,WAAW,QAAQ,GACnC,IAAI,KAAK,CAAC,EAAE,WAAW,QAAQ,GAC/B,KACA;AACA,eAAW,KAAK,OAAO,CAAC,CAAC;AAAA,EAC3B;AACA,aAAW,KAAK,KAAK,CAAC,EAAE,SAAS,WAAW;AAC5C,SAAO,WAAW,YAAY,KAAK,UAAU;AAC/C;AAGA,IAAO,0BAAQ","sourcesContent":["import { getCoords, getType } from \"@turf/invariant\";\nimport { lineString as linestring } from \"@turf/helpers\";\nimport { nearestPointOnLine } from \"@turf/nearest-point-on-line\";\n\n/**\n * Takes a {@link LineString|line}, a start {@link Point}, and a stop point\n * and returns a subsection of the line in-between those points.\n * The start & stop points don't need to fall exactly on the line.\n *\n * This can be useful for extracting only the part of a route between waypoints.\n *\n * @name lineSlice\n * @param {Coord} startPt starting point\n * @param {Coord} stopPt stopping point\n * @param {Feature<LineString>|LineString} line line to slice\n * @returns {Feature<LineString>} sliced line\n * @example\n * var line = turf.lineString([\n * [-77.031669, 38.878605],\n * [-77.029609, 38.881946],\n * [-77.020339, 38.884084],\n * [-77.025661, 38.885821],\n * [-77.021884, 38.889563],\n * [-77.019824, 38.892368]\n * ]);\n * var start = turf.point([-77.029609, 38.881946]);\n * var stop = turf.point([-77.021884, 38.889563]);\n *\n * var sliced = turf.lineSlice(start, stop, line);\n *\n * //addToMap\n * var addToMap = [start, stop, line]\n */\nfunction lineSlice(startPt, stopPt, line) {\n // Validation\n var coords = getCoords(line);\n if (getType(line) !== \"LineString\")\n throw new Error(\"line must be a LineString\");\n\n var startVertex = nearestPointOnLine(line, startPt);\n var stopVertex = nearestPointOnLine(line, stopPt);\n var ends;\n if (startVertex.properties.index <= stopVertex.properties.index) {\n ends = [startVertex, stopVertex];\n } else {\n ends = [stopVertex, startVertex];\n }\n var clipCoords = [ends[0].geometry.coordinates];\n for (\n var i = ends[0].properties.index + 1;\n i < ends[1].properties.index + 1;\n i++\n ) {\n clipCoords.push(coords[i]);\n }\n clipCoords.push(ends[1].geometry.coordinates);\n return linestring(clipCoords, line.properties);\n}\n\nexport { lineSlice };\nexport default lineSlice;\n"]}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // index.js
5
2
  import { getCoords, getType } from "@turf/invariant";
6
3
  import { lineString as linestring } from "@turf/helpers";
@@ -24,7 +21,6 @@ function lineSlice(startPt, stopPt, line) {
24
21
  clipCoords.push(ends[1].geometry.coordinates);
25
22
  return linestring(clipCoords, line.properties);
26
23
  }
27
- __name(lineSlice, "lineSlice");
28
24
  var turf_line_slice_default = lineSlice;
29
25
  export {
30
26
  turf_line_slice_default as default,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.js"],"sourcesContent":["import { getCoords, getType } from \"@turf/invariant\";\nimport { lineString as linestring } from \"@turf/helpers\";\nimport { nearestPointOnLine } from \"@turf/nearest-point-on-line\";\n\n/**\n * Takes a {@link LineString|line}, a start {@link Point}, and a stop point\n * and returns a subsection of the line in-between those points.\n * The start & stop points don't need to fall exactly on the line.\n *\n * This can be useful for extracting only the part of a route between waypoints.\n *\n * @name lineSlice\n * @param {Coord} startPt starting point\n * @param {Coord} stopPt stopping point\n * @param {Feature<LineString>|LineString} line line to slice\n * @returns {Feature<LineString>} sliced line\n * @example\n * var line = turf.lineString([\n * [-77.031669, 38.878605],\n * [-77.029609, 38.881946],\n * [-77.020339, 38.884084],\n * [-77.025661, 38.885821],\n * [-77.021884, 38.889563],\n * [-77.019824, 38.892368]\n * ]);\n * var start = turf.point([-77.029609, 38.881946]);\n * var stop = turf.point([-77.021884, 38.889563]);\n *\n * var sliced = turf.lineSlice(start, stop, line);\n *\n * //addToMap\n * var addToMap = [start, stop, line]\n */\nfunction lineSlice(startPt, stopPt, line) {\n // Validation\n var coords = getCoords(line);\n if (getType(line) !== \"LineString\")\n throw new Error(\"line must be a LineString\");\n\n var startVertex = nearestPointOnLine(line, startPt);\n var stopVertex = nearestPointOnLine(line, stopPt);\n var ends;\n if (startVertex.properties.index <= stopVertex.properties.index) {\n ends = [startVertex, stopVertex];\n } else {\n ends = [stopVertex, startVertex];\n }\n var clipCoords = [ends[0].geometry.coordinates];\n for (\n var i = ends[0].properties.index + 1;\n i < ends[1].properties.index + 1;\n i++\n ) {\n clipCoords.push(coords[i]);\n }\n clipCoords.push(ends[1].geometry.coordinates);\n return linestring(clipCoords, line.properties);\n}\n\nexport { lineSlice };\nexport default lineSlice;\n"],"mappings":";;;;AAAA,SAAS,WAAW,eAAe;AACnC,SAAS,cAAc,kBAAkB;AACzC,SAAS,0BAA0B;AA+BnC,SAAS,UAAU,SAAS,QAAQ,MAAM;AAExC,MAAI,SAAS,UAAU,IAAI;AAC3B,MAAI,QAAQ,IAAI,MAAM;AACpB,UAAM,IAAI,MAAM,2BAA2B;AAE7C,MAAI,cAAc,mBAAmB,MAAM,OAAO;AAClD,MAAI,aAAa,mBAAmB,MAAM,MAAM;AAChD,MAAI;AACJ,MAAI,YAAY,WAAW,SAAS,WAAW,WAAW,OAAO;AAC/D,WAAO,CAAC,aAAa,UAAU;AAAA,EACjC,OAAO;AACL,WAAO,CAAC,YAAY,WAAW;AAAA,EACjC;AACA,MAAI,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW;AAC9C,WACM,IAAI,KAAK,CAAC,EAAE,WAAW,QAAQ,GACnC,IAAI,KAAK,CAAC,EAAE,WAAW,QAAQ,GAC/B,KACA;AACA,eAAW,KAAK,OAAO,CAAC,CAAC;AAAA,EAC3B;AACA,aAAW,KAAK,KAAK,CAAC,EAAE,SAAS,WAAW;AAC5C,SAAO,WAAW,YAAY,KAAK,UAAU;AAC/C;AAxBS;AA2BT,IAAO,0BAAQ;","names":[]}
1
+ {"version":3,"sources":["../../index.js"],"sourcesContent":["import { getCoords, getType } from \"@turf/invariant\";\nimport { lineString as linestring } from \"@turf/helpers\";\nimport { nearestPointOnLine } from \"@turf/nearest-point-on-line\";\n\n/**\n * Takes a {@link LineString|line}, a start {@link Point}, and a stop point\n * and returns a subsection of the line in-between those points.\n * The start & stop points don't need to fall exactly on the line.\n *\n * This can be useful for extracting only the part of a route between waypoints.\n *\n * @name lineSlice\n * @param {Coord} startPt starting point\n * @param {Coord} stopPt stopping point\n * @param {Feature<LineString>|LineString} line line to slice\n * @returns {Feature<LineString>} sliced line\n * @example\n * var line = turf.lineString([\n * [-77.031669, 38.878605],\n * [-77.029609, 38.881946],\n * [-77.020339, 38.884084],\n * [-77.025661, 38.885821],\n * [-77.021884, 38.889563],\n * [-77.019824, 38.892368]\n * ]);\n * var start = turf.point([-77.029609, 38.881946]);\n * var stop = turf.point([-77.021884, 38.889563]);\n *\n * var sliced = turf.lineSlice(start, stop, line);\n *\n * //addToMap\n * var addToMap = [start, stop, line]\n */\nfunction lineSlice(startPt, stopPt, line) {\n // Validation\n var coords = getCoords(line);\n if (getType(line) !== \"LineString\")\n throw new Error(\"line must be a LineString\");\n\n var startVertex = nearestPointOnLine(line, startPt);\n var stopVertex = nearestPointOnLine(line, stopPt);\n var ends;\n if (startVertex.properties.index <= stopVertex.properties.index) {\n ends = [startVertex, stopVertex];\n } else {\n ends = [stopVertex, startVertex];\n }\n var clipCoords = [ends[0].geometry.coordinates];\n for (\n var i = ends[0].properties.index + 1;\n i < ends[1].properties.index + 1;\n i++\n ) {\n clipCoords.push(coords[i]);\n }\n clipCoords.push(ends[1].geometry.coordinates);\n return linestring(clipCoords, line.properties);\n}\n\nexport { lineSlice };\nexport default lineSlice;\n"],"mappings":";AAAA,SAAS,WAAW,eAAe;AACnC,SAAS,cAAc,kBAAkB;AACzC,SAAS,0BAA0B;AA+BnC,SAAS,UAAU,SAAS,QAAQ,MAAM;AAExC,MAAI,SAAS,UAAU,IAAI;AAC3B,MAAI,QAAQ,IAAI,MAAM;AACpB,UAAM,IAAI,MAAM,2BAA2B;AAE7C,MAAI,cAAc,mBAAmB,MAAM,OAAO;AAClD,MAAI,aAAa,mBAAmB,MAAM,MAAM;AAChD,MAAI;AACJ,MAAI,YAAY,WAAW,SAAS,WAAW,WAAW,OAAO;AAC/D,WAAO,CAAC,aAAa,UAAU;AAAA,EACjC,OAAO;AACL,WAAO,CAAC,YAAY,WAAW;AAAA,EACjC;AACA,MAAI,aAAa,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW;AAC9C,WACM,IAAI,KAAK,CAAC,EAAE,WAAW,QAAQ,GACnC,IAAI,KAAK,CAAC,EAAE,WAAW,QAAQ,GAC/B,KACA;AACA,eAAW,KAAK,OAAO,CAAC,CAAC;AAAA,EAC3B;AACA,aAAW,KAAK,KAAK,CAAC,EAAE,SAAS,WAAW;AAC5C,SAAO,WAAW,YAAY,KAAK,UAAU;AAC/C;AAGA,IAAO,0BAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/line-slice",
3
- "version": "7.0.0",
3
+ "version": "7.1.0-alpha.70+948cdafaf",
4
4
  "description": "turf line-slice module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -54,7 +54,7 @@
54
54
  "test:tape": "tsx test.ts"
55
55
  },
56
56
  "devDependencies": {
57
- "@turf/truncate": "^7.0.0",
57
+ "@turf/truncate": "^7.1.0-alpha.70+948cdafaf",
58
58
  "@types/benchmark": "^2.1.5",
59
59
  "@types/tape": "^4.2.32",
60
60
  "benchmark": "^2.1.4",
@@ -66,9 +66,10 @@
66
66
  "write-json-file": "^5.0.0"
67
67
  },
68
68
  "dependencies": {
69
- "@turf/helpers": "^7.0.0",
70
- "@turf/invariant": "^7.0.0",
71
- "@turf/nearest-point-on-line": "^7.0.0"
69
+ "@turf/helpers": "^7.1.0-alpha.70+948cdafaf",
70
+ "@turf/invariant": "^7.1.0-alpha.70+948cdafaf",
71
+ "@turf/nearest-point-on-line": "^7.1.0-alpha.70+948cdafaf",
72
+ "@types/geojson": "^7946.0.10"
72
73
  },
73
- "gitHead": "3d3a7917025fbabe191dbddbc89754b86f9c7739"
74
+ "gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067"
74
75
  }