lineToPolygon
描述
¥Description
将(多)线串转换为多边形。
¥Converts (Multi)LineString(s) to Polygon(s).
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
lines | FeatureCollection | 特性<LineString | MultiLineString> | 要转换的要素 |
options? | 对象 | 可选参数(默认 ) |
options.properties? | 对象 | translates GeoJSON properties to Feature (default ) |
options.autoComplete? | boolean | auto complete linestrings (matches first & last coordinates) (default true) |
options.orderCoords? | boolean | sorts linestrings to place outer ring at the first position of the coordinates (default true) |
options.mutate? | boolean | mutate the original linestring using autoComplete (matches first & last coordinates) (default false) |
返回
¥Returns
特性<多边形 | MultiPolygon> converted to Polygons
¥Feature<Polygon | MultiPolygon> converted to Polygons
示例
¥Examples
var line = turf.lineString([
[125, -30],
[145, -30],
[145, -20],
[125, -20],
[125, -30],
]);
var polygon = turf.lineToPolygon(line);
安装
¥Installation
$ npm install @turf/line-to-polygon
import { lineToPolygon } from "@turf/line-to-polygon";
const result = lineToPolygon(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.lineToPolygon(...);