@turf/shortest-path 7.1.0 → 7.2.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 +13 -19
- package/dist/cjs/index.cjs +3 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +5 -5
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +3 -6
- package/dist/esm/index.js.map +1 -1
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
## shortestPath
|
|
6
6
|
|
|
7
7
|
Returns the shortest [path][1] from [start][2] to [end][2] without colliding with
|
|
8
|
-
any [Feature][3] in [
|
|
8
|
+
any [Feature][3] in obstacles [FeatureCollection][4]<[Polygon][5]>
|
|
9
9
|
|
|
10
10
|
### Parameters
|
|
11
11
|
|
|
12
|
-
* `start` **[Coord][
|
|
13
|
-
* `end` **[Coord][
|
|
14
|
-
* `options` **[Object][
|
|
12
|
+
* `start` **[Coord][6]** point
|
|
13
|
+
* `end` **[Coord][6]** point
|
|
14
|
+
* `options` **[Object][7]** optional parameters (optional, default `{}`)
|
|
15
15
|
|
|
16
|
-
* `options.obstacles` **([
|
|
17
|
-
* `options.units` **
|
|
18
|
-
* `options.resolution` **[number][
|
|
16
|
+
* `options.obstacles` **([Polygon][5] | [Feature][3]<[Polygon][5]> | [FeatureCollection][4]<[Polygon][5]>)?** areas which path cannot travel
|
|
17
|
+
* `options.units` **Units** unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ... (optional, default `'kilometers'`)
|
|
18
|
+
* `options.resolution` **[number][8]** distance between matrix points on which the path will be calculated (optional, default `100`)
|
|
19
19
|
|
|
20
20
|
### Examples
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ any [Feature][3] in [ obstacles][4]
|
|
|
23
23
|
var start = [-5, -6];
|
|
24
24
|
var end = [9, -6];
|
|
25
25
|
var options = {
|
|
26
|
-
obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]])
|
|
26
|
+
obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]]).geometry
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
var path = turf.shortestPath(start, end, options);
|
|
@@ -40,21 +40,15 @@ Returns **[Feature][3]<[LineString][1]>** shortest path between start and end
|
|
|
40
40
|
|
|
41
41
|
[3]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
42
42
|
|
|
43
|
-
[4]:
|
|
43
|
+
[4]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
44
44
|
|
|
45
|
-
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.
|
|
45
|
+
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
46
46
|
|
|
47
|
-
[6]: https://
|
|
47
|
+
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.1
|
|
48
48
|
|
|
49
|
-
[7]: https://
|
|
49
|
+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
50
50
|
|
|
51
|
-
[8]: https://
|
|
52
|
-
|
|
53
|
-
[9]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
54
|
-
|
|
55
|
-
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
56
|
-
|
|
57
|
-
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
51
|
+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
58
52
|
|
|
59
53
|
<!-- 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. -->
|
|
60
54
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -283,14 +283,11 @@ BinaryHeap.prototype = {
|
|
|
283
283
|
// index.ts
|
|
284
284
|
function shortestPath(start, end, options = {}) {
|
|
285
285
|
options = options || {};
|
|
286
|
-
if (!_helpers.isObject.call(void 0, options))
|
|
287
|
-
throw new Error("options is invalid");
|
|
286
|
+
if (!_helpers.isObject.call(void 0, options)) throw new Error("options is invalid");
|
|
288
287
|
let obstacles = options.obstacles || _helpers.featureCollection.call(void 0, []);
|
|
289
288
|
let resolution = options.resolution || 100;
|
|
290
|
-
if (!start)
|
|
291
|
-
|
|
292
|
-
if (!end)
|
|
293
|
-
throw new Error("end is required");
|
|
289
|
+
if (!start) throw new Error("start is required");
|
|
290
|
+
if (!end) throw new Error("end is required");
|
|
294
291
|
if (resolution && (!_helpers.isNumber.call(void 0, resolution) || resolution <= 0))
|
|
295
292
|
throw new Error("options.resolution must be a number, greater than 0");
|
|
296
293
|
const startCoord = _invariant.getCoord.call(void 0, start);
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts","../../lib/javascript-astar.js"],"names":[],"mappings":";AAQA,SAAS,YAAY;AACrB,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AACzB,SAAS,kBAAkB,aAAa;AACxC,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,UAAU,eAAe;AAClC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACjBP,SAAS,OAAO,MAAM;AACpB,MAAI,OAAO,MACT,OAAO,CAAC;AACV,SAAO,KAAK,QAAQ;AAClB,SAAK,QAAQ,IAAI;AACjB,WAAO,KAAK;AAAA,EACd;AACA,SAAO;AACT;AAEA,SAAS,UAAU;AACjB,SAAO,IAAI,WAAW,SAAU,MAAM;AACpC,WAAO,KAAK;AAAA,EACd,CAAC;AACH;AAMO,IAAI,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcjB,QAAQ,SAAU,OAAO,OAAO,KAAK,SAAS;AAz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AQ;AAalB,SAAO,YAAY,WAAW,IAAI,CAAC;AACrC;AAUA,SAAS,SAAS,IAAoB,UAAsC;AAC1E,WAAS,IAAI,GAAG,IAAI,SAAS,SAAS,QAAQ,KAAK;AACjD,QAAI,sBAAsB,IAAI,SAAS,SAAS,CAAC,CAAC,GAAG;AACnD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAGA,IAAO,6BAAQ","sourcesContent":["import {\n Polygon,\n Feature,\n FeatureCollection,\n LineString,\n Geometry,\n Point,\n} from \"geojson\";\nimport { bbox } from \"@turf/bbox\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { distance } from \"@turf/distance\";\nimport { transformScale as scale } from \"@turf/transform-scale\";\nimport { cleanCoords } from \"@turf/clean-coords\";\nimport { bboxPolygon } from \"@turf/bbox-polygon\";\nimport { getCoord, getGeom } from \"@turf/invariant\";\nimport {\n Coord,\n Units,\n point,\n isNumber,\n lineString,\n isObject,\n featureCollection,\n feature,\n} from \"@turf/helpers\";\nimport { Graph, GridNode, astar } from \"./lib/javascript-astar.js\";\n\n/**\n * Returns the shortest {@link LineString|path} from {@link Point|start} to {@link Point|end} without colliding with\n * any {@link Feature} in {@link FeatureCollection<Polygon>| obstacles}\n *\n * @name shortestPath\n * @param {Coord} start point\n * @param {Coord} end point\n * @param {Object} [options={}] optional parameters\n * @param {Geometry|Feature|FeatureCollection<Polygon>} [options.obstacles] areas which path cannot travel\n * @param {string} [options.units='kilometers'] unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ...\n * @param {number} [options.resolution=100] distance between matrix points on which the path will be calculated\n * @returns {Feature<LineString>} shortest path between start and end\n * @example\n * var start = [-5, -6];\n * var end = [9, -6];\n * var options = {\n * obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]])\n * };\n *\n * var path = turf.shortestPath(start, end, options);\n *\n * //addToMap\n * var addToMap = [start, end, options.obstacles, path];\n */\nfunction shortestPath(\n start: Coord,\n end: Coord,\n options: {\n obstacles?: Polygon | Feature<Polygon> | FeatureCollection<Polygon>;\n units?: Units;\n resolution?: number;\n } = {}\n): Feature<LineString> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n let obstacles = options.obstacles || featureCollection([]);\n let resolution = options.resolution || 100;\n\n // validation\n if (!start) throw new Error(\"start is required\");\n if (!end) throw new Error(\"end is required\");\n if (resolution && (!isNumber(resolution) || resolution <= 0))\n throw new Error(\"options.resolution must be a number, greater than 0\");\n\n // Normalize Inputs\n const startCoord = getCoord(start);\n const endCoord = getCoord(end);\n start = point(startCoord);\n end = point(endCoord);\n\n // Handle obstacles\n if (obstacles.type === \"FeatureCollection\") {\n if (obstacles.features.length === 0) {\n return lineString([startCoord, endCoord]);\n }\n } else if (obstacles.type === \"Polygon\") {\n obstacles = featureCollection([feature(getGeom(obstacles))]);\n } else {\n throw new Error(\"invalid obstacles\");\n }\n\n // define path grid area\n const collection: FeatureCollection<Geometry> = obstacles;\n collection.features.push(start);\n collection.features.push(end);\n const box = bbox(scale(bboxPolygon(bbox(collection)), 1.15)); // extend 15%\n const [west, south, east, north] = box;\n\n const width = distance([west, south], [east, south], options);\n const division = width / resolution;\n\n collection.features.pop();\n collection.features.pop();\n\n const xFraction = division / distance([west, south], [east, south], options);\n const cellWidth = xFraction * (east - west);\n const yFraction = division / distance([west, south], [west, north], options);\n const cellHeight = yFraction * (north - south);\n\n const bboxHorizontalSide = east - west;\n const bboxVerticalSide = north - south;\n const columns = Math.floor(bboxHorizontalSide / cellWidth);\n const rows = Math.floor(bboxVerticalSide / cellHeight);\n // adjust origin of the grid\n const deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;\n const deltaY = (bboxVerticalSide - rows * cellHeight) / 2;\n\n // loop through points only once to speed up process\n // define matrix grid for A-star algorithm\n const pointMatrix: string[][] = [];\n const matrix: number[][] = [];\n\n let closestToStart: GridNode;\n let closestToEnd: GridNode;\n let minDistStart = Infinity;\n let minDistEnd = Infinity;\n let currentY = north - deltaY;\n let r = 0;\n while (currentY >= south) {\n // var currentY = south + deltaY;\n const matrixRow = [];\n const pointMatrixRow = [];\n let currentX = west + deltaX;\n let c = 0;\n while (currentX <= east) {\n const pt = point([currentX, currentY]);\n const isInsideObstacle = isInside(pt, obstacles);\n // feed obstacles matrix\n matrixRow.push(isInsideObstacle ? 0 : 1); // with javascript-astar\n // matrixRow.push(isInsideObstacle ? 1 : 0); // with astar-andrea\n // map point's coords\n pointMatrixRow.push(currentX + \"|\" + currentY);\n // set closest points\n const distStart = distance(pt, start);\n // if (distStart < minDistStart) {\n if (!isInsideObstacle && distStart < minDistStart) {\n minDistStart = distStart;\n closestToStart = { x: c, y: r };\n }\n const distEnd = distance(pt, end);\n // if (distEnd < minDistEnd) {\n if (!isInsideObstacle && distEnd < minDistEnd) {\n minDistEnd = distEnd;\n closestToEnd = { x: c, y: r };\n }\n currentX += cellWidth;\n c++;\n }\n matrix.push(matrixRow);\n pointMatrix.push(pointMatrixRow);\n currentY -= cellHeight;\n r++;\n }\n\n // find path on matrix grid\n\n // javascript-astar ----------------------\n const graph = new Graph(matrix, { diagonal: true });\n const startOnMatrix = graph.grid[closestToStart!.y][closestToStart!.x];\n const endOnMatrix = graph.grid[closestToEnd!.y][closestToEnd!.x];\n const result: GridNode[] = astar.search(graph, startOnMatrix, endOnMatrix);\n\n const path = [startCoord];\n result.forEach(function (coord) {\n const coords = pointMatrix[coord.x][coord.y].split(\"|\");\n path.push([+coords[0], +coords[1]]); // make sure coords are numbers\n });\n path.push(endCoord);\n // ---------------------------------------\n\n // astar-andrea ------------------------\n // var result = aStar(matrix, [closestToStart.x, closestToStart.y], [closestToEnd.x, closestToEnd.y], 'DiagonalFree');\n // var path = [start.geometry.coordinates];\n // result.forEach(function (coord) {\n // var coords = pointMatrix[coord[1]][coord[0]].split('|');\n // path.push([+coords[0], +coords[1]]); // make sure coords are numbers\n // });\n // path.push(end.geometry.coordinates);\n // ---------------------------------------\n\n return cleanCoords(lineString(path));\n}\n\n/**\n * Checks if Point is inside any of the Polygons\n *\n * @private\n * @param {Feature<Point>} pt to check\n * @param {FeatureCollection<Polygon>} polygons features\n * @returns {boolean} if inside or not\n */\nfunction isInside(pt: Feature<Point>, polygons: FeatureCollection<Polygon>) {\n for (let i = 0; i < polygons.features.length; i++) {\n if (booleanPointInPolygon(pt, polygons.features[i])) {\n return true;\n }\n }\n return false;\n}\n\nexport { shortestPath };\nexport default shortestPath;\n","// javascript-astar 0.4.1\n// http://github.com/bgrins/javascript-astar\n// Freely distributable under the MIT License.\n// Implements the astar search algorithm in javascript using a Binary Heap.\n// Includes Binary Heap (with modifications) from Marijn Haverbeke.\n// http://eloquentjavascript.net/appendix2.html\n\nfunction pathTo(node) {\n var curr = node,\n path = [];\n while (curr.parent) {\n path.unshift(curr);\n curr = curr.parent;\n }\n return path;\n}\n\nfunction getHeap() {\n return new BinaryHeap(function (node) {\n return node.f;\n });\n}\n\n/**\n * Astar\n * @private\n */\nexport var astar = {\n /**\n * Perform an A* Search on a graph given a start and end node.\n *\n * @private\n * @memberof astar\n * @param {Graph} graph Graph\n * @param {GridNode} start Start\n * @param {GridNode} end End\n * @param {Object} [options] Options\n * @param {bool} [options.closest] Specifies whether to return the path to the closest node if the target is unreachable.\n * @param {Function} [options.heuristic] Heuristic function (see astar.heuristics).\n * @returns {Object} Search\n */\n search: function (graph, start, end, options) {\n graph.cleanDirty();\n options = options || {};\n var heuristic = options.heuristic || astar.heuristics.manhattan,\n closest = options.closest ?? false;\n\n var openHeap = getHeap(),\n closestNode = start; // set the start node to be the closest if required\n\n start.h = heuristic(start, end);\n\n openHeap.push(start);\n\n while (openHeap.size() > 0) {\n // Grab the lowest f(x) to process next. Heap keeps this sorted for us.\n var currentNode = openHeap.pop();\n\n // End case -- result has been found, return the traced path.\n if (currentNode === end) {\n return pathTo(currentNode);\n }\n\n // Normal case -- move currentNode from open to closed, process each of its neighbors.\n currentNode.closed = true;\n\n // Find all neighbors for the current node.\n var neighbors = graph.neighbors(currentNode);\n\n for (var i = 0, il = neighbors.length; i < il; ++i) {\n var neighbor = neighbors[i];\n\n if (neighbor.closed || neighbor.isWall()) {\n // Not a valid node to process, skip to next neighbor.\n continue;\n }\n\n // The g score is the shortest distance from start to current node.\n // We need to check if the path we have arrived at this neighbor is the shortest one we have seen yet.\n var gScore = currentNode.g + neighbor.getCost(currentNode),\n beenVisited = neighbor.visited;\n\n if (!beenVisited || gScore < neighbor.g) {\n // Found an optimal (so far) path to this node. Take score for node to see how good it is.\n neighbor.visited = true;\n neighbor.parent = currentNode;\n neighbor.h = neighbor.h || heuristic(neighbor, end);\n neighbor.g = gScore;\n neighbor.f = neighbor.g + neighbor.h;\n graph.markDirty(neighbor);\n if (closest) {\n // If the neighbour is closer than the current closestNode or if it's equally close but has\n // a cheaper path than the current closest node then it becomes the closest node\n if (\n neighbor.h < closestNode.h ||\n (neighbor.h === closestNode.h && neighbor.g < closestNode.g)\n ) {\n closestNode = neighbor;\n }\n }\n\n if (!beenVisited) {\n // Pushing to heap will put it in proper place based on the 'f' value.\n openHeap.push(neighbor);\n } else {\n // Already seen the node, but since it has been rescored we need to reorder it in the heap\n openHeap.rescoreElement(neighbor);\n }\n }\n }\n }\n\n if (closest) {\n return pathTo(closestNode);\n }\n\n // No result was found - empty array signifies failure to find path.\n return [];\n },\n // See list of heuristics: http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html\n heuristics: {\n manhattan: function (pos0, pos1) {\n var d1 = Math.abs(pos1.x - pos0.x);\n var d2 = Math.abs(pos1.y - pos0.y);\n return d1 + d2;\n },\n diagonal: function (pos0, pos1) {\n var D = 1;\n var D2 = Math.sqrt(2);\n var d1 = Math.abs(pos1.x - pos0.x);\n var d2 = Math.abs(pos1.y - pos0.y);\n return D * (d1 + d2) + (D2 - 2 * D) * Math.min(d1, d2);\n },\n },\n cleanNode: function (node) {\n node.f = 0;\n node.g = 0;\n node.h = 0;\n node.visited = false;\n node.closed = false;\n node.parent = null;\n },\n};\n\n/**\n * A graph memory structure\n *\n * @private\n * @param {Array} gridIn 2D array of input weights\n * @param {Object} [options] Options\n * @param {boolean} [options.diagonal] Specifies whether diagonal moves are allowed\n * @returns {void} Graph\n */\nexport function Graph(gridIn, options) {\n options = options || {};\n this.nodes = [];\n this.diagonal = !!options.diagonal;\n this.grid = [];\n for (var x = 0; x < gridIn.length; x++) {\n this.grid[x] = [];\n\n for (var y = 0, row = gridIn[x]; y < row.length; y++) {\n var node = new GridNode(x, y, row[y]);\n this.grid[x][y] = node;\n this.nodes.push(node);\n }\n }\n this.init();\n}\n\nGraph.prototype.init = function () {\n this.dirtyNodes = [];\n for (var i = 0; i < this.nodes.length; i++) {\n astar.cleanNode(this.nodes[i]);\n }\n};\n\nGraph.prototype.cleanDirty = function () {\n for (var i = 0; i < this.dirtyNodes.length; i++) {\n astar.cleanNode(this.dirtyNodes[i]);\n }\n this.dirtyNodes = [];\n};\n\nGraph.prototype.markDirty = function (node) {\n this.dirtyNodes.push(node);\n};\n\nGraph.prototype.neighbors = function (node) {\n var ret = [],\n x = node.x,\n y = node.y,\n grid = this.grid;\n\n // West\n if (grid[x - 1] && grid[x - 1][y]) {\n ret.push(grid[x - 1][y]);\n }\n\n // East\n if (grid[x + 1] && grid[x + 1][y]) {\n ret.push(grid[x + 1][y]);\n }\n\n // South\n if (grid[x] && grid[x][y - 1]) {\n ret.push(grid[x][y - 1]);\n }\n\n // North\n if (grid[x] && grid[x][y + 1]) {\n ret.push(grid[x][y + 1]);\n }\n\n if (this.diagonal) {\n // Southwest\n if (grid[x - 1] && grid[x - 1][y - 1]) {\n ret.push(grid[x - 1][y - 1]);\n }\n\n // Southeast\n if (grid[x + 1] && grid[x + 1][y - 1]) {\n ret.push(grid[x + 1][y - 1]);\n }\n\n // Northwest\n if (grid[x - 1] && grid[x - 1][y + 1]) {\n ret.push(grid[x - 1][y + 1]);\n }\n\n // Northeast\n if (grid[x + 1] && grid[x + 1][y + 1]) {\n ret.push(grid[x + 1][y + 1]);\n }\n }\n\n return ret;\n};\n\nGraph.prototype.toString = function () {\n var graphString = [],\n nodes = this.grid, // when using grid\n rowDebug,\n row,\n y,\n l;\n for (var x = 0, len = nodes.length; x < len; x++) {\n rowDebug = [];\n row = nodes[x];\n for (y = 0, l = row.length; y < l; y++) {\n rowDebug.push(row[y].weight);\n }\n graphString.push(rowDebug.join(\" \"));\n }\n return graphString.join(\"\\n\");\n};\n\nfunction GridNode(x, y, weight) {\n this.x = x;\n this.y = y;\n this.weight = weight;\n}\n\nGridNode.prototype.toString = function () {\n return \"[\" + this.x + \" \" + this.y + \"]\";\n};\n\nGridNode.prototype.getCost = function (fromNeighbor) {\n // Take diagonal weight into consideration.\n if (fromNeighbor && fromNeighbor.x !== this.x && fromNeighbor.y !== this.y) {\n return this.weight * 1.41421;\n }\n return this.weight;\n};\n\nGridNode.prototype.isWall = function () {\n return this.weight === 0;\n};\n\nfunction BinaryHeap(scoreFunction) {\n this.content = [];\n this.scoreFunction = scoreFunction;\n}\n\nBinaryHeap.prototype = {\n push: function (element) {\n // Add the new element to the end of the array.\n this.content.push(element);\n\n // Allow it to sink down.\n this.sinkDown(this.content.length - 1);\n },\n pop: function () {\n // Store the first element so we can return it later.\n var result = this.content[0];\n // Get the element at the end of the array.\n var end = this.content.pop();\n // If there are any elements left, put the end element at the\n // start, and let it bubble up.\n if (this.content.length > 0) {\n this.content[0] = end;\n this.bubbleUp(0);\n }\n return result;\n },\n remove: function (node) {\n var i = this.content.indexOf(node);\n\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n var end = this.content.pop();\n\n if (i !== this.content.length - 1) {\n this.content[i] = end;\n\n if (this.scoreFunction(end) < this.scoreFunction(node)) {\n this.sinkDown(i);\n } else {\n this.bubbleUp(i);\n }\n }\n },\n size: function () {\n return this.content.length;\n },\n rescoreElement: function (node) {\n this.sinkDown(this.content.indexOf(node));\n },\n sinkDown: function (n) {\n // Fetch the element that has to be sunk.\n var element = this.content[n];\n\n // When at 0, an element can not sink any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n var parentN = ((n + 1) >> 1) - 1,\n parent = this.content[parentN];\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[parentN] = element;\n this.content[n] = parent;\n // Update 'n' to continue at the new position.\n n = parentN;\n // Found a parent that is less, no need to sink any further.\n } else {\n break;\n }\n }\n },\n bubbleUp: function (n) {\n // Look up the target element and its score.\n var length = this.content.length,\n element = this.content[n],\n elemScore = this.scoreFunction(element);\n\n while (true) {\n // Compute the indices of the child elements.\n var child2N = (n + 1) << 1,\n child1N = child2N - 1;\n // This is used to store the new position of the element, if any.\n var swap = null,\n child1Score;\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n var child1 = this.content[child1N];\n child1Score = this.scoreFunction(child1);\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) {\n swap = child1N;\n }\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n var child2 = this.content[child2N],\n child2Score = this.scoreFunction(child2);\n if (child2Score < (swap === null ? elemScore : child1Score)) {\n swap = child2N;\n }\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[n] = this.content[swap];\n this.content[swap] = element;\n n = swap;\n // Otherwise, we are done.\n } else {\n break;\n }\n }\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-shortest-path/dist/cjs/index.cjs","../../index.ts","../../lib/javascript-astar.js"],"names":[],"mappings":"AAAA;ACQA,kCAAqB;AACrB,uEAAsC;AACtC,0CAAyB;AACzB,uDAAwC;AACxC,iDAA4B;AAC5B,iDAA4B;AAC5B,4CAAkC;AAClC;AAGE;AACA;AACA;AACA;AACA;AACA;AAAA,wCACK;ADRP;AACA;AEVA,SAAS,MAAA,CAAO,IAAA,EAAM;AACpB,EAAA,IAAI,KAAA,EAAO,IAAA,EACT,KAAA,EAAO,CAAC,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,CAAA;AAalB,EAAA,OAAO,sCAAA,iCAAY,IAAe,CAAC,CAAA;AACrC;AAUA,SAAS,QAAA,CAAS,EAAA,EAAoB,QAAA,EAAsC;AAC1E,EAAA,IAAA,CAAA,IAAS,EAAA,EAAI,CAAA,EAAG,EAAA,EAAI,QAAA,CAAS,QAAA,CAAS,MAAA,EAAQ,CAAA,EAAA,EAAK;AACjD,IAAA,GAAA,CAAI,0DAAA,EAAsB,EAAI,QAAA,CAAS,QAAA,CAAS,CAAC,CAAC,CAAA,EAAG;AACnD,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT;AAGA,IAAO,2BAAA,EAAQ,YAAA;AD4Kf;AACE;AACA;AACF,kFAAC","file":"/home/runner/work/turf/turf/packages/turf-shortest-path/dist/cjs/index.cjs","sourcesContent":[null,"import {\n Polygon,\n Feature,\n FeatureCollection,\n LineString,\n Geometry,\n Point,\n} from \"geojson\";\nimport { bbox } from \"@turf/bbox\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { distance } from \"@turf/distance\";\nimport { transformScale as scale } from \"@turf/transform-scale\";\nimport { cleanCoords } from \"@turf/clean-coords\";\nimport { bboxPolygon } from \"@turf/bbox-polygon\";\nimport { getCoord, getGeom } from \"@turf/invariant\";\nimport {\n Coord,\n Units,\n point,\n isNumber,\n lineString,\n isObject,\n featureCollection,\n feature,\n} from \"@turf/helpers\";\nimport { Graph, GridNode, astar } from \"./lib/javascript-astar.js\";\n\n/**\n * Returns the shortest {@link LineString|path} from {@link Point|start} to {@link Point|end} without colliding with\n * any {@link Feature} in obstacles {@link FeatureCollection}<{@link Polygon}>\n *\n * @function\n * @param {Coord} start point\n * @param {Coord} end point\n * @param {Object} [options={}] optional parameters\n * @param {Polygon|Feature<Polygon>|FeatureCollection<Polygon>} [options.obstacles] areas which path cannot travel\n * @param {Units} [options.units='kilometers'] unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ...\n * @param {number} [options.resolution=100] distance between matrix points on which the path will be calculated\n * @returns {Feature<LineString>} shortest path between start and end\n * @example\n * var start = [-5, -6];\n * var end = [9, -6];\n * var options = {\n * obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]]).geometry\n * };\n *\n * var path = turf.shortestPath(start, end, options);\n *\n * //addToMap\n * var addToMap = [start, end, options.obstacles, path];\n */\nfunction shortestPath(\n start: Coord,\n end: Coord,\n options: {\n obstacles?: Polygon | Feature<Polygon> | FeatureCollection<Polygon>;\n units?: Units;\n resolution?: number;\n } = {}\n): Feature<LineString> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n let obstacles = options.obstacles || featureCollection([]);\n let resolution = options.resolution || 100;\n\n // validation\n if (!start) throw new Error(\"start is required\");\n if (!end) throw new Error(\"end is required\");\n if (resolution && (!isNumber(resolution) || resolution <= 0))\n throw new Error(\"options.resolution must be a number, greater than 0\");\n\n // Normalize Inputs\n const startCoord = getCoord(start);\n const endCoord = getCoord(end);\n start = point(startCoord);\n end = point(endCoord);\n\n // Handle obstacles\n if (obstacles.type === \"FeatureCollection\") {\n if (obstacles.features.length === 0) {\n return lineString([startCoord, endCoord]);\n }\n } else if (obstacles.type === \"Polygon\") {\n obstacles = featureCollection([feature(getGeom(obstacles))]);\n } else {\n throw new Error(\"invalid obstacles\");\n }\n\n // define path grid area\n const collection: FeatureCollection<Geometry> = obstacles;\n collection.features.push(start);\n collection.features.push(end);\n const box = bbox(scale(bboxPolygon(bbox(collection)), 1.15)); // extend 15%\n const [west, south, east, north] = box;\n\n const width = distance([west, south], [east, south], options);\n const division = width / resolution;\n\n collection.features.pop();\n collection.features.pop();\n\n const xFraction = division / distance([west, south], [east, south], options);\n const cellWidth = xFraction * (east - west);\n const yFraction = division / distance([west, south], [west, north], options);\n const cellHeight = yFraction * (north - south);\n\n const bboxHorizontalSide = east - west;\n const bboxVerticalSide = north - south;\n const columns = Math.floor(bboxHorizontalSide / cellWidth);\n const rows = Math.floor(bboxVerticalSide / cellHeight);\n // adjust origin of the grid\n const deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;\n const deltaY = (bboxVerticalSide - rows * cellHeight) / 2;\n\n // loop through points only once to speed up process\n // define matrix grid for A-star algorithm\n const pointMatrix: string[][] = [];\n const matrix: number[][] = [];\n\n let closestToStart: GridNode;\n let closestToEnd: GridNode;\n let minDistStart = Infinity;\n let minDistEnd = Infinity;\n let currentY = north - deltaY;\n let r = 0;\n while (currentY >= south) {\n // var currentY = south + deltaY;\n const matrixRow = [];\n const pointMatrixRow = [];\n let currentX = west + deltaX;\n let c = 0;\n while (currentX <= east) {\n const pt = point([currentX, currentY]);\n const isInsideObstacle = isInside(pt, obstacles);\n // feed obstacles matrix\n matrixRow.push(isInsideObstacle ? 0 : 1); // with javascript-astar\n // matrixRow.push(isInsideObstacle ? 1 : 0); // with astar-andrea\n // map point's coords\n pointMatrixRow.push(currentX + \"|\" + currentY);\n // set closest points\n const distStart = distance(pt, start);\n // if (distStart < minDistStart) {\n if (!isInsideObstacle && distStart < minDistStart) {\n minDistStart = distStart;\n closestToStart = { x: c, y: r };\n }\n const distEnd = distance(pt, end);\n // if (distEnd < minDistEnd) {\n if (!isInsideObstacle && distEnd < minDistEnd) {\n minDistEnd = distEnd;\n closestToEnd = { x: c, y: r };\n }\n currentX += cellWidth;\n c++;\n }\n matrix.push(matrixRow);\n pointMatrix.push(pointMatrixRow);\n currentY -= cellHeight;\n r++;\n }\n\n // find path on matrix grid\n\n // javascript-astar ----------------------\n const graph = new Graph(matrix, { diagonal: true });\n const startOnMatrix = graph.grid[closestToStart!.y][closestToStart!.x];\n const endOnMatrix = graph.grid[closestToEnd!.y][closestToEnd!.x];\n const result: GridNode[] = astar.search(graph, startOnMatrix, endOnMatrix);\n\n const path = [startCoord];\n result.forEach(function (coord) {\n const coords = pointMatrix[coord.x][coord.y].split(\"|\");\n path.push([+coords[0], +coords[1]]); // make sure coords are numbers\n });\n path.push(endCoord);\n // ---------------------------------------\n\n // astar-andrea ------------------------\n // var result = aStar(matrix, [closestToStart.x, closestToStart.y], [closestToEnd.x, closestToEnd.y], 'DiagonalFree');\n // var path = [start.geometry.coordinates];\n // result.forEach(function (coord) {\n // var coords = pointMatrix[coord[1]][coord[0]].split('|');\n // path.push([+coords[0], +coords[1]]); // make sure coords are numbers\n // });\n // path.push(end.geometry.coordinates);\n // ---------------------------------------\n\n return cleanCoords(lineString(path));\n}\n\n/**\n * Checks if Point is inside any of the Polygons\n *\n * @private\n * @param {Feature<Point>} pt to check\n * @param {FeatureCollection<Polygon>} polygons features\n * @returns {boolean} if inside or not\n */\nfunction isInside(pt: Feature<Point>, polygons: FeatureCollection<Polygon>) {\n for (let i = 0; i < polygons.features.length; i++) {\n if (booleanPointInPolygon(pt, polygons.features[i])) {\n return true;\n }\n }\n return false;\n}\n\nexport { shortestPath };\nexport default shortestPath;\n","// javascript-astar 0.4.1\n// http://github.com/bgrins/javascript-astar\n// Freely distributable under the MIT License.\n// Implements the astar search algorithm in javascript using a Binary Heap.\n// Includes Binary Heap (with modifications) from Marijn Haverbeke.\n// http://eloquentjavascript.net/appendix2.html\n\nfunction pathTo(node) {\n var curr = node,\n path = [];\n while (curr.parent) {\n path.unshift(curr);\n curr = curr.parent;\n }\n return path;\n}\n\nfunction getHeap() {\n return new BinaryHeap(function (node) {\n return node.f;\n });\n}\n\n/**\n * Astar\n * @private\n */\nexport var astar = {\n /**\n * Perform an A* Search on a graph given a start and end node.\n *\n * @private\n * @memberof astar\n * @param {Graph} graph Graph\n * @param {GridNode} start Start\n * @param {GridNode} end End\n * @param {Object} [options] Options\n * @param {bool} [options.closest] Specifies whether to return the path to the closest node if the target is unreachable.\n * @param {Function} [options.heuristic] Heuristic function (see astar.heuristics).\n * @returns {Object} Search\n */\n search: function (graph, start, end, options) {\n graph.cleanDirty();\n options = options || {};\n var heuristic = options.heuristic || astar.heuristics.manhattan,\n closest = options.closest ?? false;\n\n var openHeap = getHeap(),\n closestNode = start; // set the start node to be the closest if required\n\n start.h = heuristic(start, end);\n\n openHeap.push(start);\n\n while (openHeap.size() > 0) {\n // Grab the lowest f(x) to process next. Heap keeps this sorted for us.\n var currentNode = openHeap.pop();\n\n // End case -- result has been found, return the traced path.\n if (currentNode === end) {\n return pathTo(currentNode);\n }\n\n // Normal case -- move currentNode from open to closed, process each of its neighbors.\n currentNode.closed = true;\n\n // Find all neighbors for the current node.\n var neighbors = graph.neighbors(currentNode);\n\n for (var i = 0, il = neighbors.length; i < il; ++i) {\n var neighbor = neighbors[i];\n\n if (neighbor.closed || neighbor.isWall()) {\n // Not a valid node to process, skip to next neighbor.\n continue;\n }\n\n // The g score is the shortest distance from start to current node.\n // We need to check if the path we have arrived at this neighbor is the shortest one we have seen yet.\n var gScore = currentNode.g + neighbor.getCost(currentNode),\n beenVisited = neighbor.visited;\n\n if (!beenVisited || gScore < neighbor.g) {\n // Found an optimal (so far) path to this node. Take score for node to see how good it is.\n neighbor.visited = true;\n neighbor.parent = currentNode;\n neighbor.h = neighbor.h || heuristic(neighbor, end);\n neighbor.g = gScore;\n neighbor.f = neighbor.g + neighbor.h;\n graph.markDirty(neighbor);\n if (closest) {\n // If the neighbour is closer than the current closestNode or if it's equally close but has\n // a cheaper path than the current closest node then it becomes the closest node\n if (\n neighbor.h < closestNode.h ||\n (neighbor.h === closestNode.h && neighbor.g < closestNode.g)\n ) {\n closestNode = neighbor;\n }\n }\n\n if (!beenVisited) {\n // Pushing to heap will put it in proper place based on the 'f' value.\n openHeap.push(neighbor);\n } else {\n // Already seen the node, but since it has been rescored we need to reorder it in the heap\n openHeap.rescoreElement(neighbor);\n }\n }\n }\n }\n\n if (closest) {\n return pathTo(closestNode);\n }\n\n // No result was found - empty array signifies failure to find path.\n return [];\n },\n // See list of heuristics: http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html\n heuristics: {\n manhattan: function (pos0, pos1) {\n var d1 = Math.abs(pos1.x - pos0.x);\n var d2 = Math.abs(pos1.y - pos0.y);\n return d1 + d2;\n },\n diagonal: function (pos0, pos1) {\n var D = 1;\n var D2 = Math.sqrt(2);\n var d1 = Math.abs(pos1.x - pos0.x);\n var d2 = Math.abs(pos1.y - pos0.y);\n return D * (d1 + d2) + (D2 - 2 * D) * Math.min(d1, d2);\n },\n },\n cleanNode: function (node) {\n node.f = 0;\n node.g = 0;\n node.h = 0;\n node.visited = false;\n node.closed = false;\n node.parent = null;\n },\n};\n\n/**\n * A graph memory structure\n *\n * @private\n * @param {Array} gridIn 2D array of input weights\n * @param {Object} [options] Options\n * @param {boolean} [options.diagonal] Specifies whether diagonal moves are allowed\n * @returns {void} Graph\n */\nexport function Graph(gridIn, options) {\n options = options || {};\n this.nodes = [];\n this.diagonal = !!options.diagonal;\n this.grid = [];\n for (var x = 0; x < gridIn.length; x++) {\n this.grid[x] = [];\n\n for (var y = 0, row = gridIn[x]; y < row.length; y++) {\n var node = new GridNode(x, y, row[y]);\n this.grid[x][y] = node;\n this.nodes.push(node);\n }\n }\n this.init();\n}\n\nGraph.prototype.init = function () {\n this.dirtyNodes = [];\n for (var i = 0; i < this.nodes.length; i++) {\n astar.cleanNode(this.nodes[i]);\n }\n};\n\nGraph.prototype.cleanDirty = function () {\n for (var i = 0; i < this.dirtyNodes.length; i++) {\n astar.cleanNode(this.dirtyNodes[i]);\n }\n this.dirtyNodes = [];\n};\n\nGraph.prototype.markDirty = function (node) {\n this.dirtyNodes.push(node);\n};\n\nGraph.prototype.neighbors = function (node) {\n var ret = [],\n x = node.x,\n y = node.y,\n grid = this.grid;\n\n // West\n if (grid[x - 1] && grid[x - 1][y]) {\n ret.push(grid[x - 1][y]);\n }\n\n // East\n if (grid[x + 1] && grid[x + 1][y]) {\n ret.push(grid[x + 1][y]);\n }\n\n // South\n if (grid[x] && grid[x][y - 1]) {\n ret.push(grid[x][y - 1]);\n }\n\n // North\n if (grid[x] && grid[x][y + 1]) {\n ret.push(grid[x][y + 1]);\n }\n\n if (this.diagonal) {\n // Southwest\n if (grid[x - 1] && grid[x - 1][y - 1]) {\n ret.push(grid[x - 1][y - 1]);\n }\n\n // Southeast\n if (grid[x + 1] && grid[x + 1][y - 1]) {\n ret.push(grid[x + 1][y - 1]);\n }\n\n // Northwest\n if (grid[x - 1] && grid[x - 1][y + 1]) {\n ret.push(grid[x - 1][y + 1]);\n }\n\n // Northeast\n if (grid[x + 1] && grid[x + 1][y + 1]) {\n ret.push(grid[x + 1][y + 1]);\n }\n }\n\n return ret;\n};\n\nGraph.prototype.toString = function () {\n var graphString = [],\n nodes = this.grid, // when using grid\n rowDebug,\n row,\n y,\n l;\n for (var x = 0, len = nodes.length; x < len; x++) {\n rowDebug = [];\n row = nodes[x];\n for (y = 0, l = row.length; y < l; y++) {\n rowDebug.push(row[y].weight);\n }\n graphString.push(rowDebug.join(\" \"));\n }\n return graphString.join(\"\\n\");\n};\n\nfunction GridNode(x, y, weight) {\n this.x = x;\n this.y = y;\n this.weight = weight;\n}\n\nGridNode.prototype.toString = function () {\n return \"[\" + this.x + \" \" + this.y + \"]\";\n};\n\nGridNode.prototype.getCost = function (fromNeighbor) {\n // Take diagonal weight into consideration.\n if (fromNeighbor && fromNeighbor.x !== this.x && fromNeighbor.y !== this.y) {\n return this.weight * 1.41421;\n }\n return this.weight;\n};\n\nGridNode.prototype.isWall = function () {\n return this.weight === 0;\n};\n\nfunction BinaryHeap(scoreFunction) {\n this.content = [];\n this.scoreFunction = scoreFunction;\n}\n\nBinaryHeap.prototype = {\n push: function (element) {\n // Add the new element to the end of the array.\n this.content.push(element);\n\n // Allow it to sink down.\n this.sinkDown(this.content.length - 1);\n },\n pop: function () {\n // Store the first element so we can return it later.\n var result = this.content[0];\n // Get the element at the end of the array.\n var end = this.content.pop();\n // If there are any elements left, put the end element at the\n // start, and let it bubble up.\n if (this.content.length > 0) {\n this.content[0] = end;\n this.bubbleUp(0);\n }\n return result;\n },\n remove: function (node) {\n var i = this.content.indexOf(node);\n\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n var end = this.content.pop();\n\n if (i !== this.content.length - 1) {\n this.content[i] = end;\n\n if (this.scoreFunction(end) < this.scoreFunction(node)) {\n this.sinkDown(i);\n } else {\n this.bubbleUp(i);\n }\n }\n },\n size: function () {\n return this.content.length;\n },\n rescoreElement: function (node) {\n this.sinkDown(this.content.indexOf(node));\n },\n sinkDown: function (n) {\n // Fetch the element that has to be sunk.\n var element = this.content[n];\n\n // When at 0, an element can not sink any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n var parentN = ((n + 1) >> 1) - 1,\n parent = this.content[parentN];\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[parentN] = element;\n this.content[n] = parent;\n // Update 'n' to continue at the new position.\n n = parentN;\n // Found a parent that is less, no need to sink any further.\n } else {\n break;\n }\n }\n },\n bubbleUp: function (n) {\n // Look up the target element and its score.\n var length = this.content.length,\n element = this.content[n],\n elemScore = this.scoreFunction(element);\n\n while (true) {\n // Compute the indices of the child elements.\n var child2N = (n + 1) << 1,\n child1N = child2N - 1;\n // This is used to store the new position of the element, if any.\n var swap = null,\n child1Score;\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n var child1 = this.content[child1N];\n child1Score = this.scoreFunction(child1);\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) {\n swap = child1N;\n }\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n var child2 = this.content[child2N],\n child2Score = this.scoreFunction(child2);\n if (child2Score < (swap === null ? elemScore : child1Score)) {\n swap = child2N;\n }\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[n] = this.content[swap];\n this.content[swap] = element;\n n = swap;\n // Otherwise, we are done.\n } else {\n break;\n }\n }\n },\n};\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -3,21 +3,21 @@ import { Coord, Units } from '@turf/helpers';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns the shortest {@link LineString|path} from {@link Point|start} to {@link Point|end} without colliding with
|
|
6
|
-
* any {@link Feature} in {@link FeatureCollection<Polygon
|
|
6
|
+
* any {@link Feature} in obstacles {@link FeatureCollection}<{@link Polygon}>
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @function
|
|
9
9
|
* @param {Coord} start point
|
|
10
10
|
* @param {Coord} end point
|
|
11
11
|
* @param {Object} [options={}] optional parameters
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {Polygon|Feature<Polygon>|FeatureCollection<Polygon>} [options.obstacles] areas which path cannot travel
|
|
13
|
+
* @param {Units} [options.units='kilometers'] unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ...
|
|
14
14
|
* @param {number} [options.resolution=100] distance between matrix points on which the path will be calculated
|
|
15
15
|
* @returns {Feature<LineString>} shortest path between start and end
|
|
16
16
|
* @example
|
|
17
17
|
* var start = [-5, -6];
|
|
18
18
|
* var end = [9, -6];
|
|
19
19
|
* var options = {
|
|
20
|
-
* obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]])
|
|
20
|
+
* obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]]).geometry
|
|
21
21
|
* };
|
|
22
22
|
*
|
|
23
23
|
* var path = turf.shortestPath(start, end, options);
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,21 +3,21 @@ import { Coord, Units } from '@turf/helpers';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns the shortest {@link LineString|path} from {@link Point|start} to {@link Point|end} without colliding with
|
|
6
|
-
* any {@link Feature} in {@link FeatureCollection<Polygon
|
|
6
|
+
* any {@link Feature} in obstacles {@link FeatureCollection}<{@link Polygon}>
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @function
|
|
9
9
|
* @param {Coord} start point
|
|
10
10
|
* @param {Coord} end point
|
|
11
11
|
* @param {Object} [options={}] optional parameters
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {Polygon|Feature<Polygon>|FeatureCollection<Polygon>} [options.obstacles] areas which path cannot travel
|
|
13
|
+
* @param {Units} [options.units='kilometers'] unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ...
|
|
14
14
|
* @param {number} [options.resolution=100] distance between matrix points on which the path will be calculated
|
|
15
15
|
* @returns {Feature<LineString>} shortest path between start and end
|
|
16
16
|
* @example
|
|
17
17
|
* var start = [-5, -6];
|
|
18
18
|
* var end = [9, -6];
|
|
19
19
|
* var options = {
|
|
20
|
-
* obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]])
|
|
20
|
+
* obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]]).geometry
|
|
21
21
|
* };
|
|
22
22
|
*
|
|
23
23
|
* var path = turf.shortestPath(start, end, options);
|
package/dist/esm/index.js
CHANGED
|
@@ -283,14 +283,11 @@ BinaryHeap.prototype = {
|
|
|
283
283
|
// index.ts
|
|
284
284
|
function shortestPath(start, end, options = {}) {
|
|
285
285
|
options = options || {};
|
|
286
|
-
if (!isObject(options))
|
|
287
|
-
throw new Error("options is invalid");
|
|
286
|
+
if (!isObject(options)) throw new Error("options is invalid");
|
|
288
287
|
let obstacles = options.obstacles || featureCollection([]);
|
|
289
288
|
let resolution = options.resolution || 100;
|
|
290
|
-
if (!start)
|
|
291
|
-
|
|
292
|
-
if (!end)
|
|
293
|
-
throw new Error("end is required");
|
|
289
|
+
if (!start) throw new Error("start is required");
|
|
290
|
+
if (!end) throw new Error("end is required");
|
|
294
291
|
if (resolution && (!isNumber(resolution) || resolution <= 0))
|
|
295
292
|
throw new Error("options.resolution must be a number, greater than 0");
|
|
296
293
|
const startCoord = getCoord(start);
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts","../../lib/javascript-astar.js"],"sourcesContent":["import {\n Polygon,\n Feature,\n FeatureCollection,\n LineString,\n Geometry,\n Point,\n} from \"geojson\";\nimport { bbox } from \"@turf/bbox\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { distance } from \"@turf/distance\";\nimport { transformScale as scale } from \"@turf/transform-scale\";\nimport { cleanCoords } from \"@turf/clean-coords\";\nimport { bboxPolygon } from \"@turf/bbox-polygon\";\nimport { getCoord, getGeom } from \"@turf/invariant\";\nimport {\n Coord,\n Units,\n point,\n isNumber,\n lineString,\n isObject,\n featureCollection,\n feature,\n} from \"@turf/helpers\";\nimport { Graph, GridNode, astar } from \"./lib/javascript-astar.js\";\n\n/**\n * Returns the shortest {@link LineString|path} from {@link Point|start} to {@link Point|end} without colliding with\n * any {@link Feature} in {@link FeatureCollection<Polygon>| obstacles}\n *\n * @name shortestPath\n * @param {Coord} start point\n * @param {Coord} end point\n * @param {Object} [options={}] optional parameters\n * @param {Geometry|Feature|FeatureCollection<Polygon>} [options.obstacles] areas which path cannot travel\n * @param {string} [options.units='kilometers'] unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ...\n * @param {number} [options.resolution=100] distance between matrix points on which the path will be calculated\n * @returns {Feature<LineString>} shortest path between start and end\n * @example\n * var start = [-5, -6];\n * var end = [9, -6];\n * var options = {\n * obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]])\n * };\n *\n * var path = turf.shortestPath(start, end, options);\n *\n * //addToMap\n * var addToMap = [start, end, options.obstacles, path];\n */\nfunction shortestPath(\n start: Coord,\n end: Coord,\n options: {\n obstacles?: Polygon | Feature<Polygon> | FeatureCollection<Polygon>;\n units?: Units;\n resolution?: number;\n } = {}\n): Feature<LineString> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n let obstacles = options.obstacles || featureCollection([]);\n let resolution = options.resolution || 100;\n\n // validation\n if (!start) throw new Error(\"start is required\");\n if (!end) throw new Error(\"end is required\");\n if (resolution && (!isNumber(resolution) || resolution <= 0))\n throw new Error(\"options.resolution must be a number, greater than 0\");\n\n // Normalize Inputs\n const startCoord = getCoord(start);\n const endCoord = getCoord(end);\n start = point(startCoord);\n end = point(endCoord);\n\n // Handle obstacles\n if (obstacles.type === \"FeatureCollection\") {\n if (obstacles.features.length === 0) {\n return lineString([startCoord, endCoord]);\n }\n } else if (obstacles.type === \"Polygon\") {\n obstacles = featureCollection([feature(getGeom(obstacles))]);\n } else {\n throw new Error(\"invalid obstacles\");\n }\n\n // define path grid area\n const collection: FeatureCollection<Geometry> = obstacles;\n collection.features.push(start);\n collection.features.push(end);\n const box = bbox(scale(bboxPolygon(bbox(collection)), 1.15)); // extend 15%\n const [west, south, east, north] = box;\n\n const width = distance([west, south], [east, south], options);\n const division = width / resolution;\n\n collection.features.pop();\n collection.features.pop();\n\n const xFraction = division / distance([west, south], [east, south], options);\n const cellWidth = xFraction * (east - west);\n const yFraction = division / distance([west, south], [west, north], options);\n const cellHeight = yFraction * (north - south);\n\n const bboxHorizontalSide = east - west;\n const bboxVerticalSide = north - south;\n const columns = Math.floor(bboxHorizontalSide / cellWidth);\n const rows = Math.floor(bboxVerticalSide / cellHeight);\n // adjust origin of the grid\n const deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;\n const deltaY = (bboxVerticalSide - rows * cellHeight) / 2;\n\n // loop through points only once to speed up process\n // define matrix grid for A-star algorithm\n const pointMatrix: string[][] = [];\n const matrix: number[][] = [];\n\n let closestToStart: GridNode;\n let closestToEnd: GridNode;\n let minDistStart = Infinity;\n let minDistEnd = Infinity;\n let currentY = north - deltaY;\n let r = 0;\n while (currentY >= south) {\n // var currentY = south + deltaY;\n const matrixRow = [];\n const pointMatrixRow = [];\n let currentX = west + deltaX;\n let c = 0;\n while (currentX <= east) {\n const pt = point([currentX, currentY]);\n const isInsideObstacle = isInside(pt, obstacles);\n // feed obstacles matrix\n matrixRow.push(isInsideObstacle ? 0 : 1); // with javascript-astar\n // matrixRow.push(isInsideObstacle ? 1 : 0); // with astar-andrea\n // map point's coords\n pointMatrixRow.push(currentX + \"|\" + currentY);\n // set closest points\n const distStart = distance(pt, start);\n // if (distStart < minDistStart) {\n if (!isInsideObstacle && distStart < minDistStart) {\n minDistStart = distStart;\n closestToStart = { x: c, y: r };\n }\n const distEnd = distance(pt, end);\n // if (distEnd < minDistEnd) {\n if (!isInsideObstacle && distEnd < minDistEnd) {\n minDistEnd = distEnd;\n closestToEnd = { x: c, y: r };\n }\n currentX += cellWidth;\n c++;\n }\n matrix.push(matrixRow);\n pointMatrix.push(pointMatrixRow);\n currentY -= cellHeight;\n r++;\n }\n\n // find path on matrix grid\n\n // javascript-astar ----------------------\n const graph = new Graph(matrix, { diagonal: true });\n const startOnMatrix = graph.grid[closestToStart!.y][closestToStart!.x];\n const endOnMatrix = graph.grid[closestToEnd!.y][closestToEnd!.x];\n const result: GridNode[] = astar.search(graph, startOnMatrix, endOnMatrix);\n\n const path = [startCoord];\n result.forEach(function (coord) {\n const coords = pointMatrix[coord.x][coord.y].split(\"|\");\n path.push([+coords[0], +coords[1]]); // make sure coords are numbers\n });\n path.push(endCoord);\n // ---------------------------------------\n\n // astar-andrea ------------------------\n // var result = aStar(matrix, [closestToStart.x, closestToStart.y], [closestToEnd.x, closestToEnd.y], 'DiagonalFree');\n // var path = [start.geometry.coordinates];\n // result.forEach(function (coord) {\n // var coords = pointMatrix[coord[1]][coord[0]].split('|');\n // path.push([+coords[0], +coords[1]]); // make sure coords are numbers\n // });\n // path.push(end.geometry.coordinates);\n // ---------------------------------------\n\n return cleanCoords(lineString(path));\n}\n\n/**\n * Checks if Point is inside any of the Polygons\n *\n * @private\n * @param {Feature<Point>} pt to check\n * @param {FeatureCollection<Polygon>} polygons features\n * @returns {boolean} if inside or not\n */\nfunction isInside(pt: Feature<Point>, polygons: FeatureCollection<Polygon>) {\n for (let i = 0; i < polygons.features.length; i++) {\n if (booleanPointInPolygon(pt, polygons.features[i])) {\n return true;\n }\n }\n return false;\n}\n\nexport { shortestPath };\nexport default shortestPath;\n","// javascript-astar 0.4.1\n// http://github.com/bgrins/javascript-astar\n// Freely distributable under the MIT License.\n// Implements the astar search algorithm in javascript using a Binary Heap.\n// Includes Binary Heap (with modifications) from Marijn Haverbeke.\n// http://eloquentjavascript.net/appendix2.html\n\nfunction pathTo(node) {\n var curr = node,\n path = [];\n while (curr.parent) {\n path.unshift(curr);\n curr = curr.parent;\n }\n return path;\n}\n\nfunction getHeap() {\n return new BinaryHeap(function (node) {\n return node.f;\n });\n}\n\n/**\n * Astar\n * @private\n */\nexport var astar = {\n /**\n * Perform an A* Search on a graph given a start and end node.\n *\n * @private\n * @memberof astar\n * @param {Graph} graph Graph\n * @param {GridNode} start Start\n * @param {GridNode} end End\n * @param {Object} [options] Options\n * @param {bool} [options.closest] Specifies whether to return the path to the closest node if the target is unreachable.\n * @param {Function} [options.heuristic] Heuristic function (see astar.heuristics).\n * @returns {Object} Search\n */\n search: function (graph, start, end, options) {\n graph.cleanDirty();\n options = options || {};\n var heuristic = options.heuristic || astar.heuristics.manhattan,\n closest = options.closest ?? false;\n\n var openHeap = getHeap(),\n closestNode = start; // set the start node to be the closest if required\n\n start.h = heuristic(start, end);\n\n openHeap.push(start);\n\n while (openHeap.size() > 0) {\n // Grab the lowest f(x) to process next. Heap keeps this sorted for us.\n var currentNode = openHeap.pop();\n\n // End case -- result has been found, return the traced path.\n if (currentNode === end) {\n return pathTo(currentNode);\n }\n\n // Normal case -- move currentNode from open to closed, process each of its neighbors.\n currentNode.closed = true;\n\n // Find all neighbors for the current node.\n var neighbors = graph.neighbors(currentNode);\n\n for (var i = 0, il = neighbors.length; i < il; ++i) {\n var neighbor = neighbors[i];\n\n if (neighbor.closed || neighbor.isWall()) {\n // Not a valid node to process, skip to next neighbor.\n continue;\n }\n\n // The g score is the shortest distance from start to current node.\n // We need to check if the path we have arrived at this neighbor is the shortest one we have seen yet.\n var gScore = currentNode.g + neighbor.getCost(currentNode),\n beenVisited = neighbor.visited;\n\n if (!beenVisited || gScore < neighbor.g) {\n // Found an optimal (so far) path to this node. Take score for node to see how good it is.\n neighbor.visited = true;\n neighbor.parent = currentNode;\n neighbor.h = neighbor.h || heuristic(neighbor, end);\n neighbor.g = gScore;\n neighbor.f = neighbor.g + neighbor.h;\n graph.markDirty(neighbor);\n if (closest) {\n // If the neighbour is closer than the current closestNode or if it's equally close but has\n // a cheaper path than the current closest node then it becomes the closest node\n if (\n neighbor.h < closestNode.h ||\n (neighbor.h === closestNode.h && neighbor.g < closestNode.g)\n ) {\n closestNode = neighbor;\n }\n }\n\n if (!beenVisited) {\n // Pushing to heap will put it in proper place based on the 'f' value.\n openHeap.push(neighbor);\n } else {\n // Already seen the node, but since it has been rescored we need to reorder it in the heap\n openHeap.rescoreElement(neighbor);\n }\n }\n }\n }\n\n if (closest) {\n return pathTo(closestNode);\n }\n\n // No result was found - empty array signifies failure to find path.\n return [];\n },\n // See list of heuristics: http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html\n heuristics: {\n manhattan: function (pos0, pos1) {\n var d1 = Math.abs(pos1.x - pos0.x);\n var d2 = Math.abs(pos1.y - pos0.y);\n return d1 + d2;\n },\n diagonal: function (pos0, pos1) {\n var D = 1;\n var D2 = Math.sqrt(2);\n var d1 = Math.abs(pos1.x - pos0.x);\n var d2 = Math.abs(pos1.y - pos0.y);\n return D * (d1 + d2) + (D2 - 2 * D) * Math.min(d1, d2);\n },\n },\n cleanNode: function (node) {\n node.f = 0;\n node.g = 0;\n node.h = 0;\n node.visited = false;\n node.closed = false;\n node.parent = null;\n },\n};\n\n/**\n * A graph memory structure\n *\n * @private\n * @param {Array} gridIn 2D array of input weights\n * @param {Object} [options] Options\n * @param {boolean} [options.diagonal] Specifies whether diagonal moves are allowed\n * @returns {void} Graph\n */\nexport function Graph(gridIn, options) {\n options = options || {};\n this.nodes = [];\n this.diagonal = !!options.diagonal;\n this.grid = [];\n for (var x = 0; x < gridIn.length; x++) {\n this.grid[x] = [];\n\n for (var y = 0, row = gridIn[x]; y < row.length; y++) {\n var node = new GridNode(x, y, row[y]);\n this.grid[x][y] = node;\n this.nodes.push(node);\n }\n }\n this.init();\n}\n\nGraph.prototype.init = function () {\n this.dirtyNodes = [];\n for (var i = 0; i < this.nodes.length; i++) {\n astar.cleanNode(this.nodes[i]);\n }\n};\n\nGraph.prototype.cleanDirty = function () {\n for (var i = 0; i < this.dirtyNodes.length; i++) {\n astar.cleanNode(this.dirtyNodes[i]);\n }\n this.dirtyNodes = [];\n};\n\nGraph.prototype.markDirty = function (node) {\n this.dirtyNodes.push(node);\n};\n\nGraph.prototype.neighbors = function (node) {\n var ret = [],\n x = node.x,\n y = node.y,\n grid = this.grid;\n\n // West\n if (grid[x - 1] && grid[x - 1][y]) {\n ret.push(grid[x - 1][y]);\n }\n\n // East\n if (grid[x + 1] && grid[x + 1][y]) {\n ret.push(grid[x + 1][y]);\n }\n\n // South\n if (grid[x] && grid[x][y - 1]) {\n ret.push(grid[x][y - 1]);\n }\n\n // North\n if (grid[x] && grid[x][y + 1]) {\n ret.push(grid[x][y + 1]);\n }\n\n if (this.diagonal) {\n // Southwest\n if (grid[x - 1] && grid[x - 1][y - 1]) {\n ret.push(grid[x - 1][y - 1]);\n }\n\n // Southeast\n if (grid[x + 1] && grid[x + 1][y - 1]) {\n ret.push(grid[x + 1][y - 1]);\n }\n\n // Northwest\n if (grid[x - 1] && grid[x - 1][y + 1]) {\n ret.push(grid[x - 1][y + 1]);\n }\n\n // Northeast\n if (grid[x + 1] && grid[x + 1][y + 1]) {\n ret.push(grid[x + 1][y + 1]);\n }\n }\n\n return ret;\n};\n\nGraph.prototype.toString = function () {\n var graphString = [],\n nodes = this.grid, // when using grid\n rowDebug,\n row,\n y,\n l;\n for (var x = 0, len = nodes.length; x < len; x++) {\n rowDebug = [];\n row = nodes[x];\n for (y = 0, l = row.length; y < l; y++) {\n rowDebug.push(row[y].weight);\n }\n graphString.push(rowDebug.join(\" \"));\n }\n return graphString.join(\"\\n\");\n};\n\nfunction GridNode(x, y, weight) {\n this.x = x;\n this.y = y;\n this.weight = weight;\n}\n\nGridNode.prototype.toString = function () {\n return \"[\" + this.x + \" \" + this.y + \"]\";\n};\n\nGridNode.prototype.getCost = function (fromNeighbor) {\n // Take diagonal weight into consideration.\n if (fromNeighbor && fromNeighbor.x !== this.x && fromNeighbor.y !== this.y) {\n return this.weight * 1.41421;\n }\n return this.weight;\n};\n\nGridNode.prototype.isWall = function () {\n return this.weight === 0;\n};\n\nfunction BinaryHeap(scoreFunction) {\n this.content = [];\n this.scoreFunction = scoreFunction;\n}\n\nBinaryHeap.prototype = {\n push: function (element) {\n // Add the new element to the end of the array.\n this.content.push(element);\n\n // Allow it to sink down.\n this.sinkDown(this.content.length - 1);\n },\n pop: function () {\n // Store the first element so we can return it later.\n var result = this.content[0];\n // Get the element at the end of the array.\n var end = this.content.pop();\n // If there are any elements left, put the end element at the\n // start, and let it bubble up.\n if (this.content.length > 0) {\n this.content[0] = end;\n this.bubbleUp(0);\n }\n return result;\n },\n remove: function (node) {\n var i = this.content.indexOf(node);\n\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n var end = this.content.pop();\n\n if (i !== this.content.length - 1) {\n this.content[i] = end;\n\n if (this.scoreFunction(end) < this.scoreFunction(node)) {\n this.sinkDown(i);\n } else {\n this.bubbleUp(i);\n }\n }\n },\n size: function () {\n return this.content.length;\n },\n rescoreElement: function (node) {\n this.sinkDown(this.content.indexOf(node));\n },\n sinkDown: function (n) {\n // Fetch the element that has to be sunk.\n var element = this.content[n];\n\n // When at 0, an element can not sink any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n var parentN = ((n + 1) >> 1) - 1,\n parent = this.content[parentN];\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[parentN] = element;\n this.content[n] = parent;\n // Update 'n' to continue at the new position.\n n = parentN;\n // Found a parent that is less, no need to sink any further.\n } else {\n break;\n }\n }\n },\n bubbleUp: function (n) {\n // Look up the target element and its score.\n var length = this.content.length,\n element = this.content[n],\n elemScore = this.scoreFunction(element);\n\n while (true) {\n // Compute the indices of the child elements.\n var child2N = (n + 1) << 1,\n child1N = child2N - 1;\n // This is used to store the new position of the element, if any.\n var swap = null,\n child1Score;\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n var child1 = this.content[child1N];\n child1Score = this.scoreFunction(child1);\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) {\n swap = child1N;\n }\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n var child2 = this.content[child2N],\n child2Score = this.scoreFunction(child2);\n if (child2Score < (swap === null ? elemScore : child1Score)) {\n swap = child2N;\n }\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[n] = this.content[swap];\n this.content[swap] = element;\n n = swap;\n // Otherwise, we are done.\n } else {\n break;\n }\n }\n },\n};\n"],"mappings":";AAQA,SAAS,YAAY;AACrB,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AACzB,SAAS,kBAAkB,aAAa;AACxC,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,UAAU,eAAe;AAClC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACjBP,SAAS,OAAO,MAAM;AACpB,MAAI,OAAO,MACT,OAAO,CAAC;AACV,SAAO,KAAK,QAAQ;AAClB,SAAK,QAAQ,IAAI;AACjB,WAAO,KAAK;AAAA,EACd;AACA,SAAO;AACT;AAEA,SAAS,UAAU;AACjB,SAAO,IAAI,WAAW,SAAU,MAAM;AACpC,WAAO,KAAK;AAAA,EACd,CAAC;AACH;AAMO,IAAI,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcjB,QAAQ,SAA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ACpC,CAAC;AACD,OAAK,KAAK,QAAQ;AAalB,SAAO,YAAY,WAAW,IAAI,CAAC;AACrC;AAUA,SAAS,SAAS,IAAoB,UAAsC;AAC1E,WAAS,IAAI,GAAG,IAAI,SAAS,SAAS,QAAQ,KAAK;AACjD,QAAI,sBAAsB,IAAI,SAAS,SAAS,CAAC,CAAC,GAAG;AACnD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAGA,IAAO,6BAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../index.ts","../../lib/javascript-astar.js"],"sourcesContent":["import {\n Polygon,\n Feature,\n FeatureCollection,\n LineString,\n Geometry,\n Point,\n} from \"geojson\";\nimport { bbox } from \"@turf/bbox\";\nimport { booleanPointInPolygon } from \"@turf/boolean-point-in-polygon\";\nimport { distance } from \"@turf/distance\";\nimport { transformScale as scale } from \"@turf/transform-scale\";\nimport { cleanCoords } from \"@turf/clean-coords\";\nimport { bboxPolygon } from \"@turf/bbox-polygon\";\nimport { getCoord, getGeom } from \"@turf/invariant\";\nimport {\n Coord,\n Units,\n point,\n isNumber,\n lineString,\n isObject,\n featureCollection,\n feature,\n} from \"@turf/helpers\";\nimport { Graph, GridNode, astar } from \"./lib/javascript-astar.js\";\n\n/**\n * Returns the shortest {@link LineString|path} from {@link Point|start} to {@link Point|end} without colliding with\n * any {@link Feature} in obstacles {@link FeatureCollection}<{@link Polygon}>\n *\n * @function\n * @param {Coord} start point\n * @param {Coord} end point\n * @param {Object} [options={}] optional parameters\n * @param {Polygon|Feature<Polygon>|FeatureCollection<Polygon>} [options.obstacles] areas which path cannot travel\n * @param {Units} [options.units='kilometers'] unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ...\n * @param {number} [options.resolution=100] distance between matrix points on which the path will be calculated\n * @returns {Feature<LineString>} shortest path between start and end\n * @example\n * var start = [-5, -6];\n * var end = [9, -6];\n * var options = {\n * obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]]).geometry\n * };\n *\n * var path = turf.shortestPath(start, end, options);\n *\n * //addToMap\n * var addToMap = [start, end, options.obstacles, path];\n */\nfunction shortestPath(\n start: Coord,\n end: Coord,\n options: {\n obstacles?: Polygon | Feature<Polygon> | FeatureCollection<Polygon>;\n units?: Units;\n resolution?: number;\n } = {}\n): Feature<LineString> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n let obstacles = options.obstacles || featureCollection([]);\n let resolution = options.resolution || 100;\n\n // validation\n if (!start) throw new Error(\"start is required\");\n if (!end) throw new Error(\"end is required\");\n if (resolution && (!isNumber(resolution) || resolution <= 0))\n throw new Error(\"options.resolution must be a number, greater than 0\");\n\n // Normalize Inputs\n const startCoord = getCoord(start);\n const endCoord = getCoord(end);\n start = point(startCoord);\n end = point(endCoord);\n\n // Handle obstacles\n if (obstacles.type === \"FeatureCollection\") {\n if (obstacles.features.length === 0) {\n return lineString([startCoord, endCoord]);\n }\n } else if (obstacles.type === \"Polygon\") {\n obstacles = featureCollection([feature(getGeom(obstacles))]);\n } else {\n throw new Error(\"invalid obstacles\");\n }\n\n // define path grid area\n const collection: FeatureCollection<Geometry> = obstacles;\n collection.features.push(start);\n collection.features.push(end);\n const box = bbox(scale(bboxPolygon(bbox(collection)), 1.15)); // extend 15%\n const [west, south, east, north] = box;\n\n const width = distance([west, south], [east, south], options);\n const division = width / resolution;\n\n collection.features.pop();\n collection.features.pop();\n\n const xFraction = division / distance([west, south], [east, south], options);\n const cellWidth = xFraction * (east - west);\n const yFraction = division / distance([west, south], [west, north], options);\n const cellHeight = yFraction * (north - south);\n\n const bboxHorizontalSide = east - west;\n const bboxVerticalSide = north - south;\n const columns = Math.floor(bboxHorizontalSide / cellWidth);\n const rows = Math.floor(bboxVerticalSide / cellHeight);\n // adjust origin of the grid\n const deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;\n const deltaY = (bboxVerticalSide - rows * cellHeight) / 2;\n\n // loop through points only once to speed up process\n // define matrix grid for A-star algorithm\n const pointMatrix: string[][] = [];\n const matrix: number[][] = [];\n\n let closestToStart: GridNode;\n let closestToEnd: GridNode;\n let minDistStart = Infinity;\n let minDistEnd = Infinity;\n let currentY = north - deltaY;\n let r = 0;\n while (currentY >= south) {\n // var currentY = south + deltaY;\n const matrixRow = [];\n const pointMatrixRow = [];\n let currentX = west + deltaX;\n let c = 0;\n while (currentX <= east) {\n const pt = point([currentX, currentY]);\n const isInsideObstacle = isInside(pt, obstacles);\n // feed obstacles matrix\n matrixRow.push(isInsideObstacle ? 0 : 1); // with javascript-astar\n // matrixRow.push(isInsideObstacle ? 1 : 0); // with astar-andrea\n // map point's coords\n pointMatrixRow.push(currentX + \"|\" + currentY);\n // set closest points\n const distStart = distance(pt, start);\n // if (distStart < minDistStart) {\n if (!isInsideObstacle && distStart < minDistStart) {\n minDistStart = distStart;\n closestToStart = { x: c, y: r };\n }\n const distEnd = distance(pt, end);\n // if (distEnd < minDistEnd) {\n if (!isInsideObstacle && distEnd < minDistEnd) {\n minDistEnd = distEnd;\n closestToEnd = { x: c, y: r };\n }\n currentX += cellWidth;\n c++;\n }\n matrix.push(matrixRow);\n pointMatrix.push(pointMatrixRow);\n currentY -= cellHeight;\n r++;\n }\n\n // find path on matrix grid\n\n // javascript-astar ----------------------\n const graph = new Graph(matrix, { diagonal: true });\n const startOnMatrix = graph.grid[closestToStart!.y][closestToStart!.x];\n const endOnMatrix = graph.grid[closestToEnd!.y][closestToEnd!.x];\n const result: GridNode[] = astar.search(graph, startOnMatrix, endOnMatrix);\n\n const path = [startCoord];\n result.forEach(function (coord) {\n const coords = pointMatrix[coord.x][coord.y].split(\"|\");\n path.push([+coords[0], +coords[1]]); // make sure coords are numbers\n });\n path.push(endCoord);\n // ---------------------------------------\n\n // astar-andrea ------------------------\n // var result = aStar(matrix, [closestToStart.x, closestToStart.y], [closestToEnd.x, closestToEnd.y], 'DiagonalFree');\n // var path = [start.geometry.coordinates];\n // result.forEach(function (coord) {\n // var coords = pointMatrix[coord[1]][coord[0]].split('|');\n // path.push([+coords[0], +coords[1]]); // make sure coords are numbers\n // });\n // path.push(end.geometry.coordinates);\n // ---------------------------------------\n\n return cleanCoords(lineString(path));\n}\n\n/**\n * Checks if Point is inside any of the Polygons\n *\n * @private\n * @param {Feature<Point>} pt to check\n * @param {FeatureCollection<Polygon>} polygons features\n * @returns {boolean} if inside or not\n */\nfunction isInside(pt: Feature<Point>, polygons: FeatureCollection<Polygon>) {\n for (let i = 0; i < polygons.features.length; i++) {\n if (booleanPointInPolygon(pt, polygons.features[i])) {\n return true;\n }\n }\n return false;\n}\n\nexport { shortestPath };\nexport default shortestPath;\n","// javascript-astar 0.4.1\n// http://github.com/bgrins/javascript-astar\n// Freely distributable under the MIT License.\n// Implements the astar search algorithm in javascript using a Binary Heap.\n// Includes Binary Heap (with modifications) from Marijn Haverbeke.\n// http://eloquentjavascript.net/appendix2.html\n\nfunction pathTo(node) {\n var curr = node,\n path = [];\n while (curr.parent) {\n path.unshift(curr);\n curr = curr.parent;\n }\n return path;\n}\n\nfunction getHeap() {\n return new BinaryHeap(function (node) {\n return node.f;\n });\n}\n\n/**\n * Astar\n * @private\n */\nexport var astar = {\n /**\n * Perform an A* Search on a graph given a start and end node.\n *\n * @private\n * @memberof astar\n * @param {Graph} graph Graph\n * @param {GridNode} start Start\n * @param {GridNode} end End\n * @param {Object} [options] Options\n * @param {bool} [options.closest] Specifies whether to return the path to the closest node if the target is unreachable.\n * @param {Function} [options.heuristic] Heuristic function (see astar.heuristics).\n * @returns {Object} Search\n */\n search: function (graph, start, end, options) {\n graph.cleanDirty();\n options = options || {};\n var heuristic = options.heuristic || astar.heuristics.manhattan,\n closest = options.closest ?? false;\n\n var openHeap = getHeap(),\n closestNode = start; // set the start node to be the closest if required\n\n start.h = heuristic(start, end);\n\n openHeap.push(start);\n\n while (openHeap.size() > 0) {\n // Grab the lowest f(x) to process next. Heap keeps this sorted for us.\n var currentNode = openHeap.pop();\n\n // End case -- result has been found, return the traced path.\n if (currentNode === end) {\n return pathTo(currentNode);\n }\n\n // Normal case -- move currentNode from open to closed, process each of its neighbors.\n currentNode.closed = true;\n\n // Find all neighbors for the current node.\n var neighbors = graph.neighbors(currentNode);\n\n for (var i = 0, il = neighbors.length; i < il; ++i) {\n var neighbor = neighbors[i];\n\n if (neighbor.closed || neighbor.isWall()) {\n // Not a valid node to process, skip to next neighbor.\n continue;\n }\n\n // The g score is the shortest distance from start to current node.\n // We need to check if the path we have arrived at this neighbor is the shortest one we have seen yet.\n var gScore = currentNode.g + neighbor.getCost(currentNode),\n beenVisited = neighbor.visited;\n\n if (!beenVisited || gScore < neighbor.g) {\n // Found an optimal (so far) path to this node. Take score for node to see how good it is.\n neighbor.visited = true;\n neighbor.parent = currentNode;\n neighbor.h = neighbor.h || heuristic(neighbor, end);\n neighbor.g = gScore;\n neighbor.f = neighbor.g + neighbor.h;\n graph.markDirty(neighbor);\n if (closest) {\n // If the neighbour is closer than the current closestNode or if it's equally close but has\n // a cheaper path than the current closest node then it becomes the closest node\n if (\n neighbor.h < closestNode.h ||\n (neighbor.h === closestNode.h && neighbor.g < closestNode.g)\n ) {\n closestNode = neighbor;\n }\n }\n\n if (!beenVisited) {\n // Pushing to heap will put it in proper place based on the 'f' value.\n openHeap.push(neighbor);\n } else {\n // Already seen the node, but since it has been rescored we need to reorder it in the heap\n openHeap.rescoreElement(neighbor);\n }\n }\n }\n }\n\n if (closest) {\n return pathTo(closestNode);\n }\n\n // No result was found - empty array signifies failure to find path.\n return [];\n },\n // See list of heuristics: http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html\n heuristics: {\n manhattan: function (pos0, pos1) {\n var d1 = Math.abs(pos1.x - pos0.x);\n var d2 = Math.abs(pos1.y - pos0.y);\n return d1 + d2;\n },\n diagonal: function (pos0, pos1) {\n var D = 1;\n var D2 = Math.sqrt(2);\n var d1 = Math.abs(pos1.x - pos0.x);\n var d2 = Math.abs(pos1.y - pos0.y);\n return D * (d1 + d2) + (D2 - 2 * D) * Math.min(d1, d2);\n },\n },\n cleanNode: function (node) {\n node.f = 0;\n node.g = 0;\n node.h = 0;\n node.visited = false;\n node.closed = false;\n node.parent = null;\n },\n};\n\n/**\n * A graph memory structure\n *\n * @private\n * @param {Array} gridIn 2D array of input weights\n * @param {Object} [options] Options\n * @param {boolean} [options.diagonal] Specifies whether diagonal moves are allowed\n * @returns {void} Graph\n */\nexport function Graph(gridIn, options) {\n options = options || {};\n this.nodes = [];\n this.diagonal = !!options.diagonal;\n this.grid = [];\n for (var x = 0; x < gridIn.length; x++) {\n this.grid[x] = [];\n\n for (var y = 0, row = gridIn[x]; y < row.length; y++) {\n var node = new GridNode(x, y, row[y]);\n this.grid[x][y] = node;\n this.nodes.push(node);\n }\n }\n this.init();\n}\n\nGraph.prototype.init = function () {\n this.dirtyNodes = [];\n for (var i = 0; i < this.nodes.length; i++) {\n astar.cleanNode(this.nodes[i]);\n }\n};\n\nGraph.prototype.cleanDirty = function () {\n for (var i = 0; i < this.dirtyNodes.length; i++) {\n astar.cleanNode(this.dirtyNodes[i]);\n }\n this.dirtyNodes = [];\n};\n\nGraph.prototype.markDirty = function (node) {\n this.dirtyNodes.push(node);\n};\n\nGraph.prototype.neighbors = function (node) {\n var ret = [],\n x = node.x,\n y = node.y,\n grid = this.grid;\n\n // West\n if (grid[x - 1] && grid[x - 1][y]) {\n ret.push(grid[x - 1][y]);\n }\n\n // East\n if (grid[x + 1] && grid[x + 1][y]) {\n ret.push(grid[x + 1][y]);\n }\n\n // South\n if (grid[x] && grid[x][y - 1]) {\n ret.push(grid[x][y - 1]);\n }\n\n // North\n if (grid[x] && grid[x][y + 1]) {\n ret.push(grid[x][y + 1]);\n }\n\n if (this.diagonal) {\n // Southwest\n if (grid[x - 1] && grid[x - 1][y - 1]) {\n ret.push(grid[x - 1][y - 1]);\n }\n\n // Southeast\n if (grid[x + 1] && grid[x + 1][y - 1]) {\n ret.push(grid[x + 1][y - 1]);\n }\n\n // Northwest\n if (grid[x - 1] && grid[x - 1][y + 1]) {\n ret.push(grid[x - 1][y + 1]);\n }\n\n // Northeast\n if (grid[x + 1] && grid[x + 1][y + 1]) {\n ret.push(grid[x + 1][y + 1]);\n }\n }\n\n return ret;\n};\n\nGraph.prototype.toString = function () {\n var graphString = [],\n nodes = this.grid, // when using grid\n rowDebug,\n row,\n y,\n l;\n for (var x = 0, len = nodes.length; x < len; x++) {\n rowDebug = [];\n row = nodes[x];\n for (y = 0, l = row.length; y < l; y++) {\n rowDebug.push(row[y].weight);\n }\n graphString.push(rowDebug.join(\" \"));\n }\n return graphString.join(\"\\n\");\n};\n\nfunction GridNode(x, y, weight) {\n this.x = x;\n this.y = y;\n this.weight = weight;\n}\n\nGridNode.prototype.toString = function () {\n return \"[\" + this.x + \" \" + this.y + \"]\";\n};\n\nGridNode.prototype.getCost = function (fromNeighbor) {\n // Take diagonal weight into consideration.\n if (fromNeighbor && fromNeighbor.x !== this.x && fromNeighbor.y !== this.y) {\n return this.weight * 1.41421;\n }\n return this.weight;\n};\n\nGridNode.prototype.isWall = function () {\n return this.weight === 0;\n};\n\nfunction BinaryHeap(scoreFunction) {\n this.content = [];\n this.scoreFunction = scoreFunction;\n}\n\nBinaryHeap.prototype = {\n push: function (element) {\n // Add the new element to the end of the array.\n this.content.push(element);\n\n // Allow it to sink down.\n this.sinkDown(this.content.length - 1);\n },\n pop: function () {\n // Store the first element so we can return it later.\n var result = this.content[0];\n // Get the element at the end of the array.\n var end = this.content.pop();\n // If there are any elements left, put the end element at the\n // start, and let it bubble up.\n if (this.content.length > 0) {\n this.content[0] = end;\n this.bubbleUp(0);\n }\n return result;\n },\n remove: function (node) {\n var i = this.content.indexOf(node);\n\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n var end = this.content.pop();\n\n if (i !== this.content.length - 1) {\n this.content[i] = end;\n\n if (this.scoreFunction(end) < this.scoreFunction(node)) {\n this.sinkDown(i);\n } else {\n this.bubbleUp(i);\n }\n }\n },\n size: function () {\n return this.content.length;\n },\n rescoreElement: function (node) {\n this.sinkDown(this.content.indexOf(node));\n },\n sinkDown: function (n) {\n // Fetch the element that has to be sunk.\n var element = this.content[n];\n\n // When at 0, an element can not sink any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n var parentN = ((n + 1) >> 1) - 1,\n parent = this.content[parentN];\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[parentN] = element;\n this.content[n] = parent;\n // Update 'n' to continue at the new position.\n n = parentN;\n // Found a parent that is less, no need to sink any further.\n } else {\n break;\n }\n }\n },\n bubbleUp: function (n) {\n // Look up the target element and its score.\n var length = this.content.length,\n element = this.content[n],\n elemScore = this.scoreFunction(element);\n\n while (true) {\n // Compute the indices of the child elements.\n var child2N = (n + 1) << 1,\n child1N = child2N - 1;\n // This is used to store the new position of the element, if any.\n var swap = null,\n child1Score;\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n var child1 = this.content[child1N];\n child1Score = this.scoreFunction(child1);\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) {\n swap = child1N;\n }\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n var child2 = this.content[child2N],\n child2Score = this.scoreFunction(child2);\n if (child2Score < (swap === null ? elemScore : child1Score)) {\n swap = child2N;\n }\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[n] = this.content[swap];\n this.content[swap] = element;\n n = swap;\n // Otherwise, we are done.\n } else {\n break;\n }\n }\n },\n};\n"],"mappings":";AAQA,SAAS,YAAY;AACrB,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AACzB,SAAS,kBAAkB,aAAa;AACxC,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,UAAU,eAAe;AAClC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACjBP,SAAS,OAAO,MAAM;AACpB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,CAAC;AACrE,QAAM,cAAc,MAAM,KAAK,aAAc,CAAC,EAAE,aAAc,CAAC;AAC/D,QAAM,SAAqB,MAAM,OAAO,OAAO,eAAe,WAAW;AAEzE,QAAM,OAAO,CAAC,UAAU;AACxB,SAAO,QAAQ,SAAU,OAAO;AAC9B,UAAM,SAAS,YAAY,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG;AACtD,SAAK,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAAA,EACpC,CAAC;AACD,OAAK,KAAK,QAAQ;AAalB,SAAO,YAAY,WAAW,IAAI,CAAC;AACrC;AAUA,SAAS,SAAS,IAAoB,UAAsC;AAC1E,WAAS,IAAI,GAAG,IAAI,SAAS,SAAS,QAAQ,KAAK;AACjD,QAAI,sBAAsB,IAAI,SAAS,SAAS,CAAC,CAAC,GAAG;AACnD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAGA,IAAO,6BAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/shortest-path",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "turf shortest-path module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -55,30 +55,30 @@
|
|
|
55
55
|
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@turf/truncate": "^7.
|
|
58
|
+
"@turf/truncate": "^7.2.0",
|
|
59
59
|
"@types/benchmark": "^2.1.5",
|
|
60
|
-
"@types/tape": "^4.
|
|
60
|
+
"@types/tape": "^4.13.4",
|
|
61
61
|
"benchmark": "^2.1.4",
|
|
62
62
|
"load-json-file": "^7.0.1",
|
|
63
63
|
"npm-run-all": "^4.1.5",
|
|
64
|
-
"tape": "^5.
|
|
65
|
-
"tsup": "^8.
|
|
66
|
-
"tsx": "^4.
|
|
67
|
-
"typescript": "^5.
|
|
64
|
+
"tape": "^5.9.0",
|
|
65
|
+
"tsup": "^8.3.5",
|
|
66
|
+
"tsx": "^4.19.2",
|
|
67
|
+
"typescript": "^5.5.4",
|
|
68
68
|
"write-json-file": "^5.0.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@turf/bbox": "^7.
|
|
72
|
-
"@turf/bbox-polygon": "^7.
|
|
73
|
-
"@turf/boolean-point-in-polygon": "^7.
|
|
74
|
-
"@turf/clean-coords": "^7.
|
|
75
|
-
"@turf/distance": "^7.
|
|
76
|
-
"@turf/helpers": "^7.
|
|
77
|
-
"@turf/invariant": "^7.
|
|
78
|
-
"@turf/meta": "^7.
|
|
79
|
-
"@turf/transform-scale": "^7.
|
|
71
|
+
"@turf/bbox": "^7.2.0",
|
|
72
|
+
"@turf/bbox-polygon": "^7.2.0",
|
|
73
|
+
"@turf/boolean-point-in-polygon": "^7.2.0",
|
|
74
|
+
"@turf/clean-coords": "^7.2.0",
|
|
75
|
+
"@turf/distance": "^7.2.0",
|
|
76
|
+
"@turf/helpers": "^7.2.0",
|
|
77
|
+
"@turf/invariant": "^7.2.0",
|
|
78
|
+
"@turf/meta": "^7.2.0",
|
|
79
|
+
"@turf/transform-scale": "^7.2.0",
|
|
80
80
|
"@types/geojson": "^7946.0.10",
|
|
81
|
-
"tslib": "^2.
|
|
81
|
+
"tslib": "^2.8.1"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867"
|
|
84
84
|
}
|