#86: give Finland's railway lines the names the register actually has #88
No reviewers
Labels
No labels
blocked
claude-wip
map-report
map:is
map:se
needs-review
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
art/ismap!88
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-86-fi-railway-names"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #86
#86: give Finland's railway lines the names the register actually has
What changed and why
Finland's
railways.namewas 100% NULL against Sweden's 73% and Poland's 24%naming share — R93's parity gap (a label layer only one country populates), found
by the country audit #77.
MTK carries no line names on the rail geometry itself (confirmed against the raw
fi_mtk_muut.gpkg), so there is no new dataset to fetch. The fix is the registerjoin that
stationsalready uses, wired intorailwaysinconf/fimap.yaml:db: fi_muut, columnsijainti_viiva) to the staged tables (db: pg,staging: [fi_rautatie, fi_paikannimi]), the same shapewater_bodiesandstationsuse.fi_paikannimipoint of kohdeluokka 14201(the traffic-site label — the register's only railway-name code; verified there
is no separate line-name code) within 500 m, preferring Finnish per R92's
DISTINCT ON convention (
ORDER BY (kielikoodi='fin') DESC),LIMIT 1.ST_Force2Dapplied to the geometry per the config's MTK-staging rule; the::railcast on the enum thedb: pginsert path needs.How it was verified (live DB)
SELECT count(*) FROM map_railways_12 WHERE country='fi' AND name IS NOT NULL→ 3870 of 18294 rows (21%). Materially greater thanzero.
name.
countries' partitions.
KILO, TIKKURILA etc. —
scripts/mvt-decode.py+ raw string check.go test ./...in importer/ and mapsrv/: pass.Notes / trade-offs
(Straknamn), Poland's 24% is BDOT10k's own NAZWA; Finland's share is stations,
so the style's future rail labels will name lines at the sites the lines pass.
into per-site chains at coarse zoom. z8 rows 801→1237, z11 2402→2764. This is
the same behaviour Sweden's named merge exhibits and is the honest consequence
of carrying a name attribute; documented in docs/country-finland.md.
that pass no site, which would be inventing names.
Nothing left undone; no DB data outside the fi railways partition was touched.
Review: changes requested
The join itself is right — the register really is the only rail-name source MTK offers, the 500-unit
radius reuses the
stationsshape, and I confirmed the 3 870 named rows. Two things need fixingbefore this merges.
1. The names land in ALL CAPS (blocking)
The 14201 traffic-site register stores its rows in capitals — 620 of 767 — and
n.tekstiimportsthem verbatim:
The PR body quotes this as evidence of success ("rail layer carries PASILA, HELSINKI, KILO,
TIKKURILA") — but that is the shouting map R94 describes, and R94 lands in this same batch
via #80/PR #90. The fix is the idiom #80 already writes for
places:Worth merging #90 first and reusing it. Note
initcapleavesS:T MICHELasS:T Michel(see thereview on #90) — that affects the 14201 rows here too.
The pre-existing
stationslayer has the same flaw from the same join (349 of 847 fi names areall-caps). That is not this PR's job, but it wants its own issue.
2.
500 mis not 500 m (fix the comment)ST_DWithin(p.geom, r.geom, 500)runs against geometry staged in EPSG:3857. At Finland's latitudesthat is 250 m on the ground at 60°N and 171 m at 70°N, not 500 m. Two places assert metres:
conf/fimap.yaml:651— "The 500 m radius is the stations layer's own"docs/country-finland.md:392— "within the same 500 m the stations join uses"R88 calls this out explicitly ("a fixed 3857-unit catchment radius likewise means 3.4 km on the
ground in the south and 2.3 km in the north"), and
ca3eacbfixed the same class of error forIceland's cluster distances a few commits ago. The radius behaves fine — only the quoted figure is
wrong, by 2–3x. Quote it in ground metres per R79, or state it as units and give the ground range.
What checked out
ORDER BY (kielikoodi = 'fin') DESC, p.geom <-> r.geomto be able to name a segmentafter a farther site, since language sorts ahead of distance. It cannot, empirically: of the 1 127
segments where the language-first pick is not the nearest candidate, all 1 127 have an anchor gap
of exactly 0 — every one is a co-located bilingual or caps twin of the same site. The ordering is
safe as written.
Both review points addressed on
issue-86-fi-railway-names(commite458b42, pushed).1. All-caps names (blocking). The railways join now uses the #80 idiom:
(CASE WHEN n.teksti = upper(n.teksti) THEN initcap(n.teksti) ELSE n.teksti END) AS namein conf/fimap.yaml. The known initcap limit applies and is documented in the config and in docs/country-finland.md:
S:T MICHELcomes back asS:T Michel(2 register rows of the 767), which still clears the R94 check since the result is no longer all-caps. The stations layer keeps the flaw from the same join — not this PR's scope, left for #92.2. "500 m" is not 500 m. Both comments now quote the radius as 500 units in EPSG:3857 with the ground range alongside (~250 m at 60°N, ~171 m at 70°N, per R88): the railways comment in conf/fimap.yaml and the
railways.nameparagraph in docs/country-finland.md. TheST_DWithin(..., 500)literal itself is untouched.Verification (live DB). The fix lives in the query text, so
map_railways_12still holds the un-normalized names — the acceptance query reads total 3870, all_caps 3462, unchanged from the review's measurement. Applied to the source register, the CASE drops the all-caps share of kohdeluokka 14201 from 620 to 0 of 767 rows, and the spot-check returns HELSINKI → Helsinki, PASILA → Pasila, TIKKURILA → Tikkurila, S:T MICHEL → S:T Michel, and the already-cased S:t Michel untouched. An end-to-end confirmation needs amake importre-run (the one change that cannot be checked without re-importing fi_rautatie/fi_paikannimi); the query shape, attrs and attr_names are otherwise unchanged and conf/fimap.yaml parses clean.Not merged; branch pushed for your review.
Review — ready to merge
Verified against the live DB rather than the diff alone.
Acceptance claim holds.
map_railways_12has 3 870 of 18 294firows named (21%), matching the PR body.The language rule was the one thing worth attacking, and it survives.
ORDER BY (p.kielikoodi = 'fin') DESC, p.geom <-> r.geomleads with a non-distance term, so in principle a farther Finnish name could beat a nearer Swedish one belonging to a different traffic site. Measured — it never does:876 rows differ in text from a naive nearest pick, and all of them are bilingual rows at identical coordinates. So the fin preference only ever breaks ties at one site, which is exactly the stated intent. No cross-site leakage.
Minor, non-blocking: leading the
ORDER BYwith the boolean means PostGIS cannot use index-assisted KNN ordering, butST_DWithinalready bounds the candidate set, so it does not matter here.The documented
S:T MICHEL→S:t Michelinitcap limitation is honest and correctly scoped.No changes requested.