Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get city and town names for both place points and place polygons
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.
- Loading branch information