diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-27 18:05:59 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-27 18:05:59 +0200 |
| commit | 558f755f5746a4ee819de87579951b7533688e5d (patch) | |
| tree | ced2f96966a5aee90a7756e0c01f0b1295a2a55d /mountain_pass/detection.go | |
| parent | 751af663f38e174203c10438e5ef36277e93cd68 (diff) | |
Categorise OSM passes by highway and colour them on the ride detail map
Passes are extracted from OSM PBF nodes (mountain_pass=yes) and linked to
containing ways; highway road values map to road, track to track,
path/footway to path, plus hiking for rock/climbing. All passes are kept,
coloured distinctly (road/track/path/hiking/unknown) for road-bike validation
on ride 397. Single squashed migration adds category column, cheap to re-extract.
Diffstat (limited to 'mountain_pass/detection.go')
| -rw-r--r-- | mountain_pass/detection.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/mountain_pass/detection.go b/mountain_pass/detection.go index 79e55e4..a79377f 100644 --- a/mountain_pass/detection.go +++ b/mountain_pass/detection.go @@ -11,11 +11,13 @@ import ( // MountainPass is a pass extracted from OpenStreetMap: a node tagged // mountain_pass=yes (or legacy natural=mountain_pass) with a name and an -// elevation, as filtered by the loaders. +// elevation, as filtered by the loaders. Category classifies bike suitability +// (road, track, path, hiking, unknown) derived from containing way highways. type MountainPass struct { Name string Elevation int Coord *geodist.Coord + Category string } type Crossing struct { @@ -64,7 +66,7 @@ func rideBounds(coords []geodist.Coord, marginM float64) *coordinateBounds { func loadMountainPasses(db *sql.DB, bounds *coordinateBounds) ([]MountainPass, error) { query := ` - SELECT name, elevation, latitude, longitude + SELECT name, elevation, latitude, longitude, COALESCE(category,'unknown') FROM mountain_passes WHERE elevation IS NOT NULL AND name IS NOT NULL AND name != ''` @@ -87,10 +89,13 @@ func loadMountainPasses(db *sql.DB, bounds *coordinateBounds) ([]MountainPass, e for rows.Next() { var mountainPass MountainPass var latitude, longitude float64 - if err := rows.Scan(&mountainPass.Name, &mountainPass.Elevation, &latitude, &longitude); err != nil { + if err := rows.Scan(&mountainPass.Name, &mountainPass.Elevation, &latitude, &longitude, &mountainPass.Category); err != nil { return nil, err } mountainPass.Coord = &geodist.Coord{Lat: latitude, Lon: longitude} + if mountainPass.Category == "" { + mountainPass.Category = CategoryUnknown + } mountainPasses = append(mountainPasses, mountainPass) } return mountainPasses, rows.Err() |
