-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Place area city/town #538
Place area city/town #538
Conversation
Previously we had one place layer for capitals and one for non-capitals when it came to towns and cities. This combines them, reducing the number of queries, making the SQL simpler, and making the layers more useful for other styles. Incidentially fixes gravitystorm#522
This is part of gravitystorm#103, but only fixes it for place=city/town The SQL is moderately complex and difficult to document in the .mml file so it's worth documenting here ```sql (SELECT way,place,name,capital,population FROM (SELECT way,place,name,NULL AS capital,way_area, -- The polygon table doesn't have the capital information with the default style CASE WHEN population~E'^\\d{1,9}$' THEN population::integer ELSE NULL END AS population -- We need to filter out population values that might cause exceptions. This is a fairly rigerous filtering as it will remove population=1,000 FROM planet_osm_polygon UNION ALL -- Join the two together SELECT way,place,name,capital,NULL AS way_area, -- Points don't have an area CASE WHEN population~E'^\\d{1,9}$' AND length(population)<10 THEN population::integer ELSE NULL END AS population -- as above FROM planet_osm_point) AS p WHERE place IN ('city','town') -- This condition is brought inside by the query optimizer ORDER BY CASE place WHEN 'city' THEN 0 ELSE 10 END, -- We don't actually need this at moment with the current MSS CASE capital WHEN 'yes' THEN 0 ELSE 10 END, -- Nor this way_area DESC NULLS LAST, -- Put physically larger first population DESC NULLS LAST -- For points (no area) put larger population first ) AS placenames_medium ``` The ordering merits further discussion We're currently not considering area or population for ordering, so anything is an improvement here. It's hard to say if area,population or population,area is better without trying one first.
Benchmarking shows \d+ and length with no NULL check is the fastest way to check if the population is safe to cast
Thank you for this PR.
I am not sure if I'd consider this a bug. On the one hand, it would be good to have one OSM object for every real-world object. On the other hand, points can indicate the center of the settlement, while the area can indicate the outline. Rendering the name in the middle of the area would often be ugly, in particular for 'unbalanced' settlements - like coastal settlements typically are, for example. |
Superceeded by #546 |
Part of #103
This will reveal two widespread problems in the data
I don't see revealing either as a blocker as it should lead to them getting fixed.