diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-25 11:32:57 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-25 11:32:57 +0200 |
| commit | 708f5428968b7c1526f257b683d0146ef5dae418 (patch) | |
| tree | 8b4fb6a4e020d79c8a3e62e11defe4cbdc7a3896 /web/views.go | |
| parent | ff3cd6248f2b78dc76f1ce8cc2337907188fd401 (diff) | |
Make mountain pass and web consumers take ride components instead of a whole Ride
rideBounds, nearestCrossing and DetectCrossings now accept the coordinate,
distance and elevation component slices they read. LoadMountainPassesAroundRide
takes the coords slice only. Web ride view builders and the official climb
creation path iterate ride components (Coords, Distances, Elevations) rather
than per-index accessors on Ride.
Diffstat (limited to 'web/views.go')
| -rw-r--r-- | web/views.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/web/views.go b/web/views.go index cfb31e5..8df860c 100644 --- a/web/views.go +++ b/web/views.go @@ -280,9 +280,9 @@ func officialClimbCreateURL(id int64) string { } func buildRideDetailView(item ride.StoredRide, parsed ride.Ride, passes []mountain_pass.MountainPass, officialClimbs []official_climb.OfficialClimb, matchPolicy official_climb.MatchPolicy) RideDetailView { - coordinates := make([][]float64, parsed.Len()) - for i := 0; i < parsed.Len(); i++ { - coordinate := parsed.Coord(i) + coords := parsed.Coords() + coordinates := make([][]float64, len(coords)) + for i, coordinate := range coords { coordinates[i] = []float64{coordinate.Lon, coordinate.Lat} } profile := buildRideProfile(parsed, passes, officialClimbs, matchPolicy) @@ -321,16 +321,18 @@ func buildRideMapPasses(passes []mountain_pass.MountainPass) []RideMapPass { } func buildRideProfile(parsed ride.Ride, passes []mountain_pass.MountainPass, officialClimbs []official_climb.OfficialClimb, matchPolicy official_climb.MatchPolicy) RideProfile { + coords := parsed.Coords() + distances := parsed.Distances() + elevations := parsed.Elevations() profile := RideProfile{ - Points: make([]RideProfilePoint, parsed.Len()), + Points: make([]RideProfilePoint, len(coords)), Climbs: make([]RideProfileClimb, 0), Crossings: make([]RideProfileCrossing, 0), } - for i := 0; i < parsed.Len(); i++ { - coordinate := parsed.Coord(i) + for i, coordinate := range coords { profile.Points[i] = RideProfilePoint{ - DistanceKm: parsed.DistanceM(i) / 1000, - ElevationM: parsed.ElevationM(i), + DistanceKm: distances[i] / 1000, + ElevationM: elevations[i], Latitude: coordinate.Lat, Longitude: coordinate.Lon, } |
