From 44f7333d9deef81d3468e20b378c63692a9406ec Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 21 Aug 2026 10:30:27 +0200 Subject: Use OSM as the single source of mountain passes Replace the centcols CSV download/enrichment pipeline with OSM PBF extraction as the primary (only) source: merge osmpass into mountain_pass, drop the centcols table and model fields, filter to named passes with elevation, and remove the centcols CLI flags. --- mountain_pass/detection.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'mountain_pass/detection.go') diff --git a/mountain_pass/detection.go b/mountain_pass/detection.go index 4c54493..b71837b 100644 --- a/mountain_pass/detection.go +++ b/mountain_pass/detection.go @@ -9,6 +9,15 @@ import ( "github.com/martinlehoux/biking_home/ride" ) +// 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. +type MountainPass struct { + Name string + Elevation int + Coord *geodist.Coord +} + type Crossing struct { Pass MountainPass DistanceToM float64 @@ -55,12 +64,13 @@ func rideBounds(route ride.Ride, marginM float64) *coordinateBounds { func loadMountainPasses(db *sql.DB, bounds *coordinateBounds) ([]MountainPass, error) { query := ` - SELECT external_id, name, country_code, department_code, elevation, latitude, longitude - FROM mountain_passes` + SELECT name, elevation, latitude, longitude + FROM mountain_passes + WHERE elevation IS NOT NULL + AND name IS NOT NULL AND name != ''` args := make([]any, 0, 4) if bounds != nil { query += ` - WHERE latitude IS NOT NULL AND longitude IS NOT NULL AND latitude BETWEEN ? AND ? AND longitude BETWEEN ? AND ?` args = append(args, bounds.minLatitude, bounds.maxLatitude, bounds.minLongitude, bounds.maxLongitude) @@ -76,13 +86,11 @@ func loadMountainPasses(db *sql.DB, bounds *coordinateBounds) ([]MountainPass, e mountainPasses := make([]MountainPass, 0) for rows.Next() { var mountainPass MountainPass - var latitude, longitude sql.NullFloat64 - if err := rows.Scan(&mountainPass.ExternalID, &mountainPass.Name, &mountainPass.CountryCode, &mountainPass.DepartmentCode, &mountainPass.Elevation, &latitude, &longitude); err != nil { + var latitude, longitude float64 + if err := rows.Scan(&mountainPass.Name, &mountainPass.Elevation, &latitude, &longitude); err != nil { return nil, err } - if latitude.Valid && longitude.Valid { - mountainPass.Coord = &geodist.Coord{Lat: latitude.Float64, Lon: longitude.Float64} - } + mountainPass.Coord = &geodist.Coord{Lat: latitude, Lon: longitude} mountainPasses = append(mountainPasses, mountainPass) } return mountainPasses, rows.Err() -- cgit v1.3