From 227b36c0d670228599d207fa5e3301552aba23fc Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Fri, 2 Dec 2016 12:30:41 +0000 Subject: [PATCH 1/3] Switch place class back to place value --- layers/place/capital.sql | 8 ++++++++ layers/place/class.sql | 18 ------------------ layers/place/layer.sql | 10 +++++----- layers/place/place.yaml | 23 ++++++----------------- 4 files changed, 19 insertions(+), 40 deletions(-) create mode 100644 layers/place/capital.sql delete mode 100644 layers/place/class.sql diff --git a/layers/place/capital.sql b/layers/place/capital.sql new file mode 100644 index 0000000..e132530 --- /dev/null +++ b/layers/place/capital.sql @@ -0,0 +1,8 @@ +CREATE OR REPLACE FUNCTION normalize_capital_level(capital TEXT) +RETURNS INT AS $$ + SELECT CASE + WHEN capital IN ('yes', '2') THEN 2 + WHEN capital = '4' THEN 4 + ELSE NULL + END; +$$ LANGUAGE SQL IMMUTABLE STRICT; diff --git a/layers/place/class.sql b/layers/place/class.sql deleted file mode 100644 index fa34921..0000000 --- a/layers/place/class.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE OR REPLACE FUNCTION place_class(place TEXT) -RETURNS TEXT AS $$ - SELECT CASE - WHEN place IN ('city', 'town', 'village', 'hamlet', 'isolated_dwelling') THEN 'settlement' - WHEN place IN ('suburb', 'neighbourhood') THEN 'subregion' - WHEN place IN ('locality', 'farm') THEN 'other' - ELSE NULL - END; -$$ LANGUAGE SQL IMMUTABLE STRICT; - -CREATE OR REPLACE FUNCTION normalize_capital_level(capital TEXT) -RETURNS INT AS $$ - SELECT CASE - WHEN capital IN ('yes', '2') THEN 2 - WHEN capital = '4' THEN 4 - ELSE NULL - END; -$$ LANGUAGE SQL IMMUTABLE STRICT; diff --git a/layers/place/layer.sql b/layers/place/layer.sql index 053a260..8b498d1 100644 --- a/layers/place/layer.sql +++ b/layers/place/layer.sql @@ -8,22 +8,22 @@ -- etldoc: layer_city -> layer_place CREATE OR REPLACE FUNCTION layer_place(bbox geometry, zoom_level int, pixel_width numeric) -RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class text, subclass text, "rank" int, capital INT) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class text, "rank" int, capital INT) AS $$ SELECT osm_id, geometry, name, name_en, - 'continent' AS class, 'continent' AS subclass, 1 AS "rank", NULL::int AS capital + 'continent' AS class, 1 AS "rank", NULL::int AS capital FROM osm_continent_point WHERE geometry && bbox AND zoom_level < 4 UNION ALL SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, - 'country' AS class, 'country' AS subclass,"rank", NULL::int AS capital + 'country' AS class,"rank", NULL::int AS capital FROM osm_country_point WHERE geometry && bbox AND "rank" <= zoom_level AND name <> '' UNION ALL SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, - 'state' AS class, 'state' AS subclass, "rank", NULL::int AS capital + 'state' AS class, "rank", NULL::int AS capital FROM osm_state_point WHERE geometry && bbox AND name <> '' AND @@ -34,7 +34,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class t UNION ALL SELECT osm_id, geometry, name, name_en, - place_class(place::text) AS class, place::text AS subclass, "rank", capital + place::text AS class, "rank", capital FROM layer_city(bbox, zoom_level, pixel_width) ORDER BY "rank" ASC $$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/place/place.yaml b/layers/place/place.yaml index 443c268..afc2533 100644 --- a/layers/place/place.yaml +++ b/layers/place/place.yaml @@ -16,23 +16,12 @@ layer: values: [2, 4] class: | description: | - Distinguish between continents, countries, states and - places like settlements or smaller entities. - Use this to separately style the different places and build - a text hierarchy according to their importance. - than cities). - values: - - continent - - country - - state - - settlement - - subregion - - other - subclass: - description: | - Use **subclass** to do more precise styling. Original value of the [`place`](http://wiki.openstreetmap.org/wiki/Key:place) tag. + Distinguish between continents, countries, states and + places like settlements or smaller entities. + Use **class** to separately style the different places and build + a text hierarchy according to their importance. values: - continent - country @@ -63,10 +52,10 @@ layer: buffer_size: 128 datasource: geometry_field: geometry - query: (SELECT geometry, name, name_en, class, subclass, rank, capital FROM layer_place(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t + query: (SELECT geometry, name, name_en, class, rank, capital FROM layer_place(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t schema: - ./types.sql - - ./class.sql + - ./capital.sql - ./city.sql - ./merge_country_rank.sql - ./merge_city_rank.sql From a109ffd72e22456d5d2bd5a3afeefc2b49e86eb9 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Fri, 2 Dec 2016 12:36:10 +0000 Subject: [PATCH 2/3] Remove subclass from transport --- layers/transportation/layer.sql | 3 +- layers/transportation/transportation.yaml | 65 +++++------------------ 2 files changed, 15 insertions(+), 53 deletions(-) diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index 0e431f9..924ab96 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -6,14 +6,13 @@ $$ LANGUAGE SQL IMMUTABLE STRICT; -- etldoc: layer_transportation[shape=record fillcolor=lightpink, style="rounded,filled", -- etldoc: label=" layer_transportation | z4-z6 | z7-z8 | z9 | z10 | z11 | z12| z13| z14+" ] ; CREATE OR REPLACE FUNCTION layer_transportation(bbox geometry, zoom_level int) -RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp int, oneway int, brunnel TEXT, service TEXT) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, class text, ramp int, oneway int, brunnel TEXT, service TEXT) AS $$ SELECT osm_id, geometry, CASE WHEN highway IS NOT NULL THEN highway_class(highway) WHEN railway IS NOT NULL THEN railway_class(railway) END AS class, - COALESCE(NULLIF(highway,''), NULLIF(railway, '')) AS subclass, -- All links are considered as ramps as well CASE WHEN highway_is_link(highway) OR highway = 'steps' THEN 1 ELSE is_ramp::int END AS ramp, diff --git a/layers/transportation/transportation.yaml b/layers/transportation/transportation.yaml index 3788f8c..5ce76b3 100644 --- a/layers/transportation/transportation.yaml +++ b/layers/transportation/transportation.yaml @@ -1,23 +1,23 @@ layer: id: "transportation" description: | - **transportation** containsrRoads and railways. - This layer is directly derived from the OSM road hierarchy which is why it is called `highway`. Only - at zoom level 4 to 7 some major highways from Natural Earth are used otherwise it is only OSM data. - It contains all roads from motorways to primary, secondary and tertiary roads to residential roads and - foot paths. Styling the roads is the most essential part of the map. If you can put enough effort into it - makes sense to carefully style each `subclass`. For more comfortable styling you can also just style the roads - by `class`. Roads can have different properties, a road can have `oneway=yes` and `bridge=yes` at the same time. - These properties are reflected in the field `properties`. - This layer is not meant for labelling the roads (the purpose of the layer `highway_name`). - + **transportation** contains roads and railways. + This layer is directly derived from the OSM road hierarchy. + Only at zoom level 4 to 6 some major highways from Natural Earth + are used. + It contains all roads from motorways to primary, secondary and + tertiary roads to residential roads and + foot paths. Styling the roads is the most essential part of the map. The `highway` layer also contains polygons for things like plazas. buffer_size: 4 srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over fields: class: description: | - Distinguish between more and less important roads. + Distinguish between more and less important roads or railways. + Class is derived from the value of the + [`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) or + [`railway`](http://wiki.openstreetmap.org/wiki/Key:railway) tag. values: - motorway - trunk @@ -25,49 +25,12 @@ layer: - secondary - tertiary - minor - - track - service + - track - path - subclass: - description: | - Use **subclass** to do more precise styling. - Original value of the - [`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) or - [`railway`](http://wiki.openstreetmap.org/wiki/Key:railway) tag. - values: - - motorway - - motorway_link - - trunk - - trunk_link - - primary - - primary_link - - secondary - - secondary_link - - tertiary - - tertiary_link - - unclassified - - residential - - road - - living_street - raceway - - construction - - track - - service - - path - - cycleway - - bridleway - - footway - - corridor - - crossing - - pedestrian - rail - - narrow_gauge - - preserved - - funicular - - subway - - light_rail - - monorail - - tram + - transit brunnel: description: | Mark whether way is a tunnel or bridge. @@ -99,7 +62,7 @@ layer: datasource: geometry_field: geometry srid: 900913 - query: (SELECT geometry, class, subclass, oneway, ramp, brunnel, service FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t + query: (SELECT geometry, class, oneway, ramp, brunnel, service FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t schema: - ./class.sql - ./layer.sql From 681b50ff1c74eaf4afe6ec60ff67895e07715d62 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Fri, 2 Dec 2016 12:39:10 +0000 Subject: [PATCH 3/3] Remove subclass from transportation_name --- layers/transportation_name/layer.sql | 4 +- .../transportation_name.yaml | 43 ++----------------- 2 files changed, 5 insertions(+), 42 deletions(-) diff --git a/layers/transportation_name/layer.sql b/layers/transportation_name/layer.sql index 7afbcd8..90716e4 100644 --- a/layers/transportation_name/layer.sql +++ b/layers/transportation_name/layer.sql @@ -3,12 +3,12 @@ -- etldoc: label="layer_transportation_name | z8 | z9 | z10 | z11 | z12| z13| z14_" ] ; CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level integer) -RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length int, network text, class text, subclass text) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length int, network text, class text) AS $$ SELECT osm_id, geometry, name, NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length, --TODO: The road network of the road is not yet implemented NULL::text AS network, - highway_class(highway) AS class, highway AS subclass + highway_class(highway) AS class FROM ( -- etldoc: osm_transportation_name_linestring_gen3 -> layer_transportation_name:z8 diff --git a/layers/transportation_name/transportation_name.yaml b/layers/transportation_name/transportation_name.yaml index b5615a0..60e668d 100644 --- a/layers/transportation_name/transportation_name.yaml +++ b/layers/transportation_name/transportation_name.yaml @@ -22,53 +22,16 @@ layer: - secondary - tertiary - minor - - track - service + - track - path - subclass: - description: | - Use **subclass** to do more precise styling. - Original value of the - [`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) or - [`railway`](http://wiki.openstreetmap.org/wiki/Key:railway) tag. - values: - - motorway - - motorway_link - - trunk - - trunk_link - - primary - - primary_link - - secondary - - secondary_link - - tertiary - - tertiary_link - - unclassified - - residential - - road - - living_street - raceway - - construction - - track - - service - - path - - cycleway - - bridleway - - footway - - corridor - - crossing - - pedestrian - rail - - narrow_gauge - - preserved - - funicular - - subway - - light_rail - - monorail - - tram + - transit datasource: geometry_field: geometry srid: 900913 - query: (SELECT geometry, name, ref, ref_length, class::text, subclass FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t + query: (SELECT geometry, name, ref, ref_length, class::text FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t schema: - ./merge_highways.sql - ./layer.sql