aboutsummaryrefslogtreecommitdiff
path: root/climb/route.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-10-18 21:19:36 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-10-18 21:19:36 +0200
commit8a0032d08862dcf28c653bee3fd21052e967e35d (patch)
tree6cb0d8efe6f5c2bf9ce9eb3ef8306faecbe7cfeb /climb/route.go
parentd575274d00c8da251df29d5d6a636044673944a3 (diff)
Cut climb profile sections in the backend
The chart steps are computed in Go and shipped as finished sections, next to the profile statistics the climb package already owns: climb.ProfileSections cuts a Route at its widest bends under a ProfilePolicy, and rideanalysis.MergeClimbProfile takes over the merge that lived in web/climbs.go, so web only loads the attempt rides and maps the DTOs. The payload carries sections instead of raw elevations, and the browser keeps what needs the canvas: slope bands, labels, distance ticks and colours. official-climb-profile-logic.ts and its tests are gone, replaced by climb/profile_test.go and a page test reading the embedded profile JSON.
Diffstat (limited to 'climb/route.go')
-rw-r--r--climb/route.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/climb/route.go b/climb/route.go
index 4ef3465..e341bea 100644
--- a/climb/route.go
+++ b/climb/route.go
@@ -14,6 +14,16 @@ type SegmentSample struct {
ElevationGainM float64
}
+// Slice returns the sub-route covering the given point indices (inclusive). A route without coords
+// (a resampled profile) keeps them empty.
+func (route Route) Slice(start, end int) Route {
+ sliced := Route{Distances: route.Distances[start : end+1], Elevations: route.Elevations[start : end+1]}
+ if len(route.Coords) == len(route.Distances) {
+ sliced.Coords = route.Coords[start : end+1]
+ }
+ return sliced
+}
+
// Sample returns the recorded length and elevation gain of the route slice between start and end (inclusive), counting only upward steps in the gain.
func (route Route) Sample(start, end int) SegmentSample {
sample := SegmentSample{DistanceM: route.Distances[end] - route.Distances[start]}