From c05cd9cb6305f15e3de985e5040142e0156a1286 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 21 Apr 2025 10:57:32 +0200 Subject: Implement climb score --- ride/climb.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'ride/climb.go') diff --git a/ride/climb.go b/ride/climb.go index 0a9994d..069a7fb 100644 --- a/ride/climb.go +++ b/ride/climb.go @@ -7,7 +7,6 @@ import ( "slices" "time" - "github.com/jftuga/geodist" "github.com/martinlehoux/kagamigo/kcore" ) @@ -37,11 +36,8 @@ func (climb Climb) String() string { return fmt.Sprintf("%.1fkm-%.1fkm: %.1fkm at %.1f%% (%d pts - %s)", start.DistanceM/1000, end.DistanceM/1000, (end.DistanceM-start.DistanceM)/1000, Slope(start, end)*100, int(score), Category(score)) } -type Point struct { - DistanceM float64 - ElevationM float64 - Coord geodist.Coord - Timestamp time.Time +func (climb Climb) Score() float64 { + return Score(climb.points, 0, len(climb.points)-1) } func Slope(start, end Point) float64 { @@ -126,8 +122,8 @@ func climbsBetween(points []Point, start int, end int) []Climb { return climbsBetween(points, start+1, end) } climb := bestClimbBetween(points, start, highest) - if Score(points, climb.rideStart, climb.rideEnd) >= 35 && points[climb.rideEnd].DistanceM-points[climb.rideStart].DistanceM >= ClimbDistanceMinimum { - slog.Debug("Found climb between", slog.Int("start", int(points[climb.rideStart].DistanceM)), slog.Int("end", int(points[climb.rideEnd].DistanceM))) + if climb.Score() >= 35 && climb.End().DistanceM-climb.Start().DistanceM >= ClimbDistanceMinimum { + slog.Debug("Found climb between", slog.Int("start", int(climb.Start().DistanceM)), slog.Int("end", int(climb.End().DistanceM))) climbs = append(climbs, climb) } climbs = append(climbs, climbsBetween(points, start, climb.rideStart)...) -- cgit v1.2.3