Add method to divide LineString into equal chunks
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 271
- Forks
- 65
- PR merge metrics
- No merged PRs in 30d
Description
The [`lineChunk`](https://turfjs.org/docs/#lineChunk) method should be ported to this library:
> Divides a [LineString](https://tools.ietf.org/html/rfc7946#section-3.1.4) 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:
```swift
func dividedIntoChunks(of length: LocationDistance, reversed: Bool) -> MultiLineString
```
/cc @danpat @Guardiola31337
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Turf.js lineChunk documentation and the existing LineString and MultiLineString APIs. Implement the suggested dividedIntoChunks(of:reversed:) entry point, preserving the stated behavior for short lines and equal-length chunks; verify the result with the repository's existing geometry tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100