mapbox / mapbox/turf-swift

Port geosimplify-js

Open
#184 1 comment 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

[`LineString.simplify(tolerance:highestQuality:)`](https://mapbox.github.io/turf-swift/2.3.0/Structs/LineString.html#/s:4Turf10LineStringV8simplify9tolerance14highestQualityySd_SbtF) and [`simplified(tolerance:highQuality:)`](https://mapbox.github.io/turf-swift/2.3.0/Structs/LineString.html#/s:4Turf10LineStringV10simplified9tolerance14highestQualityACSd_SbtF) are based on [simplify-js](https://github.com/mourner/simplify-js/), which is fine for certain simplification use cases. However, sampling the input to a map matching algorithm requires interpolating points along a straightaway: https://github.com/mapbox/mapbox-directions-swift/issues/661#issuecomment-1063184448. The standard Ramer–Douglas–Peucker algorithm can easily create a space between vertices large enough to result in a gap according to the map matching algorithm.

[geosimplify-js](https://github.com/mapbox/geosimplify-js/) is a derivative of simplify-js that preserves points along straightaways. It could be ported to Swift as an alternative to the usual simplification algorithm. Suggested method signatures:

```swift
mutating func simplify(minimumOffset: LocationDistance, minimumGap: LocationDistance)
func simplified(minimumOffset: LocationDistance, minimumGap: LocationDistance)
```

/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 existing LineString.simplify and simplified methods, then compare their behavior with the linked geosimplify-js project and the map-matching context. Done means adding the suggested Swift methods with minimumOffset and minimumGap that preserve points along straightaways.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.