shortestPath
描述
¥Description
Returns the shortest path from start to end without colliding with any 特性 in obstacles FeatureCollection<多边形>
¥Returns the shortest path from start to end without colliding with any Feature in obstacles FeatureCollection<Polygon>
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
start | 坐标系 | point |
end | 坐标系 | point |
options? | 对象 | 可选参数(默认 ) |
options.obstacles? | 多边形 | 特性<多边形> | FeatureCollection<多边形> | areas which path cannot travel |
options.units? | 单位 | unit in which resolution & minimum distance will be expressed in;it can be degrees, radians, miles, kilometers, ...(默认 'kilometers') |
options.resolution? | number | distance between matrix points on which the path will be calculated (default 100) |
返回
¥Returns
特性<LineString> shortest path between start and end
¥Feature<LineString> shortest path between start and end
示例
¥Examples
var start = [-5, -6];
var end = [9, -6];
var options = {
obstacles: turf.polygon([
[
[0, -7],
[5, -7],
[5, -3],
[0, -3],
[0, -7],
],
]).geometry,
};
var path = turf.shortestPath(start, end, options);
安装
¥Installation
$ npm install @turf/shortest-path
import { shortestPath } from "@turf/shortest-path";
const result = shortestPath(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.shortestPath(...);