polygonSmooth
描述
¥Description
Smooths a 多边形 or MultiPolygon.基于 Chaikin 算法。警告:可能会创建退化多边形。
¥Smooths a Polygon or MultiPolygon. Based on Chaikin's algorithm. Warning: may create degenerate polygons.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
inputPolys | FeatureCollection<多边形 | MultiPolygon> | 特性<多边形 | MultiPolygon> | 多边形 | MultiPolygon | (多个)待平滑的多边形 |
options? | 对象 | 可选参数(默认 ) |
options.iterations? | string | The number of times to smooth the polygon.A higher value means a smoother polygon.(默认 1) |
返回
¥Returns
FeatureCollection<多边形 | MultiPolygon> FeatureCollection containing the smoothed polygon/multipoylgons
¥FeatureCollection<Polygon | MultiPolygon> FeatureCollection containing the smoothed polygon/multipoylgons
示例
¥Examples
var polygon = turf.polygon([
[
[11, 0],
[22, 4],
[31, 0],
[31, 11],
[21, 15],
[11, 11],
[11, 0],
],
]);
var smoothed = turf.polygonSmooth(polygon, { iterations: 3 });
安装
¥Installation
$ npm install @turf/polygon-smooth
import { polygonSmooth } from "@turf/polygon-smooth";
const result = polygonSmooth(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.polygonSmooth(...);