diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-03 08:25:07 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-03 08:25:07 +0200 |
| commit | 9707f9ad09db935af7d06b5de08bc52de13ba6a7 (patch) | |
| tree | 34bcd01e5eda302a8730bf0817d5dd7e82186359 /ride/climb.go | |
| parent | f06a10982ab9d5aaa7d31cea31964431fa75f253 (diff) | |
feat: Detect mountain pass crossings, name climbs after passes, render ride charts
- osmpass: extract mountain_pass=yes nodes from an OSM PBF, enrich centcols passes with OSM coordinates, resumable -fetch-osm download
- mountain_pass: DetectCrossings for a ride, MatchClimb to name a climb after the pass it tops
- ride: expose Points(), add Climb.Top() and Climb.Name
- chart: -chart renders elevation profile with climb bands and pass markers
- commands: -fetch-osm, -extract-osm, -import-cached, -enrich
Diffstat (limited to 'ride/climb.go')
| -rw-r--r-- | ride/climb.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ride/climb.go b/ride/climb.go index 8ac60fa..d5a1718 100644 --- a/ride/climb.go +++ b/ride/climb.go @@ -16,6 +16,7 @@ type Climb struct { rideStart int rideEnd int points []Point + Name string } func (climb Climb) Duration() time.Duration { @@ -34,11 +35,27 @@ func (climb Climb) End() Point { return climb.points[len(climb.points)-1] } +// Top returns the highest point inside the climb, used as the crest anchor +// when naming the climb after a pass. +func (climb Climb) Top() Point { + top := climb.points[0] + for _, point := range climb.points { + if point.ElevationM > top.ElevationM { + top = point + } + } + return top +} + func (climb Climb) String() string { start := climb.points[0] end := climb.points[len(climb.points)-1] score := Score(climb.points, 0, len(climb.points)-1) - return fmt.Sprintf("%.1fkm-%.1fkm: %.1fkm at %.1f%% (%d pts - %s)", start.DistanceM/1000, end.DistanceM/1000, (end.DistanceM-start.DistanceM)/1000, Slope(start, end)*100, int(score), Category(score)) + body := fmt.Sprintf("%.1fkm-%.1fkm: %.1fkm at %.1f%% (%d pts - %s)", start.DistanceM/1000, end.DistanceM/1000, (end.DistanceM-start.DistanceM)/1000, Slope(start, end)*100, int(score), Category(score)) + if climb.Name == "" { + return body + } + return climb.Name + ": " + body } func (climb Climb) Score() float64 { |