Incorporate grid rank into city rank

This commit is contained in:
lukasmartinelli 2016-10-29 14:49:53 +02:00
parent 52e133e126
commit 28a87c9e81
3 changed files with 22 additions and 14 deletions

View File

@ -11,8 +11,12 @@ We suggest you use different font styles and sizes to create a text hierarchy.
- **name**: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the POI. - **name**: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the POI.
- **rank**: Countries, states and the most important cities all have a `rank` to boost their importance on the map. - **rank**: Countries, states and the most important cities all have a `rank` to boost their importance on the map.
The `rank` field for counries and states ranges from `1` to `6` while the `rank` field for The `rank` field for counries and states ranges from `1` to `6` while the `rank` field for
cities ranges from `1` to `10`. Use the `rank` field to build a text hierarchy. cities ranges from `1` to `10` for the most important cities and continues from `10` serially based
The rank value is a combination of the Natural Earth `scalerank`, `labelrank` and `datarank` values. on the local importance of the city (derived from population and city class).
Use the `rank` field to build a text hierarchy.
The rank value is a combination of the Natural Earth `scalerank`, `labelrank` and `datarank` values for countries
and states and for cities consists out of a shifted Natural Earth `scalerank` combined with a local rank
within a grid for cities that do not have a Natural Earth `scalerank`.
- **class**: Distinguish between `country`, `state` and other city classes like - **class**: Distinguish between `country`, `state` and other city classes like
`city`, `town`, `village`, `hamlet`, `suburb`, `neighbourhood` or `isolated_dwelling`. `city`, `town`, `village`, `hamlet`, `suburb`, `neighbourhood` or `isolated_dwelling`.
Use this to separately style the different places according to their importance (usually country and state different Use this to separately style the different places according to their importance (usually country and state different

View File

@ -7,14 +7,15 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class c
OR (zoom_level BETWEEN 3 AND 7 AND "rank" <= zoom_level) OR (zoom_level BETWEEN 3 AND 7 AND "rank" <= zoom_level)
) )
UNION ALL UNION ALL
SELECT osm_id, geometry, name, name_en, place, "rank" FROM ( SELECT osm_id, geometry, name, name_en, place, COALESCE("rank", gridrank + 10) FROM (
SELECT osm_id, geometry, name, name_en, place, "rank", SELECT osm_id, geometry, name, name_en, place, "rank",
row_number() OVER ( row_number() OVER (
PARTITION BY LabelGrid(geometry, 150 * pixel_width) PARTITION BY LabelGrid(geometry, 150 * pixel_width)
ORDER BY place ASC NULLS LAST, ORDER BY "rank" ASC NULLS LAST,
population DESC NULLS LAST, place ASC NULLS LAST,
length(name) DESC population DESC NULLS LAST,
) AS gridrank length(name) ASC
)::int AS gridrank
FROM osm_city_point FROM osm_city_point
WHERE geometry && bbox WHERE geometry && bbox
AND ((zoom_level BETWEEN 8 AND 9 AND place <= 'town'::city_class) AND ((zoom_level BETWEEN 8 AND 9 AND place <= 'town'::city_class)
@ -23,7 +24,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class c
OR (zoom_level >= 14) OR (zoom_level >= 14)
) )
) AS ranked_places ) AS ranked_places
WHERE (zoom_level = 8 AND gridrank <= 4) WHERE (zoom_level = 8 AND (gridrank <= 4 OR "rank" IS NOT NULL))
OR (zoom_level BETWEEN 9 AND 12 AND gridrank <= 9) OR (zoom_level BETWEEN 9 AND 12 AND (gridrank <= 9 OR "rank" IS NOT NULL))
OR (zoom_level >= 13); OR (zoom_level >= 13);
$$ LANGUAGE SQL IMMUTABLE; $$ LANGUAGE SQL IMMUTABLE;

View File

@ -16,9 +16,12 @@ layer:
rank: | rank: |
Countries, states and the most important cities all have a `rank` to boost their importance on the map. Countries, states and the most important cities all have a `rank` to boost their importance on the map.
The `rank` field for counries and states ranges from `1` to `6` while the `rank` field for The `rank` field for counries and states ranges from `1` to `6` while the `rank` field for
cities ranges from `1` to `10`. Use the `rank` field to build a text hierarchy. cities ranges from `1` to `10` for the most important cities and continues from `10` serially based
on the local importance of the city (derived from population and city class).
Use the `rank` field to build a text hierarchy.
The rank value is a combination of the Natural Earth `scalerank`, `labelrank` and `datarank` values for countries The rank value is a combination of the Natural Earth `scalerank`, `labelrank` and `datarank` values for countries
and states and a shifted Natural Earth `scalerank` for cities. and states and for cities consists out of a shifted Natural Earth `scalerank` combined with a local rank
within a grid for cities that do not have a Natural Earth `scalerank`.
buffer_size: 128 buffer_size: 128
datasource: datasource:
geometry_field: geometry geometry_field: geometry