polygonSmooth
描述
🌐 Description
平滑一个 多边形 或 多多边形。基于 Chaikin 算法。 警告:可能会生成退化多边形。
🌐 Smooths a Polygon or MultiPolygon. Based on Chaikin's algorithm. Warning: may create degenerate polygons.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| inputPolys | FeatureCollection<Polygon | MultiPolygon> | Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon | (多)多边形 平滑处理 |
| options? | Object | 可选参数 (默认 {}) |
| options.iterations? | string | 平滑多边形的次数。值越高,多边形越平滑。(默认值 1) |
返回
🌐 Returns
FeatureCollection<Polygon | MultiPolygon> 包含平滑多边形/多多边形的要素集合
示例
🌐 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(...);