描述
将 (Multi)LineString(s) 转换为 Polygon(s)。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| lines | FeatureCollection | Feature<LineString | MultiLineString> | 待转换的要素 |
| options? | Object | 可选参数 (默认 {}) |
| options.properties? | Object | 将 GeoJSON 属性转换到 Feature (默认 {}) |
| options.autoComplete? | boolean | 自动完成线段(匹配第一个和最后一个坐标) (默认 true) |
| options.orderCoords? | boolean | 排序线段以将外环放在坐标的第一个位置 (默认 true) |
| options.mutate? | boolean | 使用 autoComplete 修改原始线段(匹配第一个和最后一个坐标) (默认 false) |
返回值
Feature<Polygon | MultiPolygon> 转换为多边形
示例
javascript
var line = turf.lineString([
[125, -30],
[145, -30],
[145, -20],
[125, -20],
[125, -30],
]);
var polygon = turf.lineToPolygon(line);安装
javascript
$ npm install @turf/line-to-polygon
import { lineToPolygon } from "@turf/line-to-polygon";
const result = lineToPolygon(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.lineToPolygon(...);