Skip to content

KBE3D / KBCore / turf / lineToPolygon

函数: lineToPolygon()

lineToPolygon<G>(lines: G | Feature<G, GeoJsonProperties> | FeatureCollection<G, GeoJsonProperties>, options?: { properties?: GeoJsonProperties; autoComplete?: boolean; orderCoords?: boolean; mutate?: boolean; }): Feature<MultiPolygon, {[name: string]: any; } | null> | Feature<Polygon, {[name: string]: any; } | null>

Function

Converts (Multi)LineString(s) to Polygon(s).

类型参数

G

G extends LineString | MultiLineString

参数

lines

Features to convert

G | Feature<G, GeoJsonProperties> | FeatureCollection<G, GeoJsonProperties>

options?

Optional parameters

properties?

GeoJsonProperties

translates GeoJSON properties to Feature

autoComplete?

boolean

auto complete linestrings (matches first & last coordinates)

orderCoords?

boolean

sorts linestrings to place outer ring at the first position of the coordinates

mutate?

boolean

mutate the original linestring using autoComplete (matches first & last coordinates)

返回

Feature<MultiPolygon, {[name: string]: any; } | null> | Feature<Polygon, {[name: string]: any; } | null>

converted to Polygons

示例

ts
var line = turf.lineString([[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]);

var polygon = turf.lineToPolygon(line);

//addToMap
var addToMap = [polygon];

KBE3D @3.0.0 Copyright © 2024-present KBE3D