diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-01 23:30:36 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-01 23:30:36 +0200 |
| commit | ab0b68a2b6bebfccd8ab5c3c7d0420f4ae0cb885 (patch) | |
| tree | 74d5a299a34a8d466c19567edd69dcf15b651d71 /ride/ride.go | |
| parent | b7ef44b22e23126a494614f93e07b248fd6a8f12 (diff) | |
feat: Add Cotacol difficulty score to climbs
Diffstat (limited to 'ride/ride.go')
| -rw-r--r-- | ride/ride.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ride/ride.go b/ride/ride.go index 9ce260f..73e7a26 100644 --- a/ride/ride.go +++ b/ride/ride.go @@ -93,7 +93,10 @@ func (r *Ride) ScoreFromKm(start, end float64) float64 { } func (r *Ride) DifficultyScore() float64 { - points := r.points + return difficultyScore(r.points) +} + +func difficultyScore(points []Point) float64 { if len(points) < 2 { return 0 } @@ -103,7 +106,7 @@ func (r *Ride) DifficultyScore() float64 { } score := 0.0 i := 0 - for start := 0.0; start < last.DistanceM; start += 100 { + for start := points[0].DistanceM; start < last.DistanceM; start += 100 { end := math.Min(start+100, last.DistanceM) for i < len(points)-1 && points[i+1].DistanceM <= start { i++ |