Skip to main content
Version: 7.2.0

cleanCoords

描述

¥Description

从任何 GeoJSON 几何体中删除冗余坐标。

¥Removes redundant coordinates from any GeoJSON Geometry.

参数

¥Parameters

名称类型描述
geojson几何图形 | 特性要素或几何图形
options?对象可选参数(默认 {})
options.mutate?boolean允许 GeoJSON 输入发生修改(默认 false)

返回

¥Returns

几何图形 | 特性 清理后的输入要素/几何体

¥Geometry | Feature the cleaned input Feature/Geometry

示例

¥Examples

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]]

安装

¥Installation

$ npm install @turf/clean-coords

import { cleanCoords } from "@turf/clean-coords";
const result = cleanCoords(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.cleanCoords(...);