#29: place names for Sweden and Poland #73
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!73
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-29-se-pl-place-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 #29
Place names for Sweden and Poland via the shared places layer
What and why
Issue #29 asked for place names in Poland, Sweden and Finland. PR #53 landed Finland
and Iceland through a shared
map_placeslayer (points + name + importance 1–3, withMapLibre doing the decluttering). This PR fills in the other two countries against the
same layer, on top of the merged #71 rank shape (per-country
rankcolumn, per-zoomrank <= Nbudget caps).Design decision (per the issue's open question). Points suffice — the shared layer
contract (#53) is explicitly points with a name, collision handling is MapLibre's job,
and label-anchor polygons are the "extension the issue flagged", deferred. Both new
countries confirm the source reality: Sweden's Topo 10
texttheme is points only(
textobjekt, 835 k points), and Poland's PRNG settlement names are points.Sweden — Lantmäteriet Topo 10
textthemetopo10-textfetchestext_sverige.zip(52 MB) as its ownentry rather than a
files:line in thetopo10order: delivery ids rotate, andadding a file to that order would trip its
filesPresent()short-circuit into a ~13 GBre-download of
markon the next import.BEBTÄTTX(tätort, the towns) andBEBTX(bebyggelse,settlements) are staged into PostGIS (
se_text_t10, then the clusterse_text_t10_cl)because the rank needs the built-up join and a cluster dedupe — both PostGIS. Terrain/
water/marsh/nature/church labels are the lake-and-river-naming extension, not place
names, and stay out.
importance= the register's own label-height ladder (thojd10–30): 30 → 3, 20 → 2,else 1. This is the same "survey prints it big" signal Finland's kirjasinkoko and
Iceland's örnefnaflokkur carry.
rank= ROW_NUMBER over (importance, built-up footprint, name). The footprint is thereal size signal: total area of the
se_mark_t10built-up polygons (2636/2637/2638/2639) within 6 km of the nearest tätort label, summed per place. It puts Stockholm
first and gives z5 the maintainer's expected set — {Stockholm, Göteborg, Västerås,
Uppsala, Linköping, Malmö} — where the original label-placement-count tiebreak ranked
Västerås/Nyköping/Sala above the capital and left Göteborg/Malmö out of z5 entirely
(issue #29 review).
se_text_t10_clclusters the settlement labels spatially within the name(ST_ClusterDBSCAN, 15 km eps) and the layer keeps one row per (name, cluster) — the
largest-label placement. A big town's several label points are one place; two genuinely
separate villages with the same name both survive. (The old nationwide ROW_NUMBER
silently dropped the second village.)
X=60% budget, no NULLs, decoded z5 tile carries exactly the six big cities, real-browser
CDP render shows the names.
Poland — GUGiK PRNG
IDENTYFIKATORPRNGidentifiers on water/transport features.New
downloads:entry fetches the M1_UrzedoweNazwyMiejscowosci layer (officialnames) as one WFS GetFeature GML (~86 MB, PROPERTYNAME slimmed to the columns this
layer reads: NAZWAGLOWNA, SKALA_WYSWIETLANIA, msGeometry). M2 (pozostałe/other)
is deliberately not fetched — the non-official tier, the same exclusion as Finland's
48190 "other".
readGMLTable) was polygon-only (one MULTIPOLYGONfor masks). A new
gml_pointsloader reads point features with named attributes —one row per feature, geometry from
gml:Point/gml:pos, every other direct childelement a text column (lowercased), axis-order handling via
swap_axeslike thepolygon path. Tested in
importer/gml_test.go.importance= the register's ownSKALA_WYSWIETLANIA(display scale, 1:100000 up to1:8000000) — fine-grained where Sweden's thojd is coarse: exactly 1026 names print at
1:500000 or coarser (the cities) → scale ≥ 1:500000 is 3, 1:250000 is 2, 1:100000 is 1.
rank= ROW_NUMBER over (scale denominator, name) — the redundantimportance DESCfirst key is dropped, since importance is derived from the denominator. The register
ties its top tier: 17 cities all print at 1:8000000, so within it the order falls to
name — Warszawa is rank 15, appearing from z6 (rank ≤ 18). This is the register's own
coarseness, exactly the #71 acceptance of register ladders; at z5 Poland shows its four
largest cities by the survey's own order.
dedupe), including the
część wsi/część miastaparts that label city districts athigh zoom — a flat catalogue of official names with no hierarchy to filter on, unlike
Sweden's mixed label theme. The two countries agree on what a place is (one label point
per place); they differ only in that Poland's source is already pure place names.
carries Warszawa, CDP render confirms.
The shared contract
conf/common.yamlplaces comment updated to say all four countries now have partitions(the old text said Sweden and Poland render nothing).
#71's budget formula is reusedunchanged with each country's land area, and this branch sits on the merged #71 — the
fimap/ismap rank changes are already in main.
What's left undone
texttheme (the issue's extended scope) andthe spatial join to put water names on the water features — explicitly deferred.
population-based tiebreak is the documented alternative if that ever matters.
Verification
make build,go test ./...inimporter/andmapsrv/— green.all four countries), decoded tiles, and real-browser CDP renders (never virtual time).
1366af641etob0ae0bfe6aSweden z5 is showing some really strange choices. It should be Stockholm, Göteborg, Malmö, Uppsala and (here the fight starts because technically it should be a locality created a decade ago because parts of Stockholm didn't actually fit the technical definition of tätort and were split up, but it's such a new name that Lanmäteriet refuses to use it because they have a technical requirement of a name being in use for sufficiently long time, which is much more than this abomination has existed and besides no one uses it outside of pub quizzes) Västerås and Linköping.
Review — changes requested (Sweden's rank tiebreak)
Poland's half verifies cleanly against the live DB. PRNG's
SKALA_WYSWIETLANIAtier is a real signal: exactly 1026 rows print at 1:500000 or coarser and exactly 1026 rows arerodzajobiektu = 'miasto', so "the coarse tier is the cities" is the register's own statement, not an inference. The 17 at 1:8000000 are the voivodeship capitals, Warszawa lands at rank 15 → z6, all as documented.gml_pointsis a clean addition andgo test ./...passes inimporter/on the branch.Sweden's ranking is the problem.
tposis not measuring town size (conf/semap.yaml:947)The tiebreak is justified as "Lantmäteriet prints a big town's name at several points on the map and a hamlet's at one". The imported result contradicts that:
Ranks 7 onward are plain alphabetical (Hallstahammar, Halmstad, Helsingborg, Hultsfred, …), so
tposseparates six names in the entire thojd-30 tier — and it orders Sala and Nyköping above Stockholm.This is not the #71 FORSSA-over-HELSINKI situation. There, the register's own coarseness was being accepted. Here a derived quantity is being introduced on the claim that it tracks size, and its output falsifies the claim: the country map at z4 names Västerås and nothing else. The count is
count(DISTINCT hex(geom))overregtext + thojdnationwide, so it is picking up split-label fragments and repeated name strings across the country, both uncorrelated with importance.Options, roughly in order of cost:
tposand tie-break on name, as Poland's layer does. Arbitrary, but honestly arbitrary — and Stockholm/Göteborg/Malmö at least fall where alphabet puts them rather than behind Sala.se_mark_t10is already staged and carries built-up polygons (Låg bebyggelse16 554,Hög bebyggelse4 527,Sluten bebyggelse394,Industri- och handelsbebyggelse6 995). Total built-up area within a small radius of the label point is a genuine measure of how big the place is, and it would rank the tier properly.(2) is the one that makes z4–z6 look like a map of Sweden.
Nationwide dedupe drops distinct places (conf/semap.yaml:956)
ROW_NUMBER() OVER (PARTITION BY g.regtext ORDER BY …)keeps one point per name for the whole country. That is needed for the split-label case ("Stock-" + "holm" sharing aregtext), but it is too broad: two separate Swedish villages with the same name yield one label, and the other place is silently gone. Same fix as the sibling #74 — cluster spatially within the name (ST_ClusterDBSCAN … PARTITION BY regtext) and keep one row per (name, cluster). Note Poland's query does not dedupe (101 334 rows, one per place), so the two countries in this PR currently disagree about what a place is.Smaller points
rank <= 96943against a 96 499-row register, so that rung is a no-op; the comment says "z13+ keeps the whole register" but z12 does too.część wsiand 6 710część miasta. City districts will label inside cities at high zoom. Sweden filters to the settlement classes (BEBTÄTTX/BEBTX) — worth being deliberate about the asymmetry rather than inheriting it.statusnazwyis a constant ('urzędowa') across the whole register and is read by neither this PR nor #68's, androdzajobiektuis read only by #68's. The comment "PROPERTYNAME keeps only the columns the layer reads + geometry" isn't accurate as written.importance DESC, denominator DESC, name—importanceis derived from the denominator, so the first key is redundant. Harmless.e5b5edaand this branch sits on top of it. The diff no longer touchesfimap.yaml/ismap.yaml.Merge order
Verified: #74 and (now-merged) #75 merge cleanly onto this branch. #68's PR conflicts — it independently adds the same
pl_prng_m1download and staging entries plus a verbatim copy of this branch'simporter/staging.go. This PR should land first and #76 rebase onto it.Review addressed on the branch (commit
d6a0823). What changed:1. Size signal —
tposis gone, replaced by built-up footprint.ranknow orders by (importance, footprint, name), where footprint = total area of these_mark_t10built-up polygons (2636/2637/2638/2639) within 6 km of the nearest tätort label, summed per place. z5 is now exactly the maintainer's expected set: Stockholm, Göteborg, Västerås, Uppsala, Linköping, Malmö (z4 = Stockholm alone).Why not the literal "built-up within a small radius of the label point": Lantmäteriet places each town's label at a readable map position (Stockholm's over the archipelago), so a plain radius under-measures the town and lets its suburbs outrank it. Assigning each built-up polygon to the nearest tätort label gives every place its own footprint — Stockholm first, Täby/Sollentuna out of the top-6.
2. Nationwide dedupe replaced by spatial clustering within the name.
se_text_t10_clruns ST_ClusterDBSCAN(geom, 15000, 1) OVER (PARTITION BY regtext); the layer keeps one row per (name, cluster). A big town's several label points are one place; two same-named villages both survive. Register: 96 499 → 203 830 places. This also fixes the z12 no-op (98304 < register now filters).3. Smaller points. z12 cap is now 98304 and filters; the z13+ comment says ~203 800 places. The Poland/Sweden asymmetry is now a documented deliberate decision (Poland keeps the whole register because PRNG is pure place names; Sweden must filter its mixed label theme). PROPERTYNAME trimmed to the columns this layer reads (dropped the constant
statusnazwyandrodzajobiektu, which #68 re-adds on rebase); the comment now matches. Poland's rank drops the redundantimportance DESCfirst key. The stale "#72 subsumes" line is out of the body.4. Merge order. This branch touches only conf/common.yaml, conf/plmap.yaml, conf/semap.yaml and docs — no importer code beyond what the original PR already carried, so #68's
pl_prng_m1/staging.go overlap is unchanged and #76 can rebase onto this.Verified against the live DB: 203 830 Swedish places, zoom counts 1/6/24/96/384/1536/6144/24576/98304, no NULLs, partitions at every zoom, decoded z5 tile carries exactly the six expected names; Poland unchanged (101 334 rows, Warszawa rank 15 → z6).
go test ./...green in importer/ and mapsrv/.