#79: Poland's and Finland's place ranks are the built-up footprint, not the register's print size #97
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!97
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-79-pl-fi-place-rank"
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?
#79: Poland's and Finland's place ranks are the built-up footprint, not the register's print size
Closes #79
Both countries'
placesladders fell through to alphabetical order at the top because theregister's own print-size signal ties there (Poland: 17 cities at 1:8000000; Finland: the
kirjasinkoko 570 bucket covers 45 names). The fix is the size-proxy shape #29 gave Sweden
and #78 gave Iceland: a built-up footprint breaks the tie, computed in a metric CRS (R88).
Poland
rankwasORDER BY (scale denominator) DESC, name. It is now(denominator) DESC, footprint DESC, name, where the footprint is the pl_ptzb built-up area whose centroid isnearest a PRNG settlement label (miasto/wieś) within a 6 km ground catchment, in EPSG:2180.
The footprint is keyed per label geometry, not per name — Poland has ~1 900 same-named
Nowa Wieś villages that must not pool.
The catchment radius is the careful part: 6 km is the smallest at which Warszawa (rank 1,
40 km²) beats Łódź while Silesia's constituent cities stay distinct — beyond ~6.2 km
Katowice's catchment swallows its neighbours and would slip into the top five.
Result:
Finland
rankwasORDER BY importance DESC, kirjasinkoko DESC, name. It is nowimportance DESC, footprint DESC, name, where the footprint is the MTK taajaanrakennettualue areaassigned to each 48111/48112 label within a 12 km ground catchment, in EPSG:3067.
The assignment is highest-font-wins, not nearest-label. Finland's register prints each
big town at ONE label point (unlike Sweden's Topo 10, which clusters several), so nearest
would let Vantaa's label — next to the airport — beat the capital for the central metro
(R85). The register's own finer signal (kirjasinkoko) decides who owns shared built-up;
ties go by distance. Helsinki (570) owns the central metro, Vantaa (505) and Espoo (505)
keep their north/west built-up, and the capital is rank 1.
The clustering moved from an inline CTE to the
fi_paikannimi_clstaging table (these_text_t10_cl shape) so the footprint kNN has a gist index to run against.
Result:
Near-miss to record
Finland's top five is Helsinki, Turku, Vantaa, Tampere, Oulu — Espoo (population #2) is
rank 6, Turku (population #6) is rank 2. This is the exact shape of Sweden's accepted
near-miss (Malmö #3 → rank 6, Linköping #6 → top five, recorded in
docs/country-requirements.md): the register prints Espoo at 505 against Helsinki's 570, so
the shared metro built-up goes to the capital and Espoo's footprint is genuinely small.
Not filed as a further issue — it is the same judgement about what "largest" means, not a
defect. Recorded here so the next R85 read on Finland does not think it was missed.
Verification
SELECT name FROM map_places_14 WHERE country=$1 ORDER BY rank LIMIT 5→ the fivelargest cities, capital first, for both countries (Finland as above; Poland Warszawa,
Łódź, Kraków, Wrocław, Poznań).
rows checked).
map_placespartitions present (11 zooms × 5 schemas).Warszawa, Łódź, Kraków, Wrocław.
console errors.
rankunique per country, monotonic withimportance(R83 check passes).make buildand bothgo test ./...pass.Left undone
Nothing functional. The Silesian-catchment fragility (radius ~6.2 km) is documented in the
config comment, not engineered away — a data change by GUGiK could re-break the top five
and the R85 check will catch it.
Review — ready to merge, two cheap nits
Verified against the live DB.
Results match the PR body.
The CRS claims hold up, which was my main worry given R88.
pl_ptzbis staged with nosrs:(kept at 2180 per the staging comment), sosum(ST_Area(geom_m))is genuinely metric — no latitude bias across Poland's 49°–55°N. Finland transforms to 3067 for the area and correctly applies thecosdlatitude correction to the 3857 catchment radius. Both are right.The tuned catchments (6 km PL, 12 km FI) are each justified by one outcome, but both are documented with their sensitivity boundary (~6.2 km before Katowice swallows its neighbours) — that is the right way to record a magic constant.
Nits
Poland dropped
ST_Force2D(geom). Verified 0 of 101 334pl_prng_m1rows are 3D, so this is safe today — but the guard cost nothing and the loader could change.Missing
NULLS LASTon the new sorts. TheanchorsCTE (ORDER BY … kirjasinkoko DESC) and the footprint LATERAL (ORDER BY a.kirjasinkoko DESC, a.geom <-> b.c) both omit it, while the surrounding pre-existing code writeskirjasinkoko DESC NULLS LASTexplicitly. Postgres defaultsDESCto NULLS FIRST, so a NULL font would outrank Helsinki's 570 and claim the shared built-up. Verified 0 NULLs for kohdeluokka 48111/48112 today, so there is no live bug — but the file is inconsistent with itself and this is the kind of trap that bites when a register changes.Cosmetic: in the Finland footprint CTE the LATERAL subquery is aliased
awhile shadowinganchors ainside it. It works, but it reads badly.Neither nit blocks the merge.
Nits fixed — and a blocking bug found while verifying them (
5514a61)Fixing the nits turned up something the original review missed, so flagging it clearly.
The bug: Poland's places layer could not survive a clean import
The new footprint join filters
p.rodzajobiektu IN ('miasto','wieś'), but the PRNG download asks the WFS for:RODZAJOBIEKTUis not in that list, and the server honours it strictly. I re-fetched to confirm — the staging table comes back with exactly three columns:so the layer query dies with
column p.rodzajobiektu does not exist. This reproduces on the pre-existing query text too, so it is not a side effect of my edits: it is the PR's own new predicate against an unchanged fetch. It only ever worked here becausepl_prng_m1in the live DB predated the fetch and still carried the column — the committed config could not rebuild it.RODZAJOBIEKTUis now inPROPERTYNAME, with a comment saying why it must stay. Re-fetched and confirmed the values are the ones the layer expects, and they match the counts the layer comment already quoted:Worth noting the general shape: any new column a layer query reads from
pl_prng_m1needs adding toPROPERTYNAMEin the same change, and nothing catches the omission until a clean fetch.The nits
ST_Force2Drestored on the places geometry.NULLS LASTadded to theanchorssort and the footprint LATERAL.anchors arenamed topick.Verification
Both countries' places queries run before and after the change, byte-identical each way — same row count, same
rank:name:geometryfingerprint, no 3D geometry:Top of both ladders unchanged —
Warszawa, Łódź, Kraków, Wrocław, Poznań…andHelsinki, Turku, Vantaa, Tampere, Oulu….go testpasses in both modules.Not verified end to end: BDOT10k is not on this box, so
pl_ptzbcould not be rebuilt and the Poland query ran against the existing staging table. The PRNG half of a clean import is now proven; thepl_ptzbhalf still wants a run aftermake fetch-bdot10k.