turf-swift
turf-swift copied to clipboard
Add method to divide LineString into equal chunks
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
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.
Tagging @mapbox/navigation-android for parity.