mapbox / mapbox/turf-swift

Add method to divide LineString into equal chunks

Open
#183 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature jira-sync-complete JS parity
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.