Giro: two versions of a route
Keep the recorded journey intact while giving the renderer a smaller job.
Try example ↗A recorded route has two jobs. It is a durable record of movement, and it is something the interface needs to draw. Those jobs do not always need the same number of points. Giro's RouteSimplifier makes that distinction explicit.
Giro contains a SwiftUI recorder, route planning, local history and export. Its repository also uses the release-candidate name svolta. The function examined here produces coordinates for drawing a recorded route.
Reduce the drawing, preserve the archive
displayCoordinates keeps the first point, thins intermediate points by minimum distance, and appends the final point. If the result still exceeds the rendering budget, it selects points at a calculated stride. The method returns a display copy; it does not rewrite the archived coordinates.
One route, two representations
Change the display spacing while the original recording stays intact.
- 160 archive points
- Distance thinning
- At most 45 display points
static func displayCoordinates(
from coordinates: [GeoCoordinate],
minimumDistance: CLLocationDistance = 4,
maximumPoints: Int = 1_200
) -> [CLLocationCoordinate2D]
// In the intermediate-point loop:
if location.distance(from: lastLocation) >= minimumDistance {
thinned.append(coordinate)
lastLocation = location
}Different consumers, different fidelity
- Recorded coordinates
- Archive stays intact
- Distance thinning
- Display-point budget
- Rendered route
The app can draw from the bounded copy while other features retain access to the original trace. That is especially useful when a recording grows long: the renderer's workload can have a ceiling without making the user's record progressively less complete.
A simpler line is not a corrected journey
This method is not map matching, GPS outlier rejection or a route-safety system. Its stride pass can omit meaningful bends, so point count alone is not a measure of visual fidelity. The archive provides a way to choose another rendering strategy later without losing the original input.
The source defaults are sensible for the intended call, but this method does not validate every possible custom maximumPoints value. A reusable version should define what budgets below two mean. The app's README also distinguishes recording from turn-by-turn navigation, which it hands off to Apple Maps or Google Maps.
The route uses synthetic geometry so the archive/display boundary is inspectable without exposing location history. The native app and a real GPS route do not run here.