Skip to content

KBE3D / KBCore / turf / truncate

函数: truncate()

truncate<T>(geojson: T, options?: { precision?: number; coordinates?: number; mutate?: boolean; }): T

Function

Takes a GeoJSON Feature or FeatureCollection and truncates the precision of the geometry.

类型参数

T

T extends AllGeoJSON

参数

geojson

T

any GeoJSON Feature, FeatureCollection, Geometry or GeometryCollection.

options?

Optional parameters

precision?

number

coordinate decimal precision

coordinates?

number

maximum number of coordinates (primarly used to remove z coordinates)

mutate?

boolean

allows GeoJSON input to be mutated (significant performance increase if true)

返回

T

layer with truncated geometry

示例

ts
var point = turf.point([
    70.46923055566859,
    58.11088890802906,
    1508
]);
var options = {precision: 3, coordinates: 2};
var truncated = turf.truncate(point, options);
//=truncated.geometry.coordinates => [70.469, 58.111]

//addToMap
var addToMap = [truncated];

KBE3D @3.0.0 Copyright © 2024-present KBE3D