@turf/along 7.1.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 CHANGED
@@ -8,11 +8,11 @@ Takes a [LineString][1] and returns a [Point][2] at a specified distance along t
8
8
 
9
9
  ### Parameters
10
10
 
11
- * `line` **[Feature][3]<[LineString][1]>** input line
11
+ * `line` **([Feature][3]<[LineString][1]> | [LineString][1])** input line
12
12
  * `distance` **[number][4]** distance along the line
13
- * `options` **[Object][5]?** Optional parameters
13
+ * `options` **[Object][5]?** Optional parameters (optional, default `{}`)
14
14
 
15
- * `options.units` **[string][6]** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`)
15
+ * `options.units` **Units** Supports all valid Turf [Units][6]. (optional, default `"kilometers"`)
16
16
 
17
17
  ### Examples
18
18
 
@@ -38,7 +38,7 @@ Returns **[Feature][3]<[Point][2]>** Point `distance` `units` along the line
38
38
 
39
39
  [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
40
40
 
41
- [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
41
+ [6]: https://turfjs.org/docs/api/types/Units
42
42
 
43
43
  <!-- 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. -->
44
44
 
@@ -31,9 +31,9 @@ function along(line, distance, options = {}) {
31
31
  }
32
32
  return _helpers.point.call(void 0, coords[coords.length - 1]);
33
33
  }
34
- var turf_along_default = along;
34
+ var index_default = along;
35
35
 
36
36
 
37
37
 
38
- exports.along = along; exports.default = turf_along_default;
38
+ exports.along = along; exports.default = index_default;
39
39
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,YAAY,uBAAuB;AAC5C,SAAS,aAAoB;AAC7B,SAAS,eAAe;AAoBxB,SAAS,MACP,MACA,UACA,UAA6B,CAAC,GACd;AAEhB,QAAM,OAAO,QAAQ,IAAI;AACzB,QAAM,SAAS,KAAK;AACpB,MAAI,YAAY;AAChB,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,QAAI,YAAY,aAAa,MAAM,OAAO,SAAS,GAAG;AACpD;AAAA,IACF,WAAW,aAAa,UAAU;AAChC,YAAM,WAAW,WAAW;AAC5B,UAAI,CAAC,UAAU;AACb,eAAO,MAAM,OAAO,CAAC,CAAC;AAAA,MACxB,OAAO;AACL,cAAM,YAAY,QAAQ,OAAO,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,IAAI;AACtD,cAAM,eAAe;AAAA,UACnB,OAAO,CAAC;AAAA,UACR;AAAA,UACA;AAAA,UACA;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF,OAAO;AACL,mBAAa,gBAAgB,OAAO,CAAC,GAAG,OAAO,IAAI,CAAC,GAAG,OAAO;AAAA,IAChE;AAAA,EACF;AACA,SAAO,MAAM,OAAO,OAAO,SAAS,CAAC,CAAC;AACxC;AAGA,IAAO,qBAAQ","sourcesContent":["import { Feature, LineString, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { destination } from \"@turf/destination\";\nimport { distance as measureDistance } from \"@turf/distance\";\nimport { point, Units } from \"@turf/helpers\";\nimport { getGeom } from \"@turf/invariant\";\n\n/**\n * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.\n *\n * @name along\n * @param {Feature<LineString>} line input line\n * @param {number} distance distance along the line\n * @param {Object} [options] Optional parameters\n * @param {string} [options.units=\"kilometers\"] can be degrees, radians, miles, or kilometers\n * @returns {Feature<Point>} Point `distance` `units` along the line\n * @example\n * var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);\n * var options = {units: 'miles'};\n *\n * var along = turf.along(line, 200, options);\n *\n * //addToMap\n * var addToMap = [along, line]\n */\nfunction along(\n line: Feature<LineString> | LineString,\n distance: number,\n options: { units?: Units } = {}\n): Feature<Point> {\n // Get Coords\n const geom = getGeom(line);\n const coords = geom.coordinates;\n let travelled = 0;\n for (let i = 0; i < coords.length; i++) {\n if (distance >= travelled && i === coords.length - 1) {\n break;\n } else if (travelled >= distance) {\n const overshot = distance - travelled;\n if (!overshot) {\n return point(coords[i]);\n } else {\n const direction = bearing(coords[i], coords[i - 1]) - 180;\n const interpolated = destination(\n coords[i],\n overshot,\n direction,\n options\n );\n return interpolated;\n }\n } else {\n travelled += measureDistance(coords[i], coords[i + 1], options);\n }\n }\n return point(coords[coords.length - 1]);\n}\n\nexport { along };\nexport default along;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-along/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACCA,wCAAwB;AACxB,gDAA4B;AAC5B,0CAA4C;AAC5C,wCAA6B;AAC7B,4CAAwB;AAoBxB,SAAS,KAAA,CACP,IAAA,EACA,QAAA,EACA,QAAA,EAA6B,CAAC,CAAA,EACd;AAEhB,EAAA,MAAM,KAAA,EAAO,gCAAA,IAAY,CAAA;AACzB,EAAA,MAAM,OAAA,EAAS,IAAA,CAAK,WAAA;AACpB,EAAA,IAAI,UAAA,EAAY,CAAA;AAChB,EAAA,IAAA,CAAA,IAAS,EAAA,EAAI,CAAA,EAAG,EAAA,EAAI,MAAA,CAAO,MAAA,EAAQ,CAAA,EAAA,EAAK;AACtC,IAAA,GAAA,CAAI,SAAA,GAAY,UAAA,GAAa,EAAA,IAAM,MAAA,CAAO,OAAA,EAAS,CAAA,EAAG;AACpD,MAAA,KAAA;AAAA,IACF,EAAA,KAAA,GAAA,CAAW,UAAA,GAAa,QAAA,EAAU;AAChC,MAAA,MAAM,SAAA,EAAW,SAAA,EAAW,SAAA;AAC5B,MAAA,GAAA,CAAI,CAAC,QAAA,EAAU;AACb,QAAA,OAAO,4BAAA,MAAM,CAAO,CAAC,CAAC,CAAA;AAAA,MACxB,EAAA,KAAO;AACL,QAAA,MAAM,UAAA,EAAY,8BAAA,MAAQ,CAAO,CAAC,CAAA,EAAG,MAAA,CAAO,EAAA,EAAI,CAAC,CAAC,EAAA,EAAI,GAAA;AACtD,QAAA,MAAM,aAAA,EAAe,sCAAA;AAAA,UACnB,MAAA,CAAO,CAAC,CAAA;AAAA,UACR,QAAA;AAAA,UACA,SAAA;AAAA,UACA;AAAA,QACF,CAAA;AACA,QAAA,OAAO,YAAA;AAAA,MACT;AAAA,IACF,EAAA,KAAO;AACL,MAAA,UAAA,GAAa,gCAAA,MAAgB,CAAO,CAAC,CAAA,EAAG,MAAA,CAAO,EAAA,EAAI,CAAC,CAAA,EAAG,OAAO,CAAA;AAAA,IAChE;AAAA,EACF;AACA,EAAA,OAAO,4BAAA,MAAM,CAAO,MAAA,CAAO,OAAA,EAAS,CAAC,CAAC,CAAA;AACxC;AAGA,IAAO,cAAA,EAAQ,KAAA;ADzBf;AACE;AACA;AACF,uDAAC","file":"/home/runner/work/turf/turf/packages/turf-along/dist/cjs/index.cjs","sourcesContent":[null,"import { Feature, LineString, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { destination } from \"@turf/destination\";\nimport { distance as measureDistance } from \"@turf/distance\";\nimport { point, Units } from \"@turf/helpers\";\nimport { getGeom } from \"@turf/invariant\";\n\n/**\n * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.\n *\n * @function\n * @param {Feature<LineString>|LineString} line input line\n * @param {number} distance distance along the line\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 * @returns {Feature<Point>} Point `distance` `units` along the line\n * @example\n * var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);\n * var options = {units: 'miles'};\n *\n * var along = turf.along(line, 200, options);\n *\n * //addToMap\n * var addToMap = [along, line]\n */\nfunction along(\n line: Feature<LineString> | LineString,\n distance: number,\n options: { units?: Units } = {}\n): Feature<Point> {\n // Get Coords\n const geom = getGeom(line);\n const coords = geom.coordinates;\n let travelled = 0;\n for (let i = 0; i < coords.length; i++) {\n if (distance >= travelled && i === coords.length - 1) {\n break;\n } else if (travelled >= distance) {\n const overshot = distance - travelled;\n if (!overshot) {\n return point(coords[i]);\n } else {\n const direction = bearing(coords[i], coords[i - 1]) - 180;\n const interpolated = destination(\n coords[i],\n overshot,\n direction,\n options\n );\n return interpolated;\n }\n } else {\n travelled += measureDistance(coords[i], coords[i + 1], options);\n }\n }\n return point(coords[coords.length - 1]);\n}\n\nexport { along };\nexport default along;\n"]}
@@ -4,11 +4,11 @@ import { Units } from '@turf/helpers';
4
4
  /**
5
5
  * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.
6
6
  *
7
- * @name along
8
- * @param {Feature<LineString>} line input line
7
+ * @function
8
+ * @param {Feature<LineString>|LineString} line input line
9
9
  * @param {number} distance distance along the line
10
10
  * @param {Object} [options] Optional parameters
11
- * @param {string} [options.units="kilometers"] can be degrees, radians, miles, or kilometers
11
+ * @param {Units} [options.units="kilometers"] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}.
12
12
  * @returns {Feature<Point>} Point `distance` `units` along the line
13
13
  * @example
14
14
  * var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);
@@ -4,11 +4,11 @@ import { Units } from '@turf/helpers';
4
4
  /**
5
5
  * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.
6
6
  *
7
- * @name along
8
- * @param {Feature<LineString>} line input line
7
+ * @function
8
+ * @param {Feature<LineString>|LineString} line input line
9
9
  * @param {number} distance distance along the line
10
10
  * @param {Object} [options] Optional parameters
11
- * @param {string} [options.units="kilometers"] can be degrees, radians, miles, or kilometers
11
+ * @param {Units} [options.units="kilometers"] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}.
12
12
  * @returns {Feature<Point>} Point `distance` `units` along the line
13
13
  * @example
14
14
  * var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);
package/dist/esm/index.js CHANGED
@@ -31,9 +31,9 @@ function along(line, distance, options = {}) {
31
31
  }
32
32
  return point(coords[coords.length - 1]);
33
33
  }
34
- var turf_along_default = along;
34
+ var index_default = along;
35
35
  export {
36
36
  along,
37
- turf_along_default as default
37
+ index_default as default
38
38
  };
39
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, LineString, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { destination } from \"@turf/destination\";\nimport { distance as measureDistance } from \"@turf/distance\";\nimport { point, Units } from \"@turf/helpers\";\nimport { getGeom } from \"@turf/invariant\";\n\n/**\n * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.\n *\n * @name along\n * @param {Feature<LineString>} line input line\n * @param {number} distance distance along the line\n * @param {Object} [options] Optional parameters\n * @param {string} [options.units=\"kilometers\"] can be degrees, radians, miles, or kilometers\n * @returns {Feature<Point>} Point `distance` `units` along the line\n * @example\n * var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);\n * var options = {units: 'miles'};\n *\n * var along = turf.along(line, 200, options);\n *\n * //addToMap\n * var addToMap = [along, line]\n */\nfunction along(\n line: Feature<LineString> | LineString,\n distance: number,\n options: { units?: Units } = {}\n): Feature<Point> {\n // Get Coords\n const geom = getGeom(line);\n const coords = geom.coordinates;\n let travelled = 0;\n for (let i = 0; i < coords.length; i++) {\n if (distance >= travelled && i === coords.length - 1) {\n break;\n } else if (travelled >= distance) {\n const overshot = distance - travelled;\n if (!overshot) {\n return point(coords[i]);\n } else {\n const direction = bearing(coords[i], coords[i - 1]) - 180;\n const interpolated = destination(\n coords[i],\n overshot,\n direction,\n options\n );\n return interpolated;\n }\n } else {\n travelled += measureDistance(coords[i], coords[i + 1], options);\n }\n }\n return point(coords[coords.length - 1]);\n}\n\nexport { along };\nexport default along;\n"],"mappings":";AACA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,YAAY,uBAAuB;AAC5C,SAAS,aAAoB;AAC7B,SAAS,eAAe;AAoBxB,SAAS,MACP,MACA,UACA,UAA6B,CAAC,GACd;AAEhB,QAAM,OAAO,QAAQ,IAAI;AACzB,QAAM,SAAS,KAAK;AACpB,MAAI,YAAY;AAChB,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,QAAI,YAAY,aAAa,MAAM,OAAO,SAAS,GAAG;AACpD;AAAA,IACF,WAAW,aAAa,UAAU;AAChC,YAAM,WAAW,WAAW;AAC5B,UAAI,CAAC,UAAU;AACb,eAAO,MAAM,OAAO,CAAC,CAAC;AAAA,MACxB,OAAO;AACL,cAAM,YAAY,QAAQ,OAAO,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,IAAI;AACtD,cAAM,eAAe;AAAA,UACnB,OAAO,CAAC;AAAA,UACR;AAAA,UACA;AAAA,UACA;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF,OAAO;AACL,mBAAa,gBAAgB,OAAO,CAAC,GAAG,OAAO,IAAI,CAAC,GAAG,OAAO;AAAA,IAChE;AAAA,EACF;AACA,SAAO,MAAM,OAAO,OAAO,SAAS,CAAC,CAAC;AACxC;AAGA,IAAO,qBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, LineString, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { destination } from \"@turf/destination\";\nimport { distance as measureDistance } from \"@turf/distance\";\nimport { point, Units } from \"@turf/helpers\";\nimport { getGeom } from \"@turf/invariant\";\n\n/**\n * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.\n *\n * @function\n * @param {Feature<LineString>|LineString} line input line\n * @param {number} distance distance along the line\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 * @returns {Feature<Point>} Point `distance` `units` along the line\n * @example\n * var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);\n * var options = {units: 'miles'};\n *\n * var along = turf.along(line, 200, options);\n *\n * //addToMap\n * var addToMap = [along, line]\n */\nfunction along(\n line: Feature<LineString> | LineString,\n distance: number,\n options: { units?: Units } = {}\n): Feature<Point> {\n // Get Coords\n const geom = getGeom(line);\n const coords = geom.coordinates;\n let travelled = 0;\n for (let i = 0; i < coords.length; i++) {\n if (distance >= travelled && i === coords.length - 1) {\n break;\n } else if (travelled >= distance) {\n const overshot = distance - travelled;\n if (!overshot) {\n return point(coords[i]);\n } else {\n const direction = bearing(coords[i], coords[i - 1]) - 180;\n const interpolated = destination(\n coords[i],\n overshot,\n direction,\n options\n );\n return interpolated;\n }\n } else {\n travelled += measureDistance(coords[i], coords[i + 1], options);\n }\n }\n return point(coords[coords.length - 1]);\n}\n\nexport { along };\nexport default along;\n"],"mappings":";AACA,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,YAAY,uBAAuB;AAC5C,SAAS,aAAoB;AAC7B,SAAS,eAAe;AAoBxB,SAAS,MACP,MACA,UACA,UAA6B,CAAC,GACd;AAEhB,QAAM,OAAO,QAAQ,IAAI;AACzB,QAAM,SAAS,KAAK;AACpB,MAAI,YAAY;AAChB,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,QAAI,YAAY,aAAa,MAAM,OAAO,SAAS,GAAG;AACpD;AAAA,IACF,WAAW,aAAa,UAAU;AAChC,YAAM,WAAW,WAAW;AAC5B,UAAI,CAAC,UAAU;AACb,eAAO,MAAM,OAAO,CAAC,CAAC;AAAA,MACxB,OAAO;AACL,cAAM,YAAY,QAAQ,OAAO,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,IAAI;AACtD,cAAM,eAAe;AAAA,UACnB,OAAO,CAAC;AAAA,UACR;AAAA,UACA;AAAA,UACA;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF,OAAO;AACL,mBAAa,gBAAgB,OAAO,CAAC,GAAG,OAAO,IAAI,CAAC,GAAG,OAAO;AAAA,IAChE;AAAA,EACF;AACA,SAAO,MAAM,OAAO,OAAO,SAAS,CAAC,CAAC;AACxC;AAGA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turf/along",
3
- "version": "7.1.0",
4
- "description": "turf along module",
3
+ "version": "7.3.0",
4
+ "description": "Calculates a point along a line at a specific distance",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
7
7
  "bugs": {
@@ -53,23 +53,23 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/benchmark": "^2.1.5",
56
- "@types/tape": "^4.2.32",
56
+ "@types/tape": "^5.8.1",
57
57
  "benchmark": "^2.1.4",
58
58
  "load-json-file": "^7.0.1",
59
59
  "npm-run-all": "^4.1.5",
60
- "tape": "^5.7.2",
61
- "tsup": "^8.0.1",
62
- "tsx": "^4.6.2",
63
- "typescript": "^5.2.2"
60
+ "tape": "^5.9.0",
61
+ "tsup": "^8.4.0",
62
+ "tsx": "^4.19.4",
63
+ "typescript": "^5.8.3"
64
64
  },
65
65
  "dependencies": {
66
- "@turf/bearing": "^7.1.0",
67
- "@turf/destination": "^7.1.0",
68
- "@turf/distance": "^7.1.0",
69
- "@turf/helpers": "^7.1.0",
70
- "@turf/invariant": "^7.1.0",
66
+ "@turf/bearing": "7.3.0",
67
+ "@turf/destination": "7.3.0",
68
+ "@turf/distance": "7.3.0",
69
+ "@turf/helpers": "7.3.0",
70
+ "@turf/invariant": "7.3.0",
71
71
  "@types/geojson": "^7946.0.10",
72
- "tslib": "^2.6.2"
72
+ "tslib": "^2.8.1"
73
73
  },
74
- "gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
74
+ "gitHead": "9f58a103e8f9a587ab640307ed03ba5233913ddd"
75
75
  }