@turf/along 7.2.0 → 7.3.1
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 +3 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +13 -14
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Takes a [LineString][1] and returns a [Point][2] at a specified distance along t
|
|
|
12
12
|
* `distance` **[number][4]** distance along the line
|
|
13
13
|
* `options` **[Object][5]?** Optional parameters (optional, default `{}`)
|
|
14
14
|
|
|
15
|
-
* `options.units` **Units**
|
|
15
|
+
* `options.units` **Units** Supports all valid Turf [Units][6]. (optional, default `"kilometers"`)
|
|
16
16
|
|
|
17
17
|
### Examples
|
|
18
18
|
|
|
@@ -38,6 +38,8 @@ 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://turfjs.org/docs/api/types/Units
|
|
42
|
+
|
|
41
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. -->
|
|
42
44
|
|
|
43
45
|
---
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -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
|
|
34
|
+
var index_default = along;
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
exports.along = along; exports.default =
|
|
38
|
+
exports.along = along; exports.default = index_default;
|
|
39
39
|
//# sourceMappingURL=index.cjs.map
|
package/d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,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"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ import { Units } from '@turf/helpers';
|
|
|
8
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 {Units} [options.units="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.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Units } from '@turf/helpers';
|
|
|
8
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 {Units} [options.units="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
|
|
34
|
+
var index_default = along;
|
|
35
35
|
export {
|
|
36
36
|
along,
|
|
37
|
-
|
|
37
|
+
index_default as default
|
|
38
38
|
};
|
|
39
39
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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 * @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\"]
|
|
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.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.3.1",
|
|
4
|
+
"description": "Calculates a point along a line at a specific distance",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bugs": {
|
|
@@ -48,28 +48,27 @@
|
|
|
48
48
|
"bench": "tsx bench.ts",
|
|
49
49
|
"build": "tsup --config ../../tsup.config.ts",
|
|
50
50
|
"docs": "tsx ../../scripts/generate-readmes.ts",
|
|
51
|
-
"test": "
|
|
51
|
+
"test": "pnpm run /test:.*/",
|
|
52
52
|
"test:tape": "tsx test.ts"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/benchmark": "^2.1.5",
|
|
56
|
-
"@types/tape": "^
|
|
56
|
+
"@types/tape": "^5.8.1",
|
|
57
57
|
"benchmark": "^2.1.4",
|
|
58
58
|
"load-json-file": "^7.0.1",
|
|
59
|
-
"npm-run-all": "^4.1.5",
|
|
60
59
|
"tape": "^5.9.0",
|
|
61
|
-
"tsup": "^8.
|
|
62
|
-
"tsx": "^4.19.
|
|
63
|
-
"typescript": "^5.
|
|
60
|
+
"tsup": "^8.4.0",
|
|
61
|
+
"tsx": "^4.19.4",
|
|
62
|
+
"typescript": "^5.8.3"
|
|
64
63
|
},
|
|
65
64
|
"dependencies": {
|
|
66
|
-
"@turf/bearing": "
|
|
67
|
-
"@turf/destination": "
|
|
68
|
-
"@turf/distance": "
|
|
69
|
-
"@turf/helpers": "
|
|
70
|
-
"@turf/invariant": "
|
|
65
|
+
"@turf/bearing": "7.3.1",
|
|
66
|
+
"@turf/destination": "7.3.1",
|
|
67
|
+
"@turf/distance": "7.3.1",
|
|
68
|
+
"@turf/helpers": "7.3.1",
|
|
69
|
+
"@turf/invariant": "7.3.1",
|
|
71
70
|
"@types/geojson": "^7946.0.10",
|
|
72
71
|
"tslib": "^2.8.1"
|
|
73
72
|
},
|
|
74
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "b7f1b4eafb760431e03955499d8eac9489438219"
|
|
75
74
|
}
|