From 708f5428968b7c1526f257b683d0146ef5dae418 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Tue, 25 Aug 2026 11:32:57 +0200 Subject: 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. --- web/views.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'web/views.go') 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, } -- cgit v1.3