描述
从任何 GeoJSON 几何图形中移除冗余坐标。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | Geometry | Feature | Feature 或 Geometry |
| options? | Object | 可选参数 (默认 {}) |
| options.mutate? | boolean | 允许 GeoJSON 输入被修改 (默认 false) |
返回值
Geometry | Feature 清理后的输入 Feature/Geometry
示例
javascript
var line = turf.lineString([
[0, 0],
[0, 2],
[0, 5],
[0, 8],
[0, 8],
[0, 10],
]);
var multiPoint = turf.multiPoint([
[0, 0],
[0, 0],
[2, 2],
]);
turf.cleanCoords(line).geometry.coordinates;
//= [[0, 0], [0, 10]]
turf.cleanCoords(multiPoint).geometry.coordinates;
//= [[0, 0], [2, 2]]安装
javascript
$ npm install @turf/clean-coords
import { cleanCoords } from "@turf/clean-coords";
const result = cleanCoords(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.cleanCoords(...);