package climb import "github.com/jftuga/geodist" type Route struct { Distances []float64 Elevations []float64 Coords []geodist.Coord } // SegmentSample is a recorded passage: the length and elevation gain ridden between two route points. type SegmentSample struct { DistanceM float64 ElevationGainM float64 } // Sample returns the recorded length and elevation gain of the route slice between start and end (inclusive), counting only upward steps in the gain. func (route Route) Sample(start, end int) SegmentSample { sample := SegmentSample{DistanceM: route.Distances[end] - route.Distances[start]} for i := start + 1; i <= end; i++ { if diff := route.Elevations[i] - route.Elevations[i-1]; diff > 0 { sample.ElevationGainM += diff } } return sample }