aboutsummaryrefslogtreecommitdiff
path: root/ride/ride.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-08-21 11:04:57 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-08-21 11:04:57 +0200
commitd26aa2dca1b14b7d52070825bfc73c5e8aed7a16 (patch)
tree5d2ad13f342316dcdb1258ecd8c6e739d9adf08d /ride/ride.go
parent44f7333d9deef81d3468e20b378c63692a9406ec (diff)
refactor(ride,rideanalysis): replace magic numbers with named constants
Diffstat (limited to 'ride/ride.go')
-rw-r--r--ride/ride.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/ride/ride.go b/ride/ride.go
index 278880f..a10d8a2 100644
--- a/ride/ride.go
+++ b/ride/ride.go
@@ -230,6 +230,10 @@ func metricValue(point gpx.GPXPoint, name string) (*float64, error) {
const CotacolAlgorithmVersion = "v1"
+// cotacolSegmentLengthM is the fixed length of the elevation segments the
+// Cotacol score is computed over.
+const cotacolSegmentLengthM = 100
+
func Cotacol(ride Ride) float64 {
return difficultyScore(ride, 0, ride.Len()-1)
}
@@ -245,8 +249,8 @@ func difficultyScore(r Ride, startIndex, endIndex int) float64 {
}
cotacol := 0.0
i := startIndex
- for start := startDistance; start < lastDistance; start += 100 {
- end := math.Min(start+100, lastDistance)
+ for start := startDistance; start < lastDistance; start += cotacolSegmentLengthM {
+ end := math.Min(start+cotacolSegmentLengthM, lastDistance)
for i < endIndex && r.DistanceM(i+1) <= start {
i++
}