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/rides.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'web/rides.go') diff --git a/web/rides.go b/web/rides.go index 81017d9..71ab3fd 100644 --- a/web/rides.go +++ b/web/rides.go @@ -65,7 +65,7 @@ func (s *Server) handleRide(w http.ResponseWriter, r *http.Request) { }), w) return } - passes, err := mountain_pass.LoadMountainPassesAroundRide(s.db, parsed, rideDetailMountainPassMarginM) + passes, err := mountain_pass.LoadMountainPassesAroundRide(s.db, parsed.Coords(), rideDetailMountainPassMarginM) if err != nil { slog.Warn("Failed to load nearby mountain passes for ride detail", "ride_id", id, "error", err) } @@ -144,14 +144,15 @@ func (s *Server) handleCreateOfficialClimb(w http.ResponseWriter, r *http.Reques http.Error(w, "the recorded route is unavailable", http.StatusBadRequest) return } - if startIndex >= endIndex || endIndex >= parsed.Len() { + bounds := parsed.Coords() + if startIndex >= endIndex || endIndex >= len(bounds) { http.Error(w, "the official climb boundaries must be ordered route points", http.StatusBadRequest) return } created, err := official_climb.Create(s.db, official_climb.OfficialClimb{ Name: r.FormValue("name"), - StartCoord: parsed.Coord(startIndex), - EndCoord: parsed.Coord(endIndex), + StartCoord: bounds[startIndex], + EndCoord: bounds[endIndex], }) if err != nil { slog.Warn("Failed to create official climb", "ride_id", id, "error", err) -- cgit v1.3