diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 10:30:27 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 10:30:27 +0200 |
| commit | 44f7333d9deef81d3468e20b378c63692a9406ec (patch) | |
| tree | aeacb99247dba4e48ee61e2792f5476a3770795a /mountain_pass/extract_test.go | |
| parent | 6667ee479c06c14bb182f36a0a9ee704fca6218d (diff) | |
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.
Diffstat (limited to 'mountain_pass/extract_test.go')
| -rw-r--r-- | mountain_pass/extract_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/mountain_pass/extract_test.go b/mountain_pass/extract_test.go new file mode 100644 index 0000000..636372c --- /dev/null +++ b/mountain_pass/extract_test.go @@ -0,0 +1,49 @@ +package mountain_pass + +import ( + "testing" + + "github.com/paulmach/osm" + "github.com/stretchr/testify/assert" +) + +func TestIsMountainPass(t *testing.T) { + cases := []struct { + name string + tags map[string]string + want bool + }{ + {"tagged", map[string]string{"mountain_pass": "yes", "name": "Col de la Gineste"}, true}, + {"legacy natural", map[string]string{"natural": "mountain_pass"}, true}, + {"not a pass", map[string]string{"natural": "saddle", "name": "Col de la Gineste"}, false}, + {"no tags", map[string]string{}, false}, + } + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + node := &osm.Node{Tags: osm.Tags{}} + for key, value := range c.tags { + node.Tags = append(node.Tags, osm.Tag{Key: key, Value: value}) + } + assert.Equal(t, c.want, isMountainPass(node)) + }) + } +} + +func TestParseElevation(t *testing.T) { + cases := []struct { + input string + want int + ok bool + }{ + {"1320", 1320, true}, + {"1320 m", 1320, true}, + {" 447.5", 447, true}, + {"", 0, false}, + {"unknown", 0, false}, + } + for _, c := range cases { + value, ok := parseElevation(c.input) + assert.Equal(t, c.want, value) + assert.Equal(t, c.ok, ok) + } +} |
