diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-16 14:55:26 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-16 14:55:26 +0200 |
| commit | df7c9b5130ba193fc918a947a461f2a70dc2dd3c (patch) | |
| tree | 0366e0b60338e268d758511621b9adf721be8322 /ride/ride.go | |
| parent | 53ab332e6d2afe9818914e0026310e4cadcc4202 (diff) | |
fix(web): use Cotacol for climb difficulty
Diffstat (limited to 'ride/ride.go')
| -rw-r--r-- | ride/ride.go | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/ride/ride.go b/ride/ride.go index 3458483..152bca4 100644 --- a/ride/ride.go +++ b/ride/ride.go @@ -226,21 +226,6 @@ func metricValue(point gpx.GPXPoint, name string) (*float64, error) { return &value, nil } -func (r *Ride) ScoreFromKm(start, end float64) float64 { - i := 0 - j := 0 - for k, distance := range r.distances { - if i == 0 && distance >= start*1000 { - i = k - } - if j == 0 && distance >= end*1000 { - j = k - break - } - } - return Score(*r, i, j) -} - const CotacolAlgorithmVersion = "v1" func Cotacol(ride Ride) float64 { @@ -256,7 +241,7 @@ func difficultyScore(r Ride, startIndex, endIndex int) float64 { if lastDistance <= startDistance { return 0 } - score := 0.0 + cotacol := 0.0 i := startIndex for start := startDistance; start < lastDistance; start += 100 { end := math.Min(start+100, lastDistance) @@ -270,10 +255,10 @@ func difficultyScore(r Ride, startIndex, endIndex int) float64 { endElevation := interpolateElevation(r, i, end) slope := (endElevation - startElevation) / (end - start) if slope > 0 { - score += (end - start) / 1000 * (slope * 100) * (slope * 100) + cotacol += (end - start) / 1000 * (slope * 100) * (slope * 100) } } - return score + return cotacol } func interpolateElevation(r Ride, i int, distance float64) float64 { |