kopia lustrzana https://github.com/openmaptiles/openmaptiles
Make ranks more fine grained
rodzic
001e44ccd7
commit
3f9f59dfe1
|
|
@ -9,10 +9,10 @@ We suggest you use different font styles and sizes to create a text hierarchy.
|
|||
|
||||
- **name_en**: The english `name:en` value if available.
|
||||
- **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` field ranging from `1` to `6` which
|
||||
marks the importance of the feature. Less important places do not have a `rank`.
|
||||
Use this to build a text hierarchy. The rank value originates from Natural Earth data and is either the
|
||||
original `scalerank` for cities or the original `labelrank` for countries and states.
|
||||
- **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
|
||||
cities ranges from `1` to `10`. Use the `rank` field to build a text hierarchy.
|
||||
The rank value is a combination of the Natural Earth `scalerank`, `labelrank` and `datarank` values.
|
||||
- **class**: Distinguish between `country`, `state` and other city classes like
|
||||
`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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
WITH important_city_point AS (
|
||||
SELECT osm.geometry, osm.osm_id, osm.name, osm.name_en, ne.scalerank
|
||||
SELECT osm.geometry, osm.osm_id, osm.name, osm.name_en, ne.scalerank, ne.labelrank
|
||||
FROM ne_10m_populated_places AS ne, osm_city_point AS osm
|
||||
WHERE
|
||||
(
|
||||
|
|
@ -18,7 +18,11 @@ WITH important_city_point AS (
|
|||
AND ST_DWithin(ne.geom, osm.geometry, 50000)
|
||||
)
|
||||
UPDATE osm_city_point AS osm
|
||||
SET "rank" = ne.scalerank
|
||||
-- Normalize both scalerank and labelrank into a ranking system from 1 to 10.
|
||||
-- Scaleranks for NE populated place range from 0 to 8 and labelranks range from 0 to 10.
|
||||
-- To give features with both ranks close to 0 a lower rank we increase the range from 1 to 9 and 1 to 11.
|
||||
-- This means a max combined rank of 20 divided by 2 to get us uniform ranking from 1 to 10
|
||||
SET "rank" = CEILING((ne.scalerank + 1 + ne.labelrank + 1)/2.0)
|
||||
FROM important_city_point AS ne
|
||||
WHERE osm.osm_id = ne.osm_id;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
ALTER TABLE osm_country_point DROP CONSTRAINT IF EXISTS osm_country_point_rank_constraint;
|
||||
|
||||
WITH important_country_point AS (
|
||||
SELECT osm.geometry, osm.osm_id, osm.name, COALESCE(NULLIF(osm.name_en, ''), ne.name) AS name_en, ne.labelrank
|
||||
SELECT osm.geometry, osm.osm_id, osm.name, COALESCE(NULLIF(osm.name_en, ''), ne.name) AS name_en, ne.scalerank, ne.labelrank
|
||||
FROM ne_10m_admin_0_countries AS ne, osm_country_point AS osm
|
||||
WHERE
|
||||
-- We only match whether the point is within the Natural Earth polygon
|
||||
|
|
@ -10,17 +12,16 @@ WITH important_country_point AS (
|
|||
AND ne.scalerank <= 1
|
||||
)
|
||||
UPDATE osm_country_point AS osm
|
||||
-- We merge the labelrank not scalerank because it is more fine grained
|
||||
-- and allows styling more important countries bigger than others
|
||||
SET "rank" = ne.labelrank
|
||||
-- Normalize both scalerank and labelrank into a ranking system from 1 to 6
|
||||
-- Scaleranks for NE countries range from 0 to 6 and labelranks range from 2 to 10.
|
||||
-- This means a max combined rank of 16 divided by 3 to get us uniform ranking from 1 to 6
|
||||
SET "rank" = CEILING((scalerank + labelrank)/3.0)
|
||||
FROM important_country_point AS ne
|
||||
WHERE osm.osm_id = ne.osm_id;
|
||||
|
||||
UPDATE osm_country_point AS osm
|
||||
SET "rank" = 6
|
||||
WHERE "rank" <= 0 OR "rank" > 6 OR "rank" IS NULL;
|
||||
WHERE "rank" < 0 OR "rank" > 6 OR "rank" IS NULL;
|
||||
|
||||
ALTER TABLE osm_country_point DROP CONSTRAINT IF EXISTS osm_country_point_rank_constraint;
|
||||
ALTER TABLE osm_country_point ADD CONSTRAINT osm_country_point_rank_constraint CHECK("rank" BETWEEN 1 AND 6);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_country_point_rank_idx ON osm_country_point("rank");
|
||||
CREATE INDEX IF NOT EXISTS osm_country_point_rank_idx ON osm_country_point("rank");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
ALTER TABLE osm_state_point DROP CONSTRAINT IF EXISTS osm_state_point_rank_constraint;
|
||||
|
||||
WITH important_state_point AS (
|
||||
SELECT osm.geometry, osm.osm_id, osm.name, COALESCE(NULLIF(osm.name_en, ''), ne.name) AS name_en, ne.scalerank, ne.labelrank
|
||||
SELECT osm.geometry, osm.osm_id, osm.name, COALESCE(NULLIF(osm.name_en, ''), ne.name) AS name_en, ne.scalerank, ne.labelrank, ne.datarank
|
||||
FROM ne_10m_admin_1_states_provinces_shp AS ne, osm_state_point AS osm
|
||||
WHERE
|
||||
-- We only match whether the point is within the Natural Earth polygon
|
||||
|
|
@ -9,17 +11,14 @@ WITH important_state_point AS (
|
|||
AND ne.scalerank <= 3 AND ne.labelrank <= 2
|
||||
)
|
||||
UPDATE osm_state_point AS osm
|
||||
-- We merge the labelrank not scalerank because it is more fine grained
|
||||
SET "rank" = ne.labelrank
|
||||
-- Normalize both scalerank and labelrank into a ranking system from 1 to 6.
|
||||
-- Scaleranks for NE states range from 2 to 11 and labelranks range from 0 to 20 and dataranks from 1 to 11.
|
||||
-- This means a max combined rank of 42 divided by 7 to get us uniform ranking from 1 to 6
|
||||
SET "rank" = CEILING((scalerank + labelrank + datarank)/7.0)
|
||||
FROM important_state_point AS ne
|
||||
WHERE osm.osm_id = ne.osm_id;
|
||||
|
||||
UPDATE osm_state_point AS osm
|
||||
SET "rank" = 6
|
||||
WHERE "rank" <= 0 OR "rank" > 6;
|
||||
|
||||
DELETE FROM osm_state_point WHERE "rank" IS NULL;
|
||||
|
||||
ALTER TABLE osm_state_point DROP CONSTRAINT IF EXISTS osm_state_point_rank_constraint;
|
||||
ALTER TABLE osm_state_point ADD CONSTRAINT osm_state_point_rank_constraint CHECK("rank" BETWEEN 1 AND 6);
|
||||
CREATE INDEX IF NOT EXISTS osm_state_point_rank_idx ON osm_state_point("rank");
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ layer:
|
|||
Use this to separately style the different places according to their importance (usually country and state different
|
||||
than cities).
|
||||
rank: |
|
||||
Countries, states and the most important cities all have a `rank` field ranging from `1` to `6` which
|
||||
marks the importance of the feature. Less important places do not have a `rank`.
|
||||
Use this to build a text hierarchy. The rank value originates from Natural Earth data and is either the
|
||||
original `scalerank` for cities or the original `labelrank` for countries and states.
|
||||
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
|
||||
cities ranges from `1` to `10`. Use the `rank` field to build a text hierarchy.
|
||||
The rank value is a combination of the Natural Earth `scalerank`, `labelrank` and `datarank` values.
|
||||
buffer_size: 128
|
||||
datasource:
|
||||
geometry_field: geometry
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue