Skip to content

KBE3D / KBCore / turf / lineChunk

函数: lineChunk()

lineChunk<T>(geojson: GeometryCollection<Geometry> | T | Feature<T, GeoJsonProperties> | FeatureCollection<T, GeoJsonProperties> | Feature<GeometryCollection<Geometry>, GeoJsonProperties>, segmentLength: number, options?: { units?: Units; reverse?: boolean; }): FeatureCollection<LineString>

Function

Divides a LineString into chunks of a specified length. If the line is shorter than the segment length then the original line is returned.

类型参数

T

T extends LineString | MultiLineString

参数

geojson

the lines to split

GeometryCollection<Geometry> | T | Feature<T, GeoJsonProperties> | FeatureCollection<T, GeoJsonProperties> | Feature<GeometryCollection<Geometry>, GeoJsonProperties>

segmentLength

number

how long to make each segment

options?

Optional parameters

units?

Units

Supports all valid Turf Units

reverse?

boolean

reverses coordinates to start the first chunked segment at the end

返回

FeatureCollection<LineString>

collection of line segments

示例

ts
var line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]);

var chunk = turf.lineChunk(line, 15, {units: 'miles'});

//addToMap
var addToMap = [chunk];

KBE3D @3.0.0 Copyright © 2024-present KBE3D