turf-swift icon indicating copy to clipboard operation
turf-swift copied to clipboard

Add method to divide LineString into equal chunks

Open 1ec5 opened this issue 3 years ago • 2 comments

The lineChunk method should be ported to this library:

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

This method would be useful for sampling a geometry before passing the simplified geometry into a map matching algorithm: https://github.com/mapbox/mapbox-directions-swift/issues/661#issuecomment-1063184448.

Suggested LineString method signatures:

func dividedIntoChunks(of length: LocationDistance, reversed: Bool) -> MultiLineString

/cc @danpat @Guardiola31337

1ec5 avatar Mar 09 '22 19:03 1ec5

mutating func divideIntoChunks(of length: LocationDistance, reversed: Bool)

I removed this suggested method signature because it isn’t possible to convert a LineString into a MultiLineString in place. However, if we add these methods to MultiLineString itself, then it would be possible.

1ec5 avatar Mar 14 '22 16:03 1ec5

Tagging @mapbox/navigation-android for parity.

MaximAlien avatar Apr 18 '22 17:04 MaximAlien