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_test.go | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'mountain_pass/detection_test.go') diff --git a/mountain_pass/detection_test.go b/mountain_pass/detection_test.go index d86e67b..f55532b 100644 --- a/mountain_pass/detection_test.go +++ b/mountain_pass/detection_test.go @@ -28,14 +28,15 @@ func TestDetectCrossingsFindsPass(t *testing.T) { func TestLoadMountainPassesAroundRideUsesExpandedBounds(t *testing.T) { db := dbtest.New(t) _, err := db.Exec(` - INSERT INTO mountain_passes (external_id, name, country_code, department_code, elevation, latitude, longitude) - VALUES (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?) + INSERT INTO mountain_passes (osm_id, name, elevation, latitude, longitude) + VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?) `, - "550e8400-e29b-41d4-a716-446655440000", "On route", "FR", "13", 400, 43.05, 5.05, - "6ba7b810-9dad-41d1-80b4-00c04fd430c8", "Within margin", "FR", "13", 500, 43.18, 5.20, - "6ba7b811-9dad-41d1-80b4-00c04fd430c8", "Outside margin", "FR", "13", 600, 43.21, 5.20, - "6ba7b812-9dad-41d1-80b4-00c04fd430c8", "Missing coordinates", "FR", "13", 700, nil, nil, - "6ba7b813-9dad-41d1-80b4-00c04fd430c8", "On route edge", "FR", "13", 300, 43.10, 5.10, + 1, "On route", 400, 43.05, 5.05, + 2, "Within margin", 500, 43.18, 5.20, + 3, "Outside margin", 600, 43.21, 5.20, + 4, "No elevation", nil, 43.19, 5.20, + 5, "", 700, 43.17, 5.20, + 6, "On route edge", 300, 43.10, 5.10, ) require.NoError(t, err) @@ -53,6 +54,27 @@ func TestLoadMountainPassesAroundRideUsesExpandedBounds(t *testing.T) { assert.Contains(t, []string{passes[1].Name, passes[2].Name}, "Within margin") } +func TestLoadMountainPassesFiltersElevationAndName(t *testing.T) { + db := dbtest.New(t) + _, err := db.Exec(` + INSERT INTO mountain_passes (osm_id, name, elevation, latitude, longitude) + VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?) + `, + 1, "Named pass", 400, 43.05, 5.05, + 2, "No elevation", nil, 43.06, 5.06, + 3, "", 300, 43.07, 5.07, + 4, "No name or elevation", nil, 43.08, 5.08, + ) + require.NoError(t, err) + + passes, err := mountain_pass.LoadMountainPasses(db) + require.NoError(t, err) + require.Len(t, passes, 1) + assert.Equal(t, "Named pass", passes[0].Name) + assert.Equal(t, 400, passes[0].Elevation) + assert.NotNil(t, passes[0].Coord) +} + func TestDetectCrossingsIgnoresDistantPass(t *testing.T) { r := rideFromPoint(t, 43.62, 5.43, 447) far := mountain_pass.MountainPass{ -- cgit v1.3