From ff3cd6248f2b78dc76f1ce8cc2337907188fd401 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Tue, 25 Aug 2026 11:24:51 +0200 Subject: Expose ride data as components and make algorithms consume only the slices they read Ride now exposes its columns as component getters (Distances, Elevations, Coords, Timestamps, and the optional Powers, Cadences, HeartRates) with the coords field unexported. difficultyScore, movingTime, Slope and the climb detection internals are pure functions over the specific slices they use, and Climb carries only the component slices it needs instead of a whole Ride. --- rideanalysis/analysis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rideanalysis/analysis.go') diff --git a/rideanalysis/analysis.go b/rideanalysis/analysis.go index 90be629..55f77b8 100644 --- a/rideanalysis/analysis.go +++ b/rideanalysis/analysis.go @@ -39,7 +39,7 @@ func Analyze(parsed ride.Ride, passes []mountain_pass.MountainPass, officialClim claimedClimbs := make([]AnalyzedClimb, 0) claimedRanges := make([]ride.Range, 0) for _, official := range officialClimbs { - for _, matched := range official_climb.MatchClimbs(parsed.Coords, official, matchPolicy.EndpointRadiusM) { + for _, matched := range official_climb.MatchClimbs(parsed.Coords(), official, matchPolicy.EndpointRadiusM) { claimedRanges = append(claimedRanges, ride.Range{Start: matched.StartIndex, End: matched.EndIndex}) claimedClimbs = append(claimedClimbs, analyzedClimb(parsed, parsed.ClimbFromIndexes(matched.StartIndex, matched.EndIndex), official.Name, official.ID)) } @@ -72,7 +72,7 @@ func analyzedClimb(parsed ride.Ride, segment ride.Climb, name string, officialID Name: name, Category: ride.CategoryOf(cotacol).String(), DistanceM: segment.EndDistanceM() - segment.StartDistanceM(), - SlopePercent: ride.Slope(parsed, segment.StartIndex(), segment.EndIndex()) * 100, + SlopePercent: ride.Slope(parsed.Distances(), parsed.Elevations(), segment.StartIndex(), segment.EndIndex()) * 100, Cotacol: cotacol, OfficialClimbID: officialID, OfficialName: officialClimbNameForID(name, officialID), -- cgit v1.3