@turf/shortest-path 7.0.0 → 7.1.0-alpha.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -12
- package/dist/cjs/index.cjs +1 -11
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +0 -10
- package/dist/esm/index.js.map +1 -1
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@ any [Feature][3] in [ obstacles][4]
|
|
|
13
13
|
* `end` **[Coord][5]** point
|
|
14
14
|
* `options` **[Object][6]** optional parameters (optional, default `{}`)
|
|
15
15
|
|
|
16
|
-
* `options.obstacles` **([Geometry][7] | [Feature][
|
|
17
|
-
* `options.units` **[string][
|
|
18
|
-
* `options.resolution` **[number][
|
|
16
|
+
* `options.obstacles` **([Geometry][7] | [Feature][3] | [FeatureCollection][8]<[Polygon][9]>)?** areas which path cannot travel
|
|
17
|
+
* `options.units` **[string][10]** unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ... (optional, default `'kilometers'`)
|
|
18
|
+
* `options.resolution` **[number][11]** distance between matrix points on which the path will be calculated (optional, default `100`)
|
|
19
19
|
|
|
20
20
|
### Examples
|
|
21
21
|
|
|
@@ -32,7 +32,7 @@ var path = turf.shortestPath(start, end, options);
|
|
|
32
32
|
var addToMap = [start, end, options.obstacles, path];
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Returns **[Feature][
|
|
35
|
+
Returns **[Feature][3]<[LineString][1]>** shortest path between start and end
|
|
36
36
|
|
|
37
37
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
38
38
|
|
|
@@ -48,17 +48,13 @@ Returns **[Feature][8]<[LineString][13]>** shortest path between start and end
|
|
|
48
48
|
|
|
49
49
|
[7]: https://tools.ietf.org/html/rfc7946#section-3.1
|
|
50
50
|
|
|
51
|
-
[8]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
51
|
+
[8]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
52
52
|
|
|
53
|
-
[9]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
53
|
+
[9]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
54
54
|
|
|
55
|
-
[10]: https://
|
|
55
|
+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
56
56
|
|
|
57
|
-
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
58
|
-
|
|
59
|
-
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
60
|
-
|
|
61
|
-
[13]: https://tools.ietf.org/html/rfc7946#section-3.1.4
|
|
57
|
+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
62
58
|
|
|
63
59
|
<!-- 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. -->
|
|
64
60
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// index.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
5
2
|
var _bbox = require('@turf/bbox');
|
|
6
3
|
var _booleanpointinpolygon = require('@turf/boolean-point-in-polygon');
|
|
7
4
|
var _distance = require('@turf/distance');
|
|
@@ -27,13 +24,11 @@ function pathTo(node) {
|
|
|
27
24
|
}
|
|
28
25
|
return path;
|
|
29
26
|
}
|
|
30
|
-
__name(pathTo, "pathTo");
|
|
31
27
|
function getHeap() {
|
|
32
28
|
return new BinaryHeap(function(node) {
|
|
33
29
|
return node.f;
|
|
34
30
|
});
|
|
35
31
|
}
|
|
36
|
-
__name(getHeap, "getHeap");
|
|
37
32
|
var astar = {
|
|
38
33
|
/**
|
|
39
34
|
* Perform an A* Search on a graph given a start and end node.
|
|
@@ -133,7 +128,6 @@ function Graph(gridIn, options) {
|
|
|
133
128
|
}
|
|
134
129
|
this.init();
|
|
135
130
|
}
|
|
136
|
-
__name(Graph, "Graph");
|
|
137
131
|
Graph.prototype.init = function() {
|
|
138
132
|
this.dirtyNodes = [];
|
|
139
133
|
for (var i = 0; i < this.nodes.length; i++) {
|
|
@@ -196,7 +190,6 @@ function GridNode(x, y, weight) {
|
|
|
196
190
|
this.y = y;
|
|
197
191
|
this.weight = weight;
|
|
198
192
|
}
|
|
199
|
-
__name(GridNode, "GridNode");
|
|
200
193
|
GridNode.prototype.toString = function() {
|
|
201
194
|
return "[" + this.x + " " + this.y + "]";
|
|
202
195
|
};
|
|
@@ -213,7 +206,6 @@ function BinaryHeap(scoreFunction) {
|
|
|
213
206
|
this.content = [];
|
|
214
207
|
this.scoreFunction = scoreFunction;
|
|
215
208
|
}
|
|
216
|
-
__name(BinaryHeap, "BinaryHeap");
|
|
217
209
|
BinaryHeap.prototype = {
|
|
218
210
|
push: function(element) {
|
|
219
211
|
this.content.push(element);
|
|
@@ -381,7 +373,6 @@ function shortestPath(start, end, options = {}) {
|
|
|
381
373
|
path.push(endCoord);
|
|
382
374
|
return _cleancoords.cleanCoords.call(void 0, _helpers.lineString.call(void 0, path));
|
|
383
375
|
}
|
|
384
|
-
__name(shortestPath, "shortestPath");
|
|
385
376
|
function isInside(pt, polygons) {
|
|
386
377
|
for (let i = 0; i < polygons.features.length; i++) {
|
|
387
378
|
if (_booleanpointinpolygon.booleanPointInPolygon.call(void 0, pt, polygons.features[i])) {
|
|
@@ -390,7 +381,6 @@ function isInside(pt, polygons) {
|
|
|
390
381
|
}
|
|
391
382
|
return false;
|
|
392
383
|
}
|
|
393
|
-
__name(isInside, "isInside");
|
|
394
384
|
var turf_shortest_path_default = shortestPath;
|
|
395
385
|
|
|
396
386
|
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@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AA,MAChC;AACA,YAAM,UAAU,SAAS,IAAI,GAAG;AAEhC,UAAI,CAAC,oBAAoB,UAAU,YAAY;AAC7C,qBAAa;AACb,uBAAe,EAAE,GAAG,GAAG,GAAG,EAAE;AAAA,MAC9B;AACA,kBAAY;AACZ;AAAA,IACF;AACA,WAAO,KAAK,SAAS;AACrB,gBAAY,KAAK,cAAc;AAC/B,gBAAY;AACZ;AAAA,EACF;AAKA,QAAM,QAAQ,IAAI,MAAM,QAAQ,EAAE,UAAU,KAAK,CAAC;AAClD,QAAM,gBAAgB,MAAM,KAAK,eAAgB,CAAC,EAAE,eAAgB,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;AA1IS;AAoJT,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;AAPS;AAUT,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":["../../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;AAzChD;AA0CI,UAAM,WAAW;AACjB,cAAU,WAAW,CAAC;AACtB,QAAI,YAAY,QAAQ,aAAa,MAAM,WAAW,WACpD,WAAU,aAAQ,YAAR,YAAmB;AAE/B,QAAI,WA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jD,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"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// index.ts
|
|
5
2
|
import { bbox } from "@turf/bbox";
|
|
6
3
|
import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
|
|
@@ -27,13 +24,11 @@ function pathTo(node) {
|
|
|
27
24
|
}
|
|
28
25
|
return path;
|
|
29
26
|
}
|
|
30
|
-
__name(pathTo, "pathTo");
|
|
31
27
|
function getHeap() {
|
|
32
28
|
return new BinaryHeap(function(node) {
|
|
33
29
|
return node.f;
|
|
34
30
|
});
|
|
35
31
|
}
|
|
36
|
-
__name(getHeap, "getHeap");
|
|
37
32
|
var astar = {
|
|
38
33
|
/**
|
|
39
34
|
* Perform an A* Search on a graph given a start and end node.
|
|
@@ -133,7 +128,6 @@ function Graph(gridIn, options) {
|
|
|
133
128
|
}
|
|
134
129
|
this.init();
|
|
135
130
|
}
|
|
136
|
-
__name(Graph, "Graph");
|
|
137
131
|
Graph.prototype.init = function() {
|
|
138
132
|
this.dirtyNodes = [];
|
|
139
133
|
for (var i = 0; i < this.nodes.length; i++) {
|
|
@@ -196,7 +190,6 @@ function GridNode(x, y, weight) {
|
|
|
196
190
|
this.y = y;
|
|
197
191
|
this.weight = weight;
|
|
198
192
|
}
|
|
199
|
-
__name(GridNode, "GridNode");
|
|
200
193
|
GridNode.prototype.toString = function() {
|
|
201
194
|
return "[" + this.x + " " + this.y + "]";
|
|
202
195
|
};
|
|
@@ -213,7 +206,6 @@ function BinaryHeap(scoreFunction) {
|
|
|
213
206
|
this.content = [];
|
|
214
207
|
this.scoreFunction = scoreFunction;
|
|
215
208
|
}
|
|
216
|
-
__name(BinaryHeap, "BinaryHeap");
|
|
217
209
|
BinaryHeap.prototype = {
|
|
218
210
|
push: function(element) {
|
|
219
211
|
this.content.push(element);
|
|
@@ -381,7 +373,6 @@ function shortestPath(start, end, options = {}) {
|
|
|
381
373
|
path.push(endCoord);
|
|
382
374
|
return cleanCoords(lineString(path));
|
|
383
375
|
}
|
|
384
|
-
__name(shortestPath, "shortestPath");
|
|
385
376
|
function isInside(pt, polygons) {
|
|
386
377
|
for (let i = 0; i < polygons.features.length; i++) {
|
|
387
378
|
if (booleanPointInPolygon(pt, polygons.features[i])) {
|
|
@@ -390,7 +381,6 @@ function isInside(pt, polygons) {
|
|
|
390
381
|
}
|
|
391
382
|
return false;
|
|
392
383
|
}
|
|
393
|
-
__name(isInside, "isInside");
|
|
394
384
|
var turf_shortest_path_default = shortestPath;
|
|
395
385
|
export {
|
|
396
386
|
turf_shortest_path_default as default,
|
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;AARS;AAUT,SAAS,UAAU;AACjB,SAAO,IAAI,WAAW,SAAU,MAAM;AACpC,WAAO,KAAK;AAAA,EACd,CAAC;AACH;AAJS;AAUF,IAAI,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAc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AAC,OAAO,CAAC,CAAC,CAAC;AAAA,EACpC,CAAC;AACD,OAAK,KAAK,QAAQ;AAalB,SAAO,YAAY,WAAW,IAAI,CAAC;AACrC;AA1IS;AAoJT,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;AAPS;AAUT,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 {@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;AAA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B,MAAM,KAAK,eAAgB,CAAC,EAAE,eAAgB,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.0.
|
|
3
|
+
"version": "7.1.0-alpha.70+948cdafaf",
|
|
4
4
|
"description": "turf shortest-path module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@turf/truncate": "^7.0.
|
|
58
|
+
"@turf/truncate": "^7.1.0-alpha.70+948cdafaf",
|
|
59
59
|
"@types/benchmark": "^2.1.5",
|
|
60
60
|
"@types/tape": "^4.2.32",
|
|
61
61
|
"benchmark": "^2.1.4",
|
|
@@ -68,16 +68,17 @@
|
|
|
68
68
|
"write-json-file": "^5.0.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@turf/bbox": "^7.0.
|
|
72
|
-
"@turf/bbox-polygon": "^7.0.
|
|
73
|
-
"@turf/boolean-point-in-polygon": "^7.0.
|
|
74
|
-
"@turf/clean-coords": "^7.0.
|
|
75
|
-
"@turf/distance": "^7.0.
|
|
76
|
-
"@turf/helpers": "^7.0.
|
|
77
|
-
"@turf/invariant": "^7.0.
|
|
78
|
-
"@turf/meta": "^7.0.
|
|
79
|
-
"@turf/transform-scale": "^7.0.
|
|
71
|
+
"@turf/bbox": "^7.1.0-alpha.70+948cdafaf",
|
|
72
|
+
"@turf/bbox-polygon": "^7.1.0-alpha.70+948cdafaf",
|
|
73
|
+
"@turf/boolean-point-in-polygon": "^7.1.0-alpha.70+948cdafaf",
|
|
74
|
+
"@turf/clean-coords": "^7.1.0-alpha.70+948cdafaf",
|
|
75
|
+
"@turf/distance": "^7.1.0-alpha.70+948cdafaf",
|
|
76
|
+
"@turf/helpers": "^7.1.0-alpha.70+948cdafaf",
|
|
77
|
+
"@turf/invariant": "^7.1.0-alpha.70+948cdafaf",
|
|
78
|
+
"@turf/meta": "^7.1.0-alpha.70+948cdafaf",
|
|
79
|
+
"@turf/transform-scale": "^7.1.0-alpha.70+948cdafaf",
|
|
80
|
+
"@types/geojson": "^7946.0.10",
|
|
80
81
|
"tslib": "^2.6.2"
|
|
81
82
|
},
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067"
|
|
83
84
|
}
|