aboutsummaryrefslogtreecommitdiff
path: root/ride/ride.go
diff options
context:
space:
mode:
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++
}