diff --git a/layers/poi/README.md b/layers/poi/README.md index cf6103e..de80baf 100644 --- a/layers/poi/README.md +++ b/layers/poi/README.md @@ -9,11 +9,12 @@ a of a variety of OpenStreetMap tags. Mostly contains amenities, sport, shop and this field will contain the same value as `subclass`. But for example for schools you only need to style the class `school` to filter the subclasses `school` and `kindergarten`. Or use the class `shop` to style all shops. -- **gridrank**: The POIs are ranked ascending according to their importance within a grid. The `gridrank` value shows the -local relative importance of a POI within it's cell in the grid. This can be used to reduce label density at z14. -Since all POIs already need to be contained at `z14` you can use `less than gridrank=10` epxression to limit -POIs. At some point like z17 you can show all POIs. - **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**: The POIs are ranked ascending according to their importance within a grid. The `rank` value shows the +local relative importance of a POI within it's cell in the grid. This can be used to reduce label density at z14. +Since all POIs already need to be contained at `z14` you can use `less than rank=10` epxression to limit +POIs. At some point like z17 you can show all POIs. - **subclass**: Original value of either the [`amenity`](http://wiki.openstreetmap.org/wiki/Key:amenity), [`leisure`](http://wiki.openstreetmap.org/wiki/Key:leisure), @@ -22,7 +23,6 @@ POIs. At some point like z17 you can show all POIs. [`tourism`](http://wiki.openstreetmap.org/wiki/Key:tourism) or [`shop`](http://wiki.openstreetmap.org/wiki/Key:shop) tag. Use this to do more precise styling. -- **name**: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the POI. ## Mapping diff --git a/layers/poi/layer.sql b/layers/poi/layer.sql index dd7cbf8..0a0a603 100644 --- a/layers/poi/layer.sql +++ b/layers/poi/layer.sql @@ -1,13 +1,13 @@ CREATE OR REPLACE FUNCTION layer_poi(bbox geometry, zoom_level integer, pixel_width numeric) -RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class text, subclass text, gridrank int) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class text, subclass text, "rank" int) AS $$ SELECT osm_id, geometry, name, NULLIF(name_en, ''), poi_class(subclass) AS class, subclass, row_number() OVER ( PARTITION BY LabelGrid(geometry, 100 * pixel_width) ORDER BY poi_class_rank(poi_class(subclass)) ASC, length(name) DESC - )::int AS gridrank + )::int AS "rank" FROM osm_poi_point WHERE geometry && bbox AND zoom_level >= 14 AND name <> '' - ORDER BY gridrank; + ORDER BY "rank"; $$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/poi/poi.yaml b/layers/poi/poi.yaml index 0cfdb00..b512067 100644 --- a/layers/poi/poi.yaml +++ b/layers/poi/poi.yaml @@ -22,15 +22,15 @@ layer: [`tourism`](http://wiki.openstreetmap.org/wiki/Key:tourism) or [`shop`](http://wiki.openstreetmap.org/wiki/Key:shop) tag. Use this to do more precise styling. - gridrank: | - The POIs are ranked ascending according to their importance within a grid. The `gridrank` value shows the + rank: | + The POIs are ranked ascending according to their importance within a grid. The `rank` value shows the local relative importance of a POI within it's cell in the grid. This can be used to reduce label density at z14. - Since all POIs already need to be contained at `z14` you can use `less than gridrank=10` epxression to limit + Since all POIs already need to be contained at `z14` you can use `less than rank=10` epxression to limit POIs. At some point like z17 you can show all POIs. datasource: geometry_field: geometry srid: 900913 - query: (SELECT geometry, name, name_en, class, subclass, gridrank FROM layer_poi(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t + query: (SELECT geometry, name, name_en, class, subclass, rank FROM layer_poi(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t schema: - ./class.sql - ./layer.sql