From 35b6951c81f7c2c152f137536d31edd7789e87cb Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Sat, 26 Nov 2016 20:19:43 +0000 Subject: [PATCH 01/21] Move highway and railway into transportation --- Makefile | 12 ++-- layers/highway_name/layer.sql | 50 --------------- layers/highway_name/merge_highways.sql | 57 ------------------ layers/railway/README.md | 19 ------ layers/railway/mapping | 14 ----- layers/railway/mapping.png | Bin 13139 -> 0 bytes layers/railway/mapping.yaml | 34 ----------- layers/railway/railway.sql | 35 ----------- layers/railway/railway.yaml | 25 -------- layers/railway/types.sql | 15 ----- layers/{highway => transportation}/README.md | 0 .../{highway => transportation}/highway.sql | 46 +++++++------- layers/transportation/mapping | 39 ++++++++++++ .../{highway => transportation}/mapping.png | Bin .../{highway => transportation}/mapping.yaml | 51 +++++++++++----- .../ne_global_roads.sql | 0 .../transportation.yaml} | 4 +- layers/{highway => transportation}/types.sql | 0 .../README.md | 0 layers/transportation_name/layer.sql | 50 +++++++++++++++ layers/transportation_name/merge_highways.sql | 57 ++++++++++++++++++ .../transportation_name.yaml} | 6 +- openmaptiles.yaml | 5 +- 23 files changed, 216 insertions(+), 303 deletions(-) delete mode 100644 layers/highway_name/layer.sql delete mode 100644 layers/highway_name/merge_highways.sql delete mode 100644 layers/railway/README.md delete mode 100644 layers/railway/mapping delete mode 100644 layers/railway/mapping.png delete mode 100644 layers/railway/mapping.yaml delete mode 100644 layers/railway/railway.sql delete mode 100644 layers/railway/railway.yaml delete mode 100644 layers/railway/types.sql rename layers/{highway => transportation}/README.md (100%) rename layers/{highway => transportation}/highway.sql (63%) create mode 100644 layers/transportation/mapping rename layers/{highway => transportation}/mapping.png (100%) rename layers/{highway => transportation}/mapping.yaml (66%) rename layers/{highway => transportation}/ne_global_roads.sql (100%) rename layers/{highway/highway.yaml => transportation/transportation.yaml} (96%) rename layers/{highway => transportation}/types.sql (100%) rename layers/{highway_name => transportation_name}/README.md (100%) create mode 100644 layers/transportation_name/layer.sql create mode 100644 layers/transportation_name/merge_highways.sql rename layers/{highway_name/highway_name.yaml => transportation_name/transportation_name.yaml} (90%) diff --git a/Makefile b/Makefile index ca51ae48..0cf6d7b2 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ all: build/openmaptiles.tm2source/data.yml build/mapping.yaml build/tileset.sql .PHONY: docs -docs: layers/railway/README.md layers/boundary/README.md layers/water/README.md layers/building/README.md layers/highway/README.md layers/highway_name/README.md layers/poi/README.md layers/place/README.md layers/waterway/README.md layers/water_name/README.md layers/landcover/README.md layers/landuse/README.md layers/housenumber/README.md +docs: layers/railway/README.md layers/boundary/README.md layers/water/README.md layers/building/README.md layers/transportation/README.md layers/transportation_name/README.md layers/poi/README.md layers/place/README.md layers/waterway/README.md layers/water_name/README.md layers/landcover/README.md layers/landuse/README.md layers/housenumber/README.md build/openmaptiles.tm2source/data.yml: mkdir -p build/openmaptiles.tm2source && generate-tm2source openmaptiles.yaml --host="postgres" --port=5432 --database="openmaptiles" --user="openmaptiles" --password="openmaptiles" > build/openmaptiles.tm2source/data.yml @@ -15,11 +15,11 @@ build/tileset.sql: layers/poi/README.md: generate-doc layers/poi/poi.yaml --diagram layers/poi/mapping > layers/poi/README.md -layers/highway/README.md: - generate-doc layers/highway/highway.yaml --diagram layers/highway/mapping > layers/highway/README.md +layers/transportation/README.md: + generate-doc layers/transportation/transportation.yaml --diagram layers/transportation/mapping > layers/transportation/README.md -layers/highway_name/README.md: - generate-doc layers/highway_name/highway_name.yaml > layers/highway_name/README.md +layers/transportation_name/README.md: + generate-doc layers/transportation_name/transportation_name.yaml > layers/transportation_name/README.md layers/railway/README.md: generate-doc layers/railway/railway.yaml --diagram layers/railway/mapping > layers/railway/README.md @@ -52,4 +52,4 @@ layers/housenumber/README.md: generate-doc layers/housenumber/housenumber.yaml > layers/housenumber/README.md clean: - rm -f build/openmaptiles.tm2source/data.yml && rm -f build/mapping.yaml && rm -f build/tileset.sql && rm -f layers/**/README.md&& rm -f layers/**/*.png + rm -f build/openmaptiles.tm2source/data.yml && rm -f build/mapping.yaml && rm -f build/tileset.sql diff --git a/layers/highway_name/layer.sql b/layers/highway_name/layer.sql deleted file mode 100644 index 100b1fc7..00000000 --- a/layers/highway_name/layer.sql +++ /dev/null @@ -1,50 +0,0 @@ - --- etldoc: layer_highway_name[shape=record fillcolor=lightpink, style="rounded,filled", --- etldoc: label="layer_highway_name | z8 | z9 | z10 | z11 | z12| z13| z14_" ] ; - -CREATE OR REPLACE FUNCTION layer_highway_name(bbox geometry, zoom_level integer) -RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length int, class highway_class, subclass text) AS $$ - SELECT osm_id, geometry, name, - NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length, - to_highway_class(highway) AS class, highway AS subclass - FROM ( - - -- etldoc: osm_highway_name_linestring_gen3 -> layer_highway_name:z8 - SELECT * FROM osm_highway_name_linestring_gen3 - WHERE zoom_level = 8 - UNION ALL - - -- etldoc: osm_highway_name_linestring_gen2 -> layer_highway_name:z9 - SELECT * FROM osm_highway_name_linestring_gen2 - WHERE zoom_level = 9 - UNION ALL - - -- etldoc: osm_highway_name_linestring_gen1 -> layer_highway_name:z10 - -- etldoc: osm_highway_name_linestring_gen1 -> layer_highway_name:z11 - SELECT * FROM osm_highway_name_linestring_gen1 - WHERE zoom_level BETWEEN 10 AND 11 - UNION ALL - - -- etldoc: osm_highway_name_linestring -> layer_highway_name:z12 - SELECT * FROM osm_highway_name_linestring - WHERE zoom_level = 12 - AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) - AND to_highway_class(highway) < 'minor_road'::highway_class - AND NOT highway_is_link(highway) - UNION ALL - - -- etldoc: osm_highway_name_linestring -> layer_highway_name:z13 - SELECT * FROM osm_highway_name_linestring - WHERE zoom_level = 13 - AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) - AND to_highway_class(highway) < 'path'::highway_class - UNION ALL - - -- etldoc: osm_highway_name_linestring -> layer_highway_name:z14_ - SELECT * FROM osm_highway_name_linestring - WHERE zoom_level >= 14 - - ) AS zoom_levels - WHERE geometry && bbox - ORDER BY z_order ASC; -$$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/highway_name/merge_highways.sql b/layers/highway_name/merge_highways.sql deleted file mode 100644 index a96f6d14..00000000 --- a/layers/highway_name/merge_highways.sql +++ /dev/null @@ -1,57 +0,0 @@ --- Instead of using relations to find out the road names we --- stitch together the touching ways with the same name --- to allow for nice label rendering --- Because this works well for roads that do not have relations as well - --- etldoc: osm_highway_linestring -> osm_highway_name_linestring -CREATE TABLE IF NOT EXISTS osm_highway_name_linestring AS ( - SELECT - (ST_Dump(geometry)).geom AS geometry, - -- NOTE: The osm_id is no longer the original one which can make it difficult - -- to lookup road names by OSM ID - member_osm_ids[0] AS osm_id, - member_osm_ids, - name, - ref, - highway, - z_order - FROM ( - SELECT - ST_LineMerge(ST_Union(geometry)) AS geometry, - name, - ref, - highway, - min(z_order) AS z_order, - array_agg(DISTINCT osm_id) AS member_osm_ids - FROM osm_highway_linestring - -- We only care about roads for labelling - WHERE name <> '' OR ref <> '' - GROUP BY name, highway, ref - ) AS highway_union -); - -CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_geometry_idx ON osm_highway_name_linestring USING gist(geometry); - --- etldoc: osm_highway_name_linestring -> osm_highway_name_linestring_gen1 -CREATE TABLE IF NOT EXISTS osm_highway_name_linestring_gen1 AS ( - SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order - FROM osm_highway_name_linestring - WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 8000 -); -CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_gen1_geometry_idx ON osm_highway_name_linestring_gen1 USING gist(geometry); - --- etldoc: osm_highway_name_linestring_gen1 -> osm_highway_name_linestring_gen2 -CREATE TABLE IF NOT EXISTS osm_highway_name_linestring_gen2 AS ( - SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order - FROM osm_highway_name_linestring_gen1 - WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 14000 -); -CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_gen2_geometry_idx ON osm_highway_name_linestring_gen2 USING gist(geometry); - --- etldoc: osm_highway_name_linestring_gen2 -> osm_highway_name_linestring_gen3 -CREATE TABLE IF NOT EXISTS osm_highway_name_linestring_gen3 AS ( - SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order - FROM osm_highway_name_linestring_gen2 - WHERE highway = 'motorway' AND ST_Length(geometry) > 20000 -); -CREATE INDEX IF NOT EXISTS osm_highway_name_linestring_gen3_geometry_idx ON osm_highway_name_linestring_gen3 USING gist(geometry); diff --git a/layers/railway/README.md b/layers/railway/README.md deleted file mode 100644 index 8a1bc516..00000000 --- a/layers/railway/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# railway - -The `railway` layer contains linestrings marking tracks from [OSM Railways](http://wiki.openstreetmap.org/wiki/Railways). -It contains tracks for [passenger and freight trains]() and smaller tracks for [Trams](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dtram) or [similar](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dlight_rail) vehicles. But also tracks for [subways](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dsubway), [narrow-gauge trains](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dnarrow_gauge) or [historic trains](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dpreserved). -Non mainline tracks (marked with class `minor_rail`) used for [storage of trains](http://wiki.openstreetmap.org/wiki/Tag:service%3Dyard) and [maintenance](http://wiki.openstreetmap.org/wiki/Tag:service%3Dsiding) are contained in the highest zoom levels and should be styled more subtle than the mainline tracks with class `rail`. - -## Fields - -- **class**: Divides the track into mainline tracks (class `rail`) and less important tracks -used for maintenance (class `minor_rail`). -- **subclass**: Original value of the [`railway`](http://wiki.openstreetmap.org/wiki/Key:railway) can be one of -`rail`, `light_rail`, `subway`, `narrow_gauge`, `preserved`, `tram`. -- **properties**: Additional properties describing the nature of tracks. Can be either `bridge` or `tunnel`. - -## Mapping - -![](mapping.png) - - diff --git a/layers/railway/mapping b/layers/railway/mapping deleted file mode 100644 index d068987d..00000000 --- a/layers/railway/mapping +++ /dev/null @@ -1,14 +0,0 @@ -digraph "Imposm Mapping" { - graph [rankdir=LR ranksep=3] - subgraph railway_linestring { - node [fixed_size=shape "width:"=20] - railway_linestring [shape=box] - key_railway [label=railway shape=box] - key_railway -> railway_linestring [label="rail -light_rail -subway -narrow_gauge -preserved -tram"] - } -} \ No newline at end of file diff --git a/layers/railway/mapping.png b/layers/railway/mapping.png deleted file mode 100644 index 52a472337b77d0c4713abdb97eec597e6ff00d8a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13139 zcmZ8|1yodF*Yz+A4Kjd8N{7;dq%=qiC`d@RAd=FJAl*tgC?S#xNT+m%fOMC1=l=}& zzVEmGwXU%S?sM;b?m7GHz0a8-WkqQmOj1k;1cDU9p*#7aw$Lteg z-Hr{Vm>SZ@4?7Az1{+&&sAr3tq&5>Wkp$Ddx?VXx*qY*BQC!ho(LGK+*Gj{6+y3!e zx7lgNt#`ZdN9sz)d~y<-0-Y%Izej?9Ln8|lM8}kbwN3VaAJb9UYGU}nWW4`#P}$?9 zL%OxMld|ZM@TvYC8IVO>B#cPNzr&alde=K))8D@Gzsu8!BDJUe?*#mIW7q=-*ErUS zjqHDy_J&4^AcHg3#P!?4?+^ZXqaG9zQg(E8v9F|AX_IlVHYB~=lN871p-+3et`|W% zWKju<5h+>)*Qj;JI%OjgJ?YBH&3*~i-ak9MF;LP z8_S31?L@nh$R*vgB%U8f7NZ3Zh1`x5;>yR-ZyrLF0|~Q1pQ45a313D6>W@i?nGb%x z>6k(ExCAVgU5|}XDfOe=C#H^U*_dpx_oy$b9p9c_ z9?zI`MAQ3zp0*q>m0jsg`79ZPf7O0{w!yAh^)7F*CrRC6B!6jT-|uFZ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_railway_linestring - railway_linestring: - type: linestring - fields: - - name: osm_id - type: id - - name: geometry - type: geometry - - key: railway - name: railway - type: string - - name: z_order - type: wayzorder - - key: tunnel - name: is_tunnel - type: bool - - key: bridge - name: is_bridge - type: bool - - key: service - name: service - type: string - - key: usage - name: usage - type: string - mapping: - railway: - - rail - - light_rail - - subway - - narrow_gauge - - preserved - - tram diff --git a/layers/railway/railway.sql b/layers/railway/railway.sql deleted file mode 100644 index 7902211c..00000000 --- a/layers/railway/railway.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE OR REPLACE FUNCTION railway_class(railway text, service text) RETURNS TEXT AS $$ - SELECT CASE - WHEN railway='rail' AND service='' THEN 'rail' - ELSE 'minor_rail' - END; -$$ LANGUAGE SQL IMMUTABLE; - -CREATE OR REPLACE FUNCTION railway_brunnel(is_bridge boolean, is_tunnel boolean) RETURNS TEXT AS $$ - SELECT CASE - WHEN is_bridge THEN 'bridge' - WHEN is_tunnel THEN 'tunnel' - ELSE NULL - END; -$$ LANGUAGE SQL IMMUTABLE; - --- etldoc: layer_railway[shape=record fillcolor=lightpink, style="rounded,filled", --- etldoc: label="layer_railway | z13 | z14_" ] ; - -CREATE OR REPLACE FUNCTION layer_railway(bbox geometry, zoom_level int) -RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, properties railway_properties) AS $$ - SELECT osm_id, geometry, - railway_class(railway, service) AS class, - railway AS subclass, - to_railway_properties(is_bridge, is_tunnel) AS properties - FROM ( - -- etldoc: osm_railway_linestring -> layer_railway :z13 - SELECT * FROM osm_railway_linestring - WHERE zoom_level = 13 AND railway = 'rail' AND service='' - UNION ALL - -- etldoc: osm_railway_linestring -> layer_railway :z14_ - SELECT * FROM osm_railway_linestring WHERE zoom_level >= 14 - ) AS zoom_levels - WHERE geometry && bbox - ORDER BY z_order ASC; -$$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/railway/railway.yaml b/layers/railway/railway.yaml deleted file mode 100644 index 913f4d6c..00000000 --- a/layers/railway/railway.yaml +++ /dev/null @@ -1,25 +0,0 @@ -layer: - id: "railway" - description: | - The `railway` layer contains linestrings marking tracks from [OSM Railways](http://wiki.openstreetmap.org/wiki/Railways). - It contains tracks for [passenger and freight trains]() and smaller tracks for [Trams](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dtram) or [similar](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dlight_rail) vehicles. But also tracks for [subways](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dsubway), [narrow-gauge trains](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dnarrow_gauge) or [historic trains](http://wiki.openstreetmap.org/wiki/Tag:railway%3Dpreserved). - Non mainline tracks (marked with class `minor_rail`) used for [storage of trains](http://wiki.openstreetmap.org/wiki/Tag:service%3Dyard) and [maintenance](http://wiki.openstreetmap.org/wiki/Tag:service%3Dsiding) are contained in the highest zoom levels and should be styled more subtle than the mainline tracks with class `rail`. - fields: - class: | - Divides the track into mainline tracks (class `rail`) and less important tracks - used for maintenance (class `minor_rail`). - subclass: | - Original value of the [`railway`](http://wiki.openstreetmap.org/wiki/Key:railway) can be one of - `rail`, `light_rail`, `subway`, `narrow_gauge`, `preserved`, `tram`. - properties: | - Additional properties describing the nature of tracks. Can be either `bridge` or `tunnel`. - buffer_size: 4 - datasource: - geometry_field: geometry - query: (SELECT geometry, class, subclass, properties::text FROM layer_railway(!bbox!, z(!scale_denominator!))) AS t -schema: - - ./types.sql - - ./railway.sql -datasources: - - type: imposm3 - mapping_file: ./mapping.yaml diff --git a/layers/railway/types.sql b/layers/railway/types.sql deleted file mode 100644 index e323edde..00000000 --- a/layers/railway/types.sql +++ /dev/null @@ -1,15 +0,0 @@ -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'railway_properties') THEN - CREATE TYPE railway_properties AS ENUM ('bridge', 'tunnel'); - END IF; -END -$$; - -CREATE OR REPLACE FUNCTION to_railway_properties(is_bridge boolean, is_tunnel boolean) RETURNS railway_properties AS $$ - SELECT CASE - WHEN is_bridge THEN 'bridge'::railway_properties - WHEN is_tunnel THEN 'tunnel'::railway_properties - ELSE NULL - END; -$$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/highway/README.md b/layers/transportation/README.md similarity index 100% rename from layers/highway/README.md rename to layers/transportation/README.md diff --git a/layers/highway/highway.sql b/layers/transportation/highway.sql similarity index 63% rename from layers/highway/highway.sql rename to layers/transportation/highway.sql index 09bf9019..fa10c6ae 100644 --- a/layers/highway/highway.sql +++ b/layers/transportation/highway.sql @@ -1,13 +1,11 @@ - - CREATE OR REPLACE FUNCTION highway_is_link(highway TEXT) RETURNS BOOLEAN AS $$ SELECT highway LIKE '%_link'; $$ LANGUAGE SQL IMMUTABLE STRICT; --- etldoc: layer_highway[shape=record fillcolor=lightpink, style="rounded,filled", --- etldoc: label=" layer_highway | z4-z7 | z8 | z9 | z10 | z11 | z12| z13| z14_" ] ; -CREATE OR REPLACE FUNCTION layer_highway(bbox geometry, zoom_level int) +-- etldoc: layer_transportation[shape=record fillcolor=lightpink, style="rounded,filled", +-- etldoc: label=" layer_transportation | z4-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 highway_class, subclass text, properties highway_properties) AS $$ SELECT osm_id, geometry, @@ -15,8 +13,8 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass te to_highway_properties(is_bridge, is_tunnel, is_ford, is_ramp, is_oneway) AS properties FROM ( - -- etldoc: ne_10m_global_roads -> layer_highway:z4z7 - SELECT + -- etldoc: ne_10m_global_roads -> layer_transportation:z4z7 + SELECT NULL::bigint AS osm_id, geometry, highway, FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, 0 AS z_order @@ -24,59 +22,59 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass te WHERE zoom_level BETWEEN 4 AND 7 AND scalerank <= 1 + zoom_level UNION ALL - -- etldoc: osm_highway_linestring_gen4 -> layer_highway:z8 + -- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z8 SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_highway_linestring_gen4 + FROM osm_transportation_linestring_gen4 WHERE zoom_level = 8 UNION ALL - -- etldoc: osm_highway_linestring_gen3 -> layer_highway:z9 + -- etldoc: osm_transportation_linestring_gen3 -> layer_transportation:z9 SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_highway_linestring_gen3 + FROM osm_transportation_linestring_gen3 WHERE zoom_level = 9 UNION ALL - -- etldoc: osm_highway_linestring_gen2 -> layer_highway:z10 + -- etldoc: osm_transportation_linestring_gen2 -> layer_transportation:z10 SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_highway_linestring_gen2 + FROM osm_transportation_linestring_gen2 WHERE zoom_level = 10 UNION ALL - -- etldoc: osm_highway_linestring_gen1 -> layer_highway:z11 + -- etldoc: osm_transportation_linestring_gen1 -> layer_transportation:z11 SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_highway_linestring_gen1 + FROM osm_transportation_linestring_gen1 WHERE zoom_level = 11 UNION ALL - -- etldoc: osm_highway_linestring -> layer_highway:z12 + -- etldoc: osm_transportation_linestring -> layer_transportation:z12 SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_highway_linestring + FROM osm_transportation_linestring WHERE zoom_level = 12 AND (to_highway_class(highway) < 'minor_road'::highway_class OR highway IN ('unclassified', 'residential')) AND NOT highway_is_link(highway) AND NOT is_area UNION ALL - -- etldoc: osm_highway_linestring -> layer_highway:z13 + -- etldoc: osm_transportation_linestring -> layer_transportation:z13 SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_highway_linestring + FROM osm_transportation_linestring WHERE zoom_level = 13 AND to_highway_class(highway) < 'path'::highway_class AND NOT is_area UNION ALL - -- etldoc: osm_highway_linestring -> layer_highway:z14_ + -- etldoc: osm_transportation_linestring -> layer_transportation:z14_ SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_highway_linestring + FROM osm_transportation_linestring WHERE zoom_level >= 14 AND NOT is_area UNION ALL -- NOTE: We limit the selection of polys because we need to be careful to net get false positives here because -- it is possible that closed linestrings appear both as highway linestrings and as polygon - -- etldoc: osm_highway_polygon -> layer_highway:z13 - -- etldoc: osm_highway_polygon -> layer_highway:z14_ + -- etldoc: osm_transportation__polygon -> layer_transportation:z13 + -- etldoc: osm_transportation__polygon -> layer_transportation:z14_ SELECT osm_id, geometry, highway, FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, z_order - FROM osm_highway_polygon + FROM osm_transportation_polygon -- We do not want underground pedestrian areas for now WHERE zoom_level >= 13 AND is_area AND COALESCE(layer, 0) >= 0 ) AS zoom_levels diff --git a/layers/transportation/mapping b/layers/transportation/mapping new file mode 100644 index 00000000..b5a74703 --- /dev/null +++ b/layers/transportation/mapping @@ -0,0 +1,39 @@ +digraph "Imposm Mapping" { + graph [rankdir=LR ranksep=3] + subgraph highway_polygon { + node [fixed_size=shape "width:"=20] + highway_polygon [shape=box] + key_highway [label=highway shape=box] + key_highway -> highway_polygon [label=pedestrian] + } + subgraph highway_linestring { + node [fixed_size=shape "width:"=20] + highway_linestring [shape=box] + key_highway [label=highway shape=box] + key_highway -> highway_linestring [label="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"] + } +} \ No newline at end of file diff --git a/layers/highway/mapping.png b/layers/transportation/mapping.png similarity index 100% rename from layers/highway/mapping.png rename to layers/transportation/mapping.png diff --git a/layers/highway/mapping.yaml b/layers/transportation/mapping.yaml similarity index 66% rename from layers/highway/mapping.yaml rename to layers/transportation/mapping.yaml index cbd8fedc..3ba3da0b 100644 --- a/layers/highway/mapping.yaml +++ b/layers/transportation/mapping.yaml @@ -1,33 +1,33 @@ generalized_tables: -# etldoc: imposm3 -> osm_highway_linestring_gen4 - highway_linestring_gen4: - source: highway_linestring_gen3 +# etldoc: imposm3 -> osm_transportation_linestring_gen4 + transportation_linestring_gen4: + source: transportation_linestring_gen3 sql_filter: highway IN ('motorway','trunk') AND NOT is_area tolerance: 200.0 -# etldoc: imposm3 -> osm_highway_linestring_gen3 - highway_linestring_gen3: - source: highway_linestring_gen2 +# etldoc: imposm3 -> osm_transportation_linestring_gen3 + transportation_linestring_gen3: + source: transportation_linestring_gen2 sql_filter: highway IN ('motorway','trunk', 'primary') AND NOT is_area tolerance: 120.0 -# etldoc: imposm3 -> osm_highway_linestring_gen2 - highway_linestring_gen2: - source: highway_linestring_gen1 +# etldoc: imposm3 -> osm_transportation_linestring_gen2 + transportation_linestring_gen2: + source: transportation_linestring_gen1 sql_filter: highway IN ('motorway','trunk', 'primary', 'secondary') AND NOT is_area tolerance: 50.0 -# etldoc: imposm3 -> osm_highway_linestring_gen1 - highway_linestring_gen1: - source: highway_linestring +# etldoc: imposm3 -> osm_transportation_linestring_gen1 + transportation_linestring_gen1: + source: transportation_linestring sql_filter: highway IN ('motorway','trunk', 'primary', 'secondary', 'tertiary') AND NOT is_area tolerance: 20.0 tables: -# etldoc: imposm3 -> osm_highway_linestring - highway_linestring: +# etldoc: imposm3 -> osm_transportation_linestring + transportation_linestring: type: linestring fields: - name: osm_id @@ -37,6 +37,9 @@ tables: - name: highway key: highway type: string + - key: railway + name: railway + type: string - key: ref name: ref type: string @@ -63,12 +66,21 @@ tables: - key: name name: name type: string + - key: short_name + name: short_name + type: string - name: name_en key: name:en type: string - name: is_area key: area type: bool + - key: service + name: service + type: string + - key: usage + name: usage + type: string mapping: highway: - motorway @@ -96,9 +108,16 @@ tables: - corridor - crossing - pedestrian + railway: + - rail + - light_rail + - subway + - narrow_gauge + - preserved + - tram -# etldoc: imposm3 -> osm_highway_polygon - highway_polygon: +# etldoc: imposm3 -> osm_transportation_polygon + transportation_polygon: type: polygon fields: - name: osm_id diff --git a/layers/highway/ne_global_roads.sql b/layers/transportation/ne_global_roads.sql similarity index 100% rename from layers/highway/ne_global_roads.sql rename to layers/transportation/ne_global_roads.sql diff --git a/layers/highway/highway.yaml b/layers/transportation/transportation.yaml similarity index 96% rename from layers/highway/highway.yaml rename to layers/transportation/transportation.yaml index f028095e..3d530672 100644 --- a/layers/highway/highway.yaml +++ b/layers/transportation/transportation.yaml @@ -1,5 +1,5 @@ layer: - id: "highway" + id: "transportation" description: | Roads or [`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) in OpenStreetMap lingo. This layer is directly derived from the OSM road hierarchy which is why it is called `highway`. Only @@ -29,7 +29,7 @@ layer: datasource: geometry_field: geometry srid: 900913 - query: (SELECT geometry, class::text, subclass, properties::text FROM layer_highway(!bbox!, z(!scale_denominator!))) AS t + query: (SELECT geometry, class::text, subclass, properties::text FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t schema: - ./types.sql - ./ne_global_roads.sql diff --git a/layers/highway/types.sql b/layers/transportation/types.sql similarity index 100% rename from layers/highway/types.sql rename to layers/transportation/types.sql diff --git a/layers/highway_name/README.md b/layers/transportation_name/README.md similarity index 100% rename from layers/highway_name/README.md rename to layers/transportation_name/README.md diff --git a/layers/transportation_name/layer.sql b/layers/transportation_name/layer.sql new file mode 100644 index 00000000..6f62a9ce --- /dev/null +++ b/layers/transportation_name/layer.sql @@ -0,0 +1,50 @@ + +-- etldoc: layer_transportation_name[shape=record fillcolor=lightpink, style="rounded,filled", +-- 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, class highway_class, subclass text) AS $$ + SELECT osm_id, geometry, name, + NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length, + to_highway_class(highway) AS class, highway AS subclass + FROM ( + + -- etldoc: osm_transportation_name_linestring_gen3 -> layer_transportation_name:z8 + SELECT * FROM osm_transportation_name_linestring_gen3 + WHERE zoom_level = 8 + UNION ALL + + -- etldoc: osm_transportation_name_linestring_gen2 -> layer_transportation_name:z9 + SELECT * FROM osm_transportation_name_linestring_gen2 + WHERE zoom_level = 9 + UNION ALL + + -- etldoc: osm_transportation_name_linestring_gen1 -> layer_transportation_name:z10 + -- etldoc: osm_transportation_name_linestring_gen1 -> layer_transportation_name:z11 + SELECT * FROM osm_transportation_name_linestring_gen1 + WHERE zoom_level BETWEEN 10 AND 11 + UNION ALL + + -- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z12 + SELECT * FROM osm_transportation_name_linestring + WHERE zoom_level = 12 + AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) + AND to_highway_class(highway) < 'minor_road'::highway_class + AND NOT highway_is_link(highway) + UNION ALL + + -- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z13 + SELECT * FROM osm_transportation_name_linestring + WHERE zoom_level = 13 + AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) + AND to_highway_class(highway) < 'path'::highway_class + UNION ALL + + -- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z14_ + SELECT * FROM osm_transportation_name_linestring + WHERE zoom_level >= 14 + + ) AS zoom_levels + WHERE geometry && bbox + ORDER BY z_order ASC; +$$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/transportation_name/merge_highways.sql b/layers/transportation_name/merge_highways.sql new file mode 100644 index 00000000..f6811633 --- /dev/null +++ b/layers/transportation_name/merge_highways.sql @@ -0,0 +1,57 @@ +-- Instead of using relations to find out the road names we +-- stitch together the touching ways with the same name +-- to allow for nice label rendering +-- Because this works well for roads that do not have relations as well + +-- etldoc: osm_transportation_linestring -> osm_transportation_name_linestring +CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring AS ( + SELECT + (ST_Dump(geometry)).geom AS geometry, + -- NOTE: The osm_id is no longer the original one which can make it difficult + -- to lookup road names by OSM ID + member_osm_ids[0] AS osm_id, + member_osm_ids, + name, + ref, + highway, + z_order + FROM ( + SELECT + ST_LineMerge(ST_Union(geometry)) AS geometry, + name, + ref, + highway, + min(z_order) AS z_order, + array_agg(DISTINCT osm_id) AS member_osm_ids + FROM osm_transportation_linestring + -- We only care about highways (not railways) for labeling + WHERE (name <> '' OR ref <> '') AND NULLIF(highway, '') IS NOT NULL + GROUP BY name, highway, ref + ) AS highway_union +); + +CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_geometry_idx ON osm_transportation_name_linestring USING gist(geometry); + +-- etldoc: osm_transportation_name_linestring -> osm_transportation_name_linestring_gen1 +CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen1 AS ( + SELECT ST_Simplify(geometry, 50) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order + FROM osm_transportation_name_linestring + WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 8000 +); +CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen1_geometry_idx ON osm_transportation_name_linestring_gen1 USING gist(geometry); + +-- etldoc: osm_transportation_name_linestring_gen1 -> osm_transportation_name_linestring_gen2 +CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen2 AS ( + SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order + FROM osm_transportation_name_linestring_gen1 + WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 14000 +); +CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen2_geometry_idx ON osm_transportation_name_linestring_gen2 USING gist(geometry); + +-- etldoc: osm_transportation_name_linestring_gen2 -> osm_transportation_name_linestring_gen3 +CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen3 AS ( + SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, member_osm_ids, name, ref, highway, z_order + FROM osm_transportation_name_linestring_gen2 + WHERE highway = 'motorway' AND ST_Length(geometry) > 20000 +); +CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_gen3_geometry_idx ON osm_transportation_name_linestring_gen3 USING gist(geometry); diff --git a/layers/highway_name/highway_name.yaml b/layers/transportation_name/transportation_name.yaml similarity index 90% rename from layers/highway_name/highway_name.yaml rename to layers/transportation_name/transportation_name.yaml index 69751b36..27e55bf3 100644 --- a/layers/highway_name/highway_name.yaml +++ b/layers/transportation_name/transportation_name.yaml @@ -1,5 +1,5 @@ layer: - id: "highway_name" + id: "transportation_name" description: | This is the layer for labelling the highways. Only highways that are named `name=*` and are long enough to place text upon appear. The OSM roads are stitched together if they contain the same name @@ -20,10 +20,10 @@ layer: datasource: geometry_field: geometry srid: 900913 - query: (SELECT geometry, name, ref, ref_length, class::text, subclass FROM layer_highway_name(!bbox!, z(!scale_denominator!))) AS t + query: (SELECT geometry, name, ref, ref_length, class::text, subclass FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t schema: - ./merge_highways.sql - ./layer.sql datasources: - type: imposm3 - mapping_file: ../highway/mapping.yaml + mapping_file: ../transportation/mapping.yaml diff --git a/openmaptiles.yaml b/openmaptiles.yaml index 0ab01265..2013d404 100644 --- a/openmaptiles.yaml +++ b/openmaptiles.yaml @@ -1,13 +1,12 @@ tileset: layers: - layers/boundary/boundary.yaml - - layers/highway/highway.yaml - - layers/highway_name/highway_name.yaml + - layers/transportation/transportation.yaml + - layers/transportation_name/transportation_name.yaml - layers/building/building.yaml - layers/housenumber/housenumber.yaml - layers/place/place.yaml - layers/poi/poi.yaml - - layers/railway/railway.yaml - layers/water_name/water_name.yaml - layers/water/water.yaml - layers/waterway/waterway.yaml From 453d64ba1738244c9abd99956d911e7099f67bae Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Sat, 26 Nov 2016 20:25:25 +0000 Subject: [PATCH 02/21] Show OSM highways earlier --- layers/transportation/highway.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layers/transportation/highway.sql b/layers/transportation/highway.sql index fa10c6ae..a95fbf33 100644 --- a/layers/transportation/highway.sql +++ b/layers/transportation/highway.sql @@ -19,13 +19,13 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass te FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, 0 AS z_order FROM ne_10m_global_roads - WHERE zoom_level BETWEEN 4 AND 7 AND scalerank <= 1 + zoom_level + WHERE zoom_level BETWEEN 4 AND 6 AND scalerank <= 1 + zoom_level UNION ALL -- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z8 SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen4 - WHERE zoom_level = 8 + WHERE zoom_level BETWEEN 7 AND 8 UNION ALL -- etldoc: osm_transportation_linestring_gen3 -> layer_transportation:z9 From 69b77416be91d44629599bff083a5e2d6667a7d6 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Sat, 26 Nov 2016 20:46:19 +0000 Subject: [PATCH 03/21] Add ramp, oneway, brunnel to transportation --- layers/transportation/highway.sql | 10 ++++---- layers/transportation/transportation.yaml | 2 +- layers/transportation/types.sql | 28 +++++++---------------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/layers/transportation/highway.sql b/layers/transportation/highway.sql index a95fbf33..cd8b8bda 100644 --- a/layers/transportation/highway.sql +++ b/layers/transportation/highway.sql @@ -6,14 +6,16 @@ $$ LANGUAGE SQL IMMUTABLE STRICT; -- etldoc: layer_transportation[shape=record fillcolor=lightpink, style="rounded,filled", -- etldoc: label=" layer_transportation | z4-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 highway_class, subclass text, properties highway_properties) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass text, ramp int, oneway int, brunnel TEXT) AS $$ SELECT osm_id, geometry, to_highway_class(highway) AS class, highway AS subclass, - to_highway_properties(is_bridge, is_tunnel, is_ford, is_ramp, is_oneway) AS properties + CASE WHEN highway_is_link(highway) THEN 1 ELSE is_ramp::int END AS ramp, + is_oneway::int AS oneway, + to_brunnel(is_bridge, is_tunnel, is_ford) AS brunnel FROM ( - -- etldoc: ne_10m_global_roads -> layer_transportation:z4z7 + -- etldoc: ne_10m_global_roads -> layer_transportation:z4z6 SELECT NULL::bigint AS osm_id, geometry, highway, FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, @@ -22,7 +24,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass te WHERE zoom_level BETWEEN 4 AND 6 AND scalerank <= 1 + zoom_level UNION ALL - -- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z8 + -- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z7z8 SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen4 WHERE zoom_level BETWEEN 7 AND 8 diff --git a/layers/transportation/transportation.yaml b/layers/transportation/transportation.yaml index 3d530672..0d189e47 100644 --- a/layers/transportation/transportation.yaml +++ b/layers/transportation/transportation.yaml @@ -29,7 +29,7 @@ layer: datasource: geometry_field: geometry srid: 900913 - query: (SELECT geometry, class::text, subclass, properties::text FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t + query: (SELECT geometry, class::text, subclass, oneway, ramp, brunnel FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t schema: - ./types.sql - ./ne_global_roads.sql diff --git a/layers/transportation/types.sql b/layers/transportation/types.sql index 10e6c6bf..e9560bcf 100644 --- a/layers/transportation/types.sql +++ b/layers/transportation/types.sql @@ -8,13 +8,14 @@ BEGIN END $$; -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'highway_properties') THEN - CREATE TYPE highway_properties AS ENUM ('bridge:oneway', 'tunnel:oneway', 'ramp', 'ford', 'bridge', 'tunnel', 'oneway'); - END IF; -END -$$; +CREATE OR REPLACE FUNCTION to_brunnel(is_bridge BOOL, is_tunnel BOOL, is_ford BOOL) RETURNS TEXT AS $$ + SELECT CASE + WHEN is_bridge THEN 'bridge' + WHEN is_tunnel THEN 'tunnel' + WHEN is_ford THEN 'ford' + ELSE NULL + END; +$$ LANGUAGE SQL IMMUTABLE STRICT; CREATE OR REPLACE FUNCTION to_highway_class(highway TEXT) RETURNS highway_class AS $$ SELECT CASE @@ -29,16 +30,3 @@ CREATE OR REPLACE FUNCTION to_highway_class(highway TEXT) RETURNS highway_class ELSE NULL END; $$ LANGUAGE SQL IMMUTABLE STRICT; - -CREATE OR REPLACE FUNCTION to_highway_properties(is_bridge boolean, is_tunnel boolean, is_ford boolean, is_ramp boolean, is_oneway boolean) RETURNS highway_properties AS $$ - SELECT CASE - WHEN is_bridge AND is_oneway THEN 'bridge:oneway'::highway_properties - WHEN is_tunnel AND is_oneway THEN 'tunnel:oneway'::highway_properties - WHEN is_ramp THEN 'ramp'::highway_properties - WHEN is_ford THEN 'ford'::highway_properties - WHEN is_bridge THEN 'bridge'::highway_properties - WHEN is_tunnel THEN 'tunnel'::highway_properties - WHEN is_oneway THEN 'oneway'::highway_properties - ELSE NULL - END; -$$ LANGUAGE SQL IMMUTABLE; From 24b1e763faf0835005d954aa6de04a1442f211b9 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Sat, 26 Nov 2016 20:47:42 +0000 Subject: [PATCH 04/21] Rename highway to layer --- layers/transportation/{highway.sql => layer.sql} | 0 layers/transportation/transportation.yaml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename layers/transportation/{highway.sql => layer.sql} (100%) diff --git a/layers/transportation/highway.sql b/layers/transportation/layer.sql similarity index 100% rename from layers/transportation/highway.sql rename to layers/transportation/layer.sql diff --git a/layers/transportation/transportation.yaml b/layers/transportation/transportation.yaml index 0d189e47..05d96e2a 100644 --- a/layers/transportation/transportation.yaml +++ b/layers/transportation/transportation.yaml @@ -33,7 +33,7 @@ layer: schema: - ./types.sql - ./ne_global_roads.sql - - ./highway.sql + - ./layer.sql datasources: - type: imposm3 mapping_file: ./mapping.yaml From e9f4c31e0a9364986d6ff0299544b449ffcd57e5 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Sat, 26 Nov 2016 21:08:30 +0000 Subject: [PATCH 05/21] Return railways in transportation --- layers/transportation/layer.sql | 30 +++++++++++++---------- layers/transportation/transportation.yaml | 2 +- layers/transportation/types.sql | 27 +++++++++----------- layers/transportation_name/layer.sql | 6 ++--- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index cd8b8bda..43143955 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -6,10 +6,14 @@ $$ LANGUAGE SQL IMMUTABLE STRICT; -- etldoc: layer_transportation[shape=record fillcolor=lightpink, style="rounded,filled", -- etldoc: label=" layer_transportation | z4-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 highway_class, subclass text, ramp int, oneway int, brunnel TEXT) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp int, oneway int, brunnel TEXT) AS $$ SELECT osm_id, geometry, - to_highway_class(highway) AS class, highway AS subclass, + CASE + WHEN highway <> '' THEN to_highway_class(highway) + WHEN railway <> '' THEN railway_class(railway, service) + END AS class, + COALESCE(NULLIF(highway,''), NULLIF(railway, '')) AS subclass, CASE WHEN highway_is_link(highway) THEN 1 ELSE is_ramp::int END AS ramp, is_oneway::int AS oneway, to_brunnel(is_bridge, is_tunnel, is_ford) AS brunnel @@ -17,7 +21,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass te -- etldoc: ne_10m_global_roads -> layer_transportation:z4z6 SELECT - NULL::bigint AS osm_id, geometry, highway, + NULL::bigint AS osm_id, geometry, highway, NULL AS railway, NULL AS service, FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, 0 AS z_order FROM ne_10m_global_roads @@ -25,48 +29,48 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass te UNION ALL -- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z7z8 - SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen4 WHERE zoom_level BETWEEN 7 AND 8 UNION ALL -- etldoc: osm_transportation_linestring_gen3 -> layer_transportation:z9 - SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen3 WHERE zoom_level = 9 UNION ALL -- etldoc: osm_transportation_linestring_gen2 -> layer_transportation:z10 - SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen2 WHERE zoom_level = 10 UNION ALL -- etldoc: osm_transportation_linestring_gen1 -> layer_transportation:z11 - SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen1 WHERE zoom_level = 11 UNION ALL -- etldoc: osm_transportation_linestring -> layer_transportation:z12 - SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring WHERE zoom_level = 12 - AND (to_highway_class(highway) < 'minor_road'::highway_class OR highway IN ('unclassified', 'residential')) + AND (to_highway_class(highway) NOT IN ('minor_road', 'path') OR highway IN ('unclassified', 'residential')) AND NOT highway_is_link(highway) AND NOT is_area UNION ALL -- etldoc: osm_transportation_linestring -> layer_transportation:z13 - SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring WHERE zoom_level = 13 - AND to_highway_class(highway) < 'path'::highway_class + AND to_highway_class(highway) <> 'path' AND NOT is_area UNION ALL -- etldoc: osm_transportation_linestring -> layer_transportation:z14_ - SELECT osm_id, geometry, highway, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring WHERE zoom_level >= 14 AND NOT is_area UNION ALL @@ -75,7 +79,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class highway_class, subclass te -- it is possible that closed linestrings appear both as highway linestrings and as polygon -- etldoc: osm_transportation__polygon -> layer_transportation:z13 -- etldoc: osm_transportation__polygon -> layer_transportation:z14_ - SELECT osm_id, geometry, highway, FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, z_order + SELECT osm_id, geometry, highway, NULL AS railway, NULL AS service, FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, z_order FROM osm_transportation_polygon -- We do not want underground pedestrian areas for now WHERE zoom_level >= 13 AND is_area AND COALESCE(layer, 0) >= 0 diff --git a/layers/transportation/transportation.yaml b/layers/transportation/transportation.yaml index 05d96e2a..a309d878 100644 --- a/layers/transportation/transportation.yaml +++ b/layers/transportation/transportation.yaml @@ -29,7 +29,7 @@ layer: datasource: geometry_field: geometry srid: 900913 - query: (SELECT geometry, class::text, subclass, oneway, ramp, brunnel FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t + query: (SELECT geometry, class, subclass, oneway, ramp, brunnel FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t schema: - ./types.sql - ./ne_global_roads.sql diff --git a/layers/transportation/types.sql b/layers/transportation/types.sql index e9560bcf..fc1d75b2 100644 --- a/layers/transportation/types.sql +++ b/layers/transportation/types.sql @@ -1,13 +1,3 @@ - - -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'highway_class') THEN - CREATE TYPE highway_class AS ENUM ('motorway', 'major_road', 'minor_road', 'path'); - END IF; -END -$$; - CREATE OR REPLACE FUNCTION to_brunnel(is_bridge BOOL, is_tunnel BOOL, is_ford BOOL) RETURNS TEXT AS $$ SELECT CASE WHEN is_bridge THEN 'bridge' @@ -17,16 +7,23 @@ CREATE OR REPLACE FUNCTION to_brunnel(is_bridge BOOL, is_tunnel BOOL, is_ford BO END; $$ LANGUAGE SQL IMMUTABLE STRICT; -CREATE OR REPLACE FUNCTION to_highway_class(highway TEXT) RETURNS highway_class AS $$ +CREATE OR REPLACE FUNCTION to_highway_class(highway TEXT) RETURNS TEXT AS $$ SELECT CASE - WHEN highway IN ('motorway', 'motorway_link') THEN 'motorway'::highway_class + WHEN highway IN ('motorway', 'motorway_link') THEN 'motorway' -- A major class is helpful in styling - one can still differentiate on a finer level using the subclass WHEN highway IN ('trunk', 'trunk_link', 'primary', 'primary_link', 'secondary', 'secondary_link', - 'tertiary', 'tertiary_link') THEN 'major_road'::highway_class - WHEN highway IN ('unclassified', 'residential', 'living_street', 'road', 'track', 'service') THEN 'minor_road'::highway_class - WHEN highway IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps') THEN 'path'::highway_class + 'tertiary', 'tertiary_link') THEN 'major_road' + WHEN highway IN ('unclassified', 'residential', 'living_street', 'road', 'track', 'service') THEN 'minor_road' + WHEN highway IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps') THEN 'path' ELSE NULL END; $$ LANGUAGE SQL IMMUTABLE STRICT; + +CREATE OR REPLACE FUNCTION railway_class(railway text, service text) RETURNS TEXT AS $$ + SELECT CASE + WHEN railway='rail' AND service='' THEN 'rail' + ELSE 'minor_rail' + END; +$$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/transportation_name/layer.sql b/layers/transportation_name/layer.sql index 6f62a9ce..0e435bc7 100644 --- a/layers/transportation_name/layer.sql +++ b/layers/transportation_name/layer.sql @@ -3,7 +3,7 @@ -- 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, class highway_class, subclass text) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length int, class text, subclass text) AS $$ SELECT osm_id, geometry, name, NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length, to_highway_class(highway) AS class, highway AS subclass @@ -29,7 +29,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length SELECT * FROM osm_transportation_name_linestring WHERE zoom_level = 12 AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) - AND to_highway_class(highway) < 'minor_road'::highway_class + AND to_highway_class(highway) NOT IN ('minor_road', 'path') AND NOT highway_is_link(highway) UNION ALL @@ -37,7 +37,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length SELECT * FROM osm_transportation_name_linestring WHERE zoom_level = 13 AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) - AND to_highway_class(highway) < 'path'::highway_class + AND to_highway_class(highway) <> 'path' UNION ALL -- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z14_ From 65419bdb84c61119dc45eedd60e0cb4d5d1fcf8f Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Sat, 26 Nov 2016 21:11:43 +0000 Subject: [PATCH 06/21] Use service field on different zoom levels --- layers/transportation/layer.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index 43143955..2d400c64 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -29,31 +29,31 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp UNION ALL -- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z7z8 - SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen4 WHERE zoom_level BETWEEN 7 AND 8 UNION ALL -- etldoc: osm_transportation_linestring_gen3 -> layer_transportation:z9 - SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen3 WHERE zoom_level = 9 UNION ALL -- etldoc: osm_transportation_linestring_gen2 -> layer_transportation:z10 - SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen2 WHERE zoom_level = 10 UNION ALL -- etldoc: osm_transportation_linestring_gen1 -> layer_transportation:z11 - SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen1 WHERE zoom_level = 11 UNION ALL -- etldoc: osm_transportation_linestring -> layer_transportation:z12 - SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring WHERE zoom_level = 12 AND (to_highway_class(highway) NOT IN ('minor_road', 'path') OR highway IN ('unclassified', 'residential')) @@ -62,15 +62,15 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp UNION ALL -- etldoc: osm_transportation_linestring -> layer_transportation:z13 - SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring WHERE zoom_level = 13 - AND to_highway_class(highway) <> 'path' + AND (to_highway_class(highway) <> 'path' OR railway_class(railway, service) = 'rail') AND NOT is_area UNION ALL -- etldoc: osm_transportation_linestring -> layer_transportation:z14_ - SELECT osm_id, geometry, highway, railway, NULL AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring WHERE zoom_level >= 14 AND NOT is_area UNION ALL From a04d5776e639975d6e99a4bdfb4a3496ecf9fdeb Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 28 Nov 2016 10:29:00 +0000 Subject: [PATCH 07/21] Use ClearTables scheme for classes --- layers/transportation/class.sql | 34 +++++++ layers/transportation/layer.sql | 117 +++++++++++++--------- layers/transportation/transportation.yaml | 2 +- layers/transportation/types.sql | 29 ------ 4 files changed, 105 insertions(+), 77 deletions(-) create mode 100644 layers/transportation/class.sql delete mode 100644 layers/transportation/types.sql diff --git a/layers/transportation/class.sql b/layers/transportation/class.sql new file mode 100644 index 00000000..6e4e7e15 --- /dev/null +++ b/layers/transportation/class.sql @@ -0,0 +1,34 @@ +CREATE OR REPLACE FUNCTION brunnel(is_bridge BOOL, is_tunnel BOOL, is_ford BOOL) RETURNS TEXT AS $$ + SELECT CASE + WHEN is_bridge THEN 'bridge' + WHEN is_tunnel THEN 'tunnel' + WHEN is_ford THEN 'ford' + ELSE NULL + END; +$$ LANGUAGE SQL IMMUTABLE STRICT; + +-- The classes for highways are derived from the classes used in ClearTables +-- https://github.com/ClearTables/ClearTables/blob/master/transportation.lua +CREATE OR REPLACE FUNCTION highway_class(highway TEXT) RETURNS TEXT AS $$ + SELECT CASE + WHEN highway IN ('motorway', 'motorway_link') THEN 'motorway' + WHEN highway IN ('trunk', 'trunk_link') THEN 'trunk' + WHEN highway IN ('primary', 'primary_link') THEN 'primary' + WHEN highway IN ('secondary', 'secondary_link') THEN 'secondary' + WHEN highway IN ('tertiary', 'tertiary_link') THEN 'tertiary' + WHEN highway IN ('unclassified', 'residential', 'living_street', 'road') THEN 'minor' + WHEN highway IN ('service', 'track') THEN highway + WHEN highway IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps') THEN 'path' + ELSE NULL + END; +$$ LANGUAGE SQL IMMUTABLE STRICT; + +-- The classes for railways are derived from the classes used in ClearTables +-- https://github.com/ClearTables/ClearTables/blob/master/transportation.lua +CREATE OR REPLACE FUNCTION railway_class(railway TEXT) RETURNS TEXT AS $$ + SELECT CASE + WHEN railway IN ('rail', 'narrow_gauge', 'preserved', 'funicular') THEN 'rail' + WHEN railway IN ('subway', 'light_rail', 'monorail', 'tram') THEN 'transit' + ELSE NULL + END; +$$ LANGUAGE SQL IMMUTABLE STRICT; diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index 2d400c64..7168118f 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -8,81 +8,104 @@ $$ LANGUAGE SQL IMMUTABLE STRICT; 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) AS $$ SELECT - osm_id, geometry, - CASE - WHEN highway <> '' THEN to_highway_class(highway) - WHEN railway <> '' THEN railway_class(railway, service) + osm_id, geometry, + CASE + WHEN highway <> '' THEN highway_class(highway) + WHEN railway <> '' 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) THEN 1 ELSE is_ramp::int END AS ramp, is_oneway::int AS oneway, - to_brunnel(is_bridge, is_tunnel, is_ford) AS brunnel - FROM ( + brunnel(is_bridge, is_tunnel, is_ford) AS brunnel + FROM ( + -- etldoc: ne_10m_global_roads -> layer_transportation:z4z6 + SELECT + NULL::bigint AS osm_id, geometry, + highway, NULL AS railway, NULL AS service, + FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, + FALSE AS is_ramp, FALSE AS is_oneway, + 0 AS z_order + FROM ne_10m_global_roads + WHERE zoom_level BETWEEN 4 AND 6 AND scalerank <= 1 + zoom_level + UNION ALL - -- etldoc: ne_10m_global_roads -> layer_transportation:z4z6 - SELECT - NULL::bigint AS osm_id, geometry, highway, NULL AS railway, NULL AS service, - FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, - 0 AS z_order - FROM ne_10m_global_roads - WHERE zoom_level BETWEEN 4 AND 6 AND scalerank <= 1 + zoom_level - UNION ALL - - -- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z7z8 - SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + -- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z7z8 + SELECT + osm_id, geometry, highway, railway, service, + is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen4 - WHERE zoom_level BETWEEN 7 AND 8 - UNION ALL + WHERE zoom_level BETWEEN 7 AND 8 + UNION ALL - -- etldoc: osm_transportation_linestring_gen3 -> layer_transportation:z9 - SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + -- etldoc: osm_transportation_linestring_gen3 -> layer_transportation:z9 + SELECT + osm_id, geometry, highway, railway, service, + is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen3 - WHERE zoom_level = 9 - UNION ALL + WHERE zoom_level = 9 + UNION ALL - -- etldoc: osm_transportation_linestring_gen2 -> layer_transportation:z10 - SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + -- etldoc: osm_transportation_linestring_gen2 -> layer_transportation:z10 + SELECT + osm_id, geometry, highway, railway, service, + is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen2 - WHERE zoom_level = 10 - UNION ALL + WHERE zoom_level = 10 + UNION ALL - -- etldoc: osm_transportation_linestring_gen1 -> layer_transportation:z11 - SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + -- etldoc: osm_transportation_linestring_gen1 -> layer_transportation:z11 + SELECT + osm_id, geometry, highway, railway, service, + is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring_gen1 - WHERE zoom_level = 11 - UNION ALL + WHERE zoom_level = 11 + UNION ALL - -- etldoc: osm_transportation_linestring -> layer_transportation:z12 - SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + -- etldoc: osm_transportation_linestring -> layer_transportation:z12 + SELECT + osm_id, geometry, highway, railway, service, + is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring - WHERE zoom_level = 12 - AND (to_highway_class(highway) NOT IN ('minor_road', 'path') OR highway IN ('unclassified', 'residential')) - AND NOT highway_is_link(highway) + WHERE zoom_level = 12 + AND ( + highway_class(highway) NOT IN ('track', 'path', 'minor') + OR highway IN ('unclassified', 'residential') + ) AND NOT is_area UNION ALL - -- etldoc: osm_transportation_linestring -> layer_transportation:z13 - SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + -- etldoc: osm_transportation_linestring -> layer_transportation:z13 + SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring - WHERE zoom_level = 13 - AND (to_highway_class(highway) <> 'path' OR railway_class(railway, service) = 'rail') + WHERE zoom_level = 13 + AND ( + highway_class(highway) NOT IN ('track', 'path') + OR (railway='rail' AND service = '') + ) AND NOT is_area UNION ALL - -- etldoc: osm_transportation_linestring -> layer_transportation:z14_ - SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + -- etldoc: osm_transportation_linestring -> layer_transportation:z14_ + SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_transportation_linestring - WHERE zoom_level >= 14 AND NOT is_area + WHERE zoom_level >= 14 AND NOT is_area UNION ALL - -- NOTE: We limit the selection of polys because we need to be careful to net get false positives here because - -- it is possible that closed linestrings appear both as highway linestrings and as polygon + -- NOTE: We limit the selection of polys because we need to be + -- careful to net get false positives here because + -- it is possible that closed linestrings appear both as + -- highway linestrings and as polygon -- etldoc: osm_transportation__polygon -> layer_transportation:z13 -- etldoc: osm_transportation__polygon -> layer_transportation:z14_ - SELECT osm_id, geometry, highway, NULL AS railway, NULL AS service, FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, z_order + SELECT + osm_id, geometry, + highway, NULL AS railway, NULL AS service, + FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, + FALSE AS is_ramp, FALSE AS is_oneway, z_order FROM osm_transportation_polygon -- We do not want underground pedestrian areas for now - WHERE zoom_level >= 13 AND is_area AND COALESCE(layer, 0) >= 0 + WHERE zoom_level >= 13 AND is_area AND COALESCE(layer, 0) >= 0 ) AS zoom_levels WHERE geometry && bbox ORDER BY z_order ASC; diff --git a/layers/transportation/transportation.yaml b/layers/transportation/transportation.yaml index a309d878..0542eada 100644 --- a/layers/transportation/transportation.yaml +++ b/layers/transportation/transportation.yaml @@ -31,7 +31,7 @@ layer: srid: 900913 query: (SELECT geometry, class, subclass, oneway, ramp, brunnel FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t schema: - - ./types.sql + - ./class.sql - ./ne_global_roads.sql - ./layer.sql datasources: diff --git a/layers/transportation/types.sql b/layers/transportation/types.sql deleted file mode 100644 index fc1d75b2..00000000 --- a/layers/transportation/types.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE OR REPLACE FUNCTION to_brunnel(is_bridge BOOL, is_tunnel BOOL, is_ford BOOL) RETURNS TEXT AS $$ - SELECT CASE - WHEN is_bridge THEN 'bridge' - WHEN is_tunnel THEN 'tunnel' - WHEN is_ford THEN 'ford' - ELSE NULL - END; -$$ LANGUAGE SQL IMMUTABLE STRICT; - -CREATE OR REPLACE FUNCTION to_highway_class(highway TEXT) RETURNS TEXT AS $$ - SELECT CASE - WHEN highway IN ('motorway', 'motorway_link') THEN 'motorway' - -- A major class is helpful in styling - one can still differentiate on a finer level using the subclass - WHEN highway IN ('trunk', 'trunk_link', - 'primary', 'primary_link', - 'secondary', 'secondary_link', - 'tertiary', 'tertiary_link') THEN 'major_road' - WHEN highway IN ('unclassified', 'residential', 'living_street', 'road', 'track', 'service') THEN 'minor_road' - WHEN highway IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps') THEN 'path' - ELSE NULL - END; -$$ LANGUAGE SQL IMMUTABLE STRICT; - -CREATE OR REPLACE FUNCTION railway_class(railway text, service text) RETURNS TEXT AS $$ - SELECT CASE - WHEN railway='rail' AND service='' THEN 'rail' - ELSE 'minor_rail' - END; -$$ LANGUAGE SQL IMMUTABLE; From de2f538ef505c0ab11cf3bc8dd056d037c0fea1a Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 28 Nov 2016 11:09:50 +0000 Subject: [PATCH 08/21] Use new classes in transport_name and add network --- layers/transportation_name/layer.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/layers/transportation_name/layer.sql b/layers/transportation_name/layer.sql index 0e435bc7..7afbcd81 100644 --- a/layers/transportation_name/layer.sql +++ b/layers/transportation_name/layer.sql @@ -3,10 +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, class text, subclass text) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length int, network text, class text, subclass text) AS $$ SELECT osm_id, geometry, name, NULLIF(ref, ''), NULLIF(LENGTH(ref), 0) AS ref_length, - to_highway_class(highway) AS class, highway AS subclass + --TODO: The road network of the road is not yet implemented + NULL::text AS network, + highway_class(highway) AS class, highway AS subclass FROM ( -- etldoc: osm_transportation_name_linestring_gen3 -> layer_transportation_name:z8 @@ -29,7 +31,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length SELECT * FROM osm_transportation_name_linestring WHERE zoom_level = 12 AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) - AND to_highway_class(highway) NOT IN ('minor_road', 'path') + AND highway_class(highway) NOT IN ('minor', 'track', 'path') AND NOT highway_is_link(highway) UNION ALL @@ -37,7 +39,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, ref text, ref_length SELECT * FROM osm_transportation_name_linestring WHERE zoom_level = 13 AND LineLabel(zoom_level, COALESCE(NULLIF(name, ''), ref), geometry) - AND to_highway_class(highway) <> 'path' + AND highway_class(highway) NOT IN ('track', 'path') UNION ALL -- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z14_ From 1d3171185ba1bb574418339b9c8c4e0e6f05caed Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 28 Nov 2016 12:50:04 +0000 Subject: [PATCH 09/21] Split railway and highway into different tables --- layers/transportation/layer.sql | 78 ++++----- layers/transportation/mapping.yaml | 204 +++++++++++++++------- layers/transportation/transportation.yaml | 2 +- 3 files changed, 181 insertions(+), 103 deletions(-) diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index 7168118f..03a6bde5 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -6,18 +6,19 @@ $$ LANGUAGE SQL IMMUTABLE STRICT; -- etldoc: layer_transportation[shape=record fillcolor=lightpink, style="rounded,filled", -- etldoc: label=" layer_transportation | z4-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) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp int, oneway int, brunnel TEXT, service TEXT) AS $$ SELECT osm_id, geometry, CASE - WHEN highway <> '' THEN highway_class(highway) - WHEN railway <> '' THEN railway_class(railway) + WHEN highway IS NULL THEN highway_class(highway) + WHEN railway IS 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) THEN 1 ELSE is_ramp::int END AS ramp, is_oneway::int AS oneway, - brunnel(is_bridge, is_tunnel, is_ford) AS brunnel + brunnel(is_bridge, is_tunnel, is_ford) AS brunnel, + NULLIF(service, '') AS service FROM ( -- etldoc: ne_10m_global_roads -> layer_transportation:z4z6 SELECT @@ -30,80 +31,77 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp WHERE zoom_level BETWEEN 4 AND 6 AND scalerank <= 1 + zoom_level UNION ALL - -- etldoc: osm_transportation_linestring_gen4 -> layer_transportation:z7z8 + -- etldoc: osm_highway_linestring_gen4 -> layer_transportation:z7z8 SELECT - osm_id, geometry, highway, railway, service, + osm_id, geometry, highway, NULL AS railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_transportation_linestring_gen4 + FROM osm_highway_linestring_gen4 WHERE zoom_level BETWEEN 7 AND 8 UNION ALL - -- etldoc: osm_transportation_linestring_gen3 -> layer_transportation:z9 + -- etldoc: osm_highway_linestring_gen3 -> layer_transportation:z9 SELECT - osm_id, geometry, highway, railway, service, + osm_id, geometry, highway, NULL AS railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_transportation_linestring_gen3 + FROM osm_highway_linestring_gen3 WHERE zoom_level = 9 UNION ALL - -- etldoc: osm_transportation_linestring_gen2 -> layer_transportation:z10 + -- etldoc: osm_highway_linestring_gen2 -> layer_transportation:z10 SELECT - osm_id, geometry, highway, railway, service, + osm_id, geometry, highway, NULL AS railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_transportation_linestring_gen2 + FROM osm_highway_linestring_gen2 WHERE zoom_level = 10 UNION ALL - -- etldoc: osm_transportation_linestring_gen1 -> layer_transportation:z11 + -- etldoc: osm_highway_linestring_gen1 -> layer_transportation:z11 SELECT - osm_id, geometry, highway, railway, service, + osm_id, geometry, highway, NULL AS railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_transportation_linestring_gen1 + FROM osm_highway_linestring_gen1 WHERE zoom_level = 11 UNION ALL - -- etldoc: osm_transportation_linestring -> layer_transportation:z12 + -- etldoc: osm_highway_linestring -> layer_transportation:z12 + -- etldoc: osm_highway_linestring -> layer_transportation:z13 + -- etldoc: osm_highway_linestring -> layer_transportation:z14_ SELECT - osm_id, geometry, highway, railway, service, + osm_id, geometry, highway, NULL AS railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_transportation_linestring - WHERE zoom_level = 12 - AND ( + FROM osm_highway_linestring + WHERE NOT is_area AND ( + zoom_level = 12 AND ( highway_class(highway) NOT IN ('track', 'path', 'minor') OR highway IN ('unclassified', 'residential') ) - AND NOT is_area + OR zoom_level = 13 AND highway_class(highway) NOT IN ('track', 'path') + OR zoom_level >= 14 + ) UNION ALL - -- etldoc: osm_transportation_linestring -> layer_transportation:z13 - SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_transportation_linestring - WHERE zoom_level = 13 - AND ( - highway_class(highway) NOT IN ('track', 'path') - OR (railway='rail' AND service = '') - ) - AND NOT is_area - UNION ALL - - -- etldoc: osm_transportation_linestring -> layer_transportation:z14_ - SELECT osm_id, geometry, highway, railway, service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order - FROM osm_transportation_linestring - WHERE zoom_level >= 14 AND NOT is_area + -- etldoc: osm_railway_linestring -> layer_transportation:z13 + -- etldoc: osm_railway_linestring -> layer_transportation:z14 + SELECT + osm_id, geometry, NULL AS highway, railway, service, + is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + FROM osm_railway_linestring + WHERE zoom_level = 13 AND (railway='rail' AND service = '') + OR zoom_Level >= 14 UNION ALL -- NOTE: We limit the selection of polys because we need to be -- careful to net get false positives here because -- it is possible that closed linestrings appear both as -- highway linestrings and as polygon - -- etldoc: osm_transportation__polygon -> layer_transportation:z13 - -- etldoc: osm_transportation__polygon -> layer_transportation:z14_ + -- etldoc: osm_highway_polygon -> layer_transportation:z13 + -- etldoc: osm_highway_polygon -> layer_transportation:z14_ SELECT osm_id, geometry, highway, NULL AS railway, NULL AS service, FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE AS is_oneway, z_order - FROM osm_transportation_polygon + FROM osm_highway_polygon -- We do not want underground pedestrian areas for now WHERE zoom_level >= 13 AND is_area AND COALESCE(layer, 0) >= 0 ) AS zoom_levels diff --git a/layers/transportation/mapping.yaml b/layers/transportation/mapping.yaml index 3ba3da0b..2757a0fa 100644 --- a/layers/transportation/mapping.yaml +++ b/layers/transportation/mapping.yaml @@ -1,33 +1,93 @@ generalized_tables: -# etldoc: imposm3 -> osm_transportation_linestring_gen4 - transportation_linestring_gen4: - source: transportation_linestring_gen3 +# etldoc: imposm3 -> osm_highway_linestring_gen4 + highway_linestring_gen4: + source: highway_linestring_gen3 sql_filter: highway IN ('motorway','trunk') AND NOT is_area tolerance: 200.0 -# etldoc: imposm3 -> osm_transportation_linestring_gen3 - transportation_linestring_gen3: - source: transportation_linestring_gen2 +# etldoc: imposm3 -> osm_highway_linestring_gen3 + highway_linestring_gen3: + source: highway_linestring_gen2 sql_filter: highway IN ('motorway','trunk', 'primary') AND NOT is_area tolerance: 120.0 -# etldoc: imposm3 -> osm_transportation_linestring_gen2 - transportation_linestring_gen2: - source: transportation_linestring_gen1 +# etldoc: imposm3 -> osm_highway_linestring_gen2 + highway_linestring_gen2: + source: highway_linestring_gen1 sql_filter: highway IN ('motorway','trunk', 'primary', 'secondary') AND NOT is_area tolerance: 50.0 -# etldoc: imposm3 -> osm_transportation_linestring_gen1 - transportation_linestring_gen1: - source: transportation_linestring +# etldoc: imposm3 -> osm_highway_linestring_gen1 + highway_linestring_gen1: + source: highway_linestring sql_filter: highway IN ('motorway','trunk', 'primary', 'secondary', 'tertiary') AND NOT is_area tolerance: 20.0 +name_field: &name + name: name + key: name + type: string +name_en_field: &name_en + name: name_en + key: name:en + type: string +short_name_field: &short_name + key: short_name + name: short_name + type: string +tunnel_field: &tunnel + key: tunnel + name: is_tunnel + type: bool +bridge_field: &bridge + key: bridge + name: is_bridge + type: bool +ramp_field: &ramp + key: ramp + name: is_ramp + type: bool +ford_field: &ford + key: ford + name: is_ford + type: bool +oneway_field: &oneway + key: oneway + name: is_oneway + type: bool +area_field: &area + name: is_area + key: area + type: bool +service_field: &service + key: service + name: service + type: string +usage_field: &usage + key: usage + name: usage + type: string +ref_field: &ref + key: ref + name: ref + type: string +network_field: &network + key: network + name: network + type: string +layer_field: &layer + key: layer + name: layer + type: integer +z_order_field: &z_order + name: z_order + type: wayzorder + tables: -# etldoc: imposm3 -> osm_transportation_linestring - transportation_linestring: +# etldoc: imposm3 -> osm_highway_linestring + highway_linestring: type: linestring fields: - name: osm_id @@ -37,50 +97,21 @@ tables: - name: highway key: highway type: string - - key: railway - name: railway - type: string - - key: ref - name: ref - type: string - - name: z_order - type: wayzorder - - name: layer - key: layer - type: integer - - key: tunnel - name: is_tunnel - type: bool - - key: bridge - name: is_bridge - type: bool - - key: ramp - name: is_ramp - type: bool - - key: ford - name: is_ford - type: bool - - key: oneway - name: is_oneway - type: bool - - key: name - name: name - type: string - - key: short_name - name: short_name - type: string - - name: name_en - key: name:en - type: string - - name: is_area - key: area - type: bool - - key: service - name: service - type: string - - key: usage - name: usage - type: string + - *ref + - *network + - *z_order + - *layer + - *name + - *name_en + - *short_name + - *tunnel + - *bridge + - *ramp + - *ford + - *oneway + - *area + - *service + - *usage mapping: highway: - motorway @@ -108,16 +139,46 @@ tables: - corridor - crossing - pedestrian + +# etldoc: imposm3 -> osm_railway_linestring + railway_linestring: + type: linestring + fields: + - name: osm_id + type: id + - name: geometry + type: geometry + - key: railway + name: railway + type: string + - *ref + - *network + - *z_order + - *layer + - *name + - *name_en + - *short_name + - *tunnel + - *bridge + - *ramp + - *ford + - *oneway + - *area + - *service + - *usage + mapping: railway: - rail - - light_rail - - subway - narrow_gauge - preserved + - funicular + - subway + - light_rail + - monorail - tram -# etldoc: imposm3 -> osm_transportation_polygon - transportation_polygon: +# etldoc: imposm3 -> osm_highway_polygon + highway_polygon: type: polygon fields: - name: osm_id @@ -138,3 +199,22 @@ tables: mapping: highway: - pedestrian + +# TODO: Future table for joining networks +# etldoc: imposm3 -> osm_route_member + route_member: + type: relation_member + columns: + - name: osm_id + type: id + - name: member + type: member_id + - name: role + type: member_role + - name: type + type: member_type + - *ref + - *network + mapping: + route: + - road diff --git a/layers/transportation/transportation.yaml b/layers/transportation/transportation.yaml index 0542eada..12f64f3e 100644 --- a/layers/transportation/transportation.yaml +++ b/layers/transportation/transportation.yaml @@ -29,7 +29,7 @@ layer: datasource: geometry_field: geometry srid: 900913 - query: (SELECT geometry, class, subclass, oneway, ramp, brunnel FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t + query: (SELECT geometry, class, subclass, oneway, ramp, brunnel, service FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t schema: - ./class.sql - ./ne_global_roads.sql From 4da3e3cc0216316ebf62dd69c5d6f5e6302c8a01 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 28 Nov 2016 13:34:07 +0000 Subject: [PATCH 10/21] Leave attributes as NULL on low zoom levels --- layers/transportation/layer.sql | 37 ++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index 03a6bde5..fdd0e502 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -10,8 +10,8 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp SELECT osm_id, geometry, CASE - WHEN highway IS NULL THEN highway_class(highway) - WHEN railway IS NULL THEN railway_class(railway) + 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 @@ -24,8 +24,9 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp SELECT NULL::bigint AS osm_id, geometry, highway, NULL AS railway, NULL AS service, - FALSE AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, - FALSE AS is_ramp, FALSE AS is_oneway, + NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, + NULL::boolean AS is_ford, + NULL::boolean AS is_ramp, NULL::boolean AS is_oneway, 0 AS z_order FROM ne_10m_global_roads WHERE zoom_level BETWEEN 4 AND 6 AND scalerank <= 1 + zoom_level @@ -33,32 +34,44 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp -- etldoc: osm_highway_linestring_gen4 -> layer_transportation:z7z8 SELECT - osm_id, geometry, highway, NULL AS railway, service, - is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + osm_id, geometry, highway, NULL AS railway, NULL AS service, + NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, + NULL::boolean AS is_ford, + NULL::boolean AS is_ramp, NULL::boolean AS is_oneway, + z_order FROM osm_highway_linestring_gen4 WHERE zoom_level BETWEEN 7 AND 8 UNION ALL -- etldoc: osm_highway_linestring_gen3 -> layer_transportation:z9 SELECT - osm_id, geometry, highway, NULL AS railway, service, - is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + osm_id, geometry, highway, NULL AS railway, NULL AS service, + NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, + NULL::boolean AS is_ford, + NULL::boolean AS is_ramp, NULL::boolean AS is_oneway, + z_order FROM osm_highway_linestring_gen3 WHERE zoom_level = 9 UNION ALL -- etldoc: osm_highway_linestring_gen2 -> layer_transportation:z10 SELECT - osm_id, geometry, highway, NULL AS railway, service, - is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + osm_id, geometry, highway, NULL AS railway, NULL AS service, + NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, + NULL::boolean AS is_ford, + NULL::boolean AS is_ramp, NULL::boolean AS is_oneway, + z_order FROM osm_highway_linestring_gen2 WHERE zoom_level = 10 UNION ALL -- etldoc: osm_highway_linestring_gen1 -> layer_transportation:z11 SELECT - osm_id, geometry, highway, NULL AS railway, service, - is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order + osm_id, geometry, highway, NULL AS railway, NULL AS service, + NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel, + NULL::boolean AS is_ford, + NULL::boolean AS is_ramp, NULL::boolean AS is_oneway, + z_order FROM osm_highway_linestring_gen1 WHERE zoom_level = 11 UNION ALL From 2f35ab3ee135834036284bc0b39f8fd8eb540d77 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 28 Nov 2016 15:42:13 +0000 Subject: [PATCH 11/21] Use classes from ClearTables and add continents --- layers/place/city.sql | 20 +++++++++++--------- layers/place/class.sql | 18 ++++++++++++++++++ layers/place/layer.sql | 32 ++++++++++++++++++++++++++++++++ layers/place/mapping.yaml | 20 ++++++++++++++++++++ layers/place/merge_city_rank.sql | 2 +- layers/place/place.sql | 16 ---------------- layers/place/place.yaml | 5 +++-- layers/place/types.sql | 6 +++--- 8 files changed, 88 insertions(+), 31 deletions(-) create mode 100644 layers/place/class.sql create mode 100644 layers/place/layer.sql delete mode 100644 layers/place/place.sql diff --git a/layers/place/city.sql b/layers/place/city.sql index af23866e..d5304d3d 100644 --- a/layers/place/city.sql +++ b/layers/place/city.sql @@ -3,9 +3,9 @@ -- etldoc: label="layer_city | z2-z7 | z8_z14_ " ] ; CREATE OR REPLACE FUNCTION layer_city(bbox geometry, zoom_level int, pixel_width numeric) -RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class city_class, "rank" int) AS $$ +RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, place city_place, "rank" int, capital int) AS $$ -- etldoc: osm_city_point -> layer_city:z2_7 - SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, place AS class, "rank" + SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, place, "rank", normalize_capital_level(capital) AS capital FROM osm_city_point WHERE geometry && bbox AND ((zoom_level = 2 AND "rank" = 1) @@ -14,10 +14,11 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class c UNION ALL SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, - place AS class, - COALESCE("rank", gridrank + 10) + place, + COALESCE("rank", gridrank + 10), + normalize_capital_level(capital) AS capital FROM ( - SELECT osm_id, geometry, name, name_en, place, "rank", + SELECT osm_id, geometry, name, name_en, place, "rank", capital, row_number() OVER ( PARTITION BY LabelGrid(geometry, 128 * pixel_width) ORDER BY "rank" ASC NULLS LAST, @@ -28,11 +29,12 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class c -- etldoc: osm_city_point -> layer_city:z8_14_ FROM osm_city_point WHERE geometry && bbox - AND ((zoom_level = 8 AND place <= 'town'::city_class) - OR (zoom_level BETWEEN 9 AND 10 AND place <= 'village'::city_class) - OR (zoom_level BETWEEN 11 AND 13 AND place <= 'suburb'::city_class) + AND ((zoom_level = 8 AND place <= 'town'::city_place + OR (zoom_level BETWEEN 9 AND 10 AND place <= 'village'::city_place) + + OR (zoom_level BETWEEN 11 AND 13 AND place <= 'suburb'::city_place) OR (zoom_level >= 14) - ) + )) ) AS ranked_places WHERE (zoom_level = 8 AND (gridrank <= 4 OR "rank" IS NOT NULL)) OR (zoom_level = 9 AND (gridrank <= 8 OR "rank" IS NOT NULL)) diff --git a/layers/place/class.sql b/layers/place/class.sql new file mode 100644 index 00000000..fa349217 --- /dev/null +++ b/layers/place/class.sql @@ -0,0 +1,18 @@ +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 new file mode 100644 index 00000000..a6871940 --- /dev/null +++ b/layers/place/layer.sql @@ -0,0 +1,32 @@ + +-- etldoc: layer_place[shape=record fillcolor=lightpink, style="rounded,filled", +-- etldoc: label="layer_place | z0-z14_ " ] ; + +-- etldoc: layer_continent -> layer_place +-- etldoc: layer_country -> layer_place +-- etldoc: layer_state -> layer_place +-- 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 $$ + SELECT + osm_id, geometry, name, name_en, + 'continent' AS class, 'continent' AS subclass, 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, name_en, + 'country' AS class, 'country' AS subclass,"rank", NULL::int AS capital + FROM layer_country(bbox, zoom_level) + UNION ALL + SELECT + osm_id, geometry, name, name_en, + 'state' AS class, 'state' AS subclass, "rank", NULL::int AS capital + FROM layer_state(bbox, zoom_level) + UNION ALL + SELECT + osm_id, geometry, name, name_en, + place_class(place::text) AS class, place::text AS subclass, "rank", capital + FROM layer_city(bbox, zoom_level, pixel_width) +$$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/place/mapping.yaml b/layers/place/mapping.yaml index 2e342325..aa3b1482 100644 --- a/layers/place/mapping.yaml +++ b/layers/place/mapping.yaml @@ -12,6 +12,23 @@ rank_field: &rank type: integer tables: + # etldoc: imposm3 -> osm_continent_point + continent_point: + type: point + fields: + - name: osm_id + type: id + - name: geometry + type: geometry + - *name + - *name_en + filters: + exclude_tags: + - [ "name", "__nil__" ] + mapping: + place: + - continent + # etldoc: imposm3 -> osm_country_point country_point: type: point @@ -73,6 +90,9 @@ tables: - key: population name: population type: integer + - key: capital + name: capital + type: string - *rank filters: exclude_tags: diff --git a/layers/place/merge_city_rank.sql b/layers/place/merge_city_rank.sql index 025f0586..66ce265a 100644 --- a/layers/place/merge_city_rank.sql +++ b/layers/place/merge_city_rank.sql @@ -18,7 +18,7 @@ WITH important_city_point AS ( ne.nameascii ILIKE osm.name OR ne.nameascii ILIKE osm.name_en ) - AND (osm.place = 'city'::city_class OR osm.place= 'town'::city_class OR osm.place = 'village'::city_class) + AND osm.place IN ('city', 'town', 'village') AND ST_DWithin(ne.geom, osm.geometry, 50000) ) UPDATE osm_city_point AS osm diff --git a/layers/place/place.sql b/layers/place/place.sql deleted file mode 100644 index 8e11d215..00000000 --- a/layers/place/place.sql +++ /dev/null @@ -1,16 +0,0 @@ - --- etldoc: layer_place[shape=record fillcolor=lightpink, style="rounded,filled", --- etldoc: label="layer_place | z0-z14_ " ] ; - --- etldoc: layer_country -> layer_place --- etldoc: layer_state -> layer_place --- 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, "rank" int) AS $$ - SELECT osm_id, geometry, name, name_en, 'country' AS class, "rank" FROM layer_country(bbox, zoom_level) - UNION ALL - SELECT osm_id, geometry, name, name_en, 'state' AS class, "rank" FROM layer_state(bbox, zoom_level) - UNION ALL - SELECT osm_id, geometry, name, name_en, class::text, "rank" FROM layer_city(bbox, zoom_level, pixel_width) -$$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/place/place.yaml b/layers/place/place.yaml index 2ac875d0..02bedd7b 100644 --- a/layers/place/place.yaml +++ b/layers/place/place.yaml @@ -25,16 +25,17 @@ layer: buffer_size: 128 datasource: geometry_field: geometry - query: (SELECT geometry, name, name_en, class, rank FROM layer_place(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t + query: (SELECT geometry, name, name_en, class, subclass, rank, capital FROM layer_place(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t schema: - ./types.sql + - ./class.sql - ./city.sql - ./country.sql - ./state.sql - ./merge_country_rank.sql - ./merge_city_rank.sql - ./merge_state_rank.sql - - ./place.sql + - ./layer.sql datasources: - type: imposm3 mapping_file: ./mapping.yaml diff --git a/layers/place/types.sql b/layers/place/types.sql index 48c575e1..f7fdedfc 100644 --- a/layers/place/types.sql +++ b/layers/place/types.sql @@ -1,9 +1,9 @@ DO $$ BEGIN - IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'city_class') THEN - CREATE TYPE city_class AS ENUM ('city', 'town', 'village', 'hamlet', 'suburb', 'neighbourhood', 'isolated_dwelling'); + IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'city_place') THEN + CREATE TYPE city_place AS ENUM ('city', 'town', 'village', 'hamlet', 'suburb', 'neighbourhood', 'isolated_dwelling'); END IF; END $$; -ALTER TABLE osm_city_point ALTER COLUMN place TYPE city_class USING place::city_class; +ALTER TABLE osm_city_point ALTER COLUMN place TYPE city_place USING place::city_place; From 6fb20ab650c244acf688991df9ac4ebc85d862ce Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 28 Nov 2016 16:03:42 +0000 Subject: [PATCH 12/21] Include country and state select direcdtly in layer func --- layers/place/city.sql | 3 +-- layers/place/country.sql | 11 ----------- layers/place/layer.sql | 24 ++++++++++++++++-------- layers/place/place.yaml | 2 -- layers/place/state.sql | 18 ------------------ 5 files changed, 17 insertions(+), 41 deletions(-) delete mode 100644 layers/place/country.sql delete mode 100644 layers/place/state.sql diff --git a/layers/place/city.sql b/layers/place/city.sql index d5304d3d..1695f312 100644 --- a/layers/place/city.sql +++ b/layers/place/city.sql @@ -40,6 +40,5 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, place c OR (zoom_level = 9 AND (gridrank <= 8 OR "rank" IS NOT NULL)) OR (zoom_level = 10 AND (gridrank <= 12 OR "rank" IS NOT NULL)) OR (zoom_level BETWEEN 11 AND 12 AND (gridrank <= 14 OR "rank" IS NOT NULL)) - OR (zoom_level >= 13) - ORDER BY "rank" ASC; + OR (zoom_level >= 13); $$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/place/country.sql b/layers/place/country.sql deleted file mode 100644 index 3f276fa2..00000000 --- a/layers/place/country.sql +++ /dev/null @@ -1,11 +0,0 @@ - --- etldoc: layer_country[shape=record fillcolor=lightpink, style="rounded,filled", --- etldoc: label="layer_country | z0-z14_ " ] ; - --- etldoc: osm_country_point -> layer_country -CREATE OR REPLACE FUNCTION layer_country(bbox geometry, zoom_level int) -RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, "rank" int) AS $$ - SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, "rank" FROM osm_country_point - WHERE geometry && bbox AND "rank" <= zoom_level AND name <> '' - ORDER BY "rank" ASC, length(name) ASC; -$$ LANGUAGE SQL IMMUTABLE; diff --git a/layers/place/layer.sql b/layers/place/layer.sql index a6871940..053a2601 100644 --- a/layers/place/layer.sql +++ b/layers/place/layer.sql @@ -2,10 +2,10 @@ -- etldoc: layer_place[shape=record fillcolor=lightpink, style="rounded,filled", -- etldoc: label="layer_place | z0-z14_ " ] ; --- etldoc: layer_continent -> layer_place --- etldoc: layer_country -> layer_place --- etldoc: layer_state -> layer_place --- etldoc: layer_city -> layer_place +-- etldoc: osm_continent_point -> layer_place +-- etldoc: osm_country_point -> layer_place +-- etldoc: osm_state_point -> layer_place +-- 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 $$ @@ -16,17 +16,25 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class t WHERE geometry && bbox AND zoom_level < 4 UNION ALL SELECT - osm_id, geometry, name, name_en, + osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, 'country' AS class, 'country' AS subclass,"rank", NULL::int AS capital - FROM layer_country(bbox, zoom_level) + FROM osm_country_point + WHERE geometry && bbox AND "rank" <= zoom_level AND name <> '' UNION ALL SELECT - osm_id, geometry, name, name_en, + osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, 'state' AS class, 'state' AS subclass, "rank", NULL::int AS capital - FROM layer_state(bbox, zoom_level) + FROM osm_state_point + WHERE geometry && bbox AND + name <> '' AND + ("rank" + 2 <= zoom_level) AND ( + zoom_level >= 5 OR + is_in_country IN ('United Kingdom', 'USA', 'Россия', 'Brasil', 'China', 'India') OR + is_in_country_code IN ('AU', 'CN', 'IN', 'BR', 'US')) UNION ALL SELECT osm_id, geometry, name, name_en, place_class(place::text) AS class, place::text AS subclass, "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 02bedd7b..e1949bed 100644 --- a/layers/place/place.yaml +++ b/layers/place/place.yaml @@ -30,8 +30,6 @@ schema: - ./types.sql - ./class.sql - ./city.sql - - ./country.sql - - ./state.sql - ./merge_country_rank.sql - ./merge_city_rank.sql - ./merge_state_rank.sql diff --git a/layers/place/state.sql b/layers/place/state.sql deleted file mode 100644 index de11478e..00000000 --- a/layers/place/state.sql +++ /dev/null @@ -1,18 +0,0 @@ - --- etldoc: layer_state[shape=record fillcolor=lightpink, style="rounded,filled", --- etldoc: label="layer_state | z0-z14_ " ] ; - --- etldoc: osm_state_point -> layer_state - -CREATE OR REPLACE FUNCTION layer_state(bbox geometry, zoom_level int) -RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, "rank" int) AS $$ - SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, "rank" - FROM osm_state_point - WHERE geometry && bbox AND - name <> '' AND - ("rank" + 2 <= zoom_level) AND ( - zoom_level >= 5 OR - is_in_country IN ('United Kingdom', 'USA', 'Россия', 'Brasil', 'China', 'India') OR - is_in_country_code IN ('AU', 'CN', 'IN', 'BR', 'US')) - ORDER BY "rank" ASC; -$$ LANGUAGE SQL IMMUTABLE; From 21b12facc6413c6245710223437f409e14f63b2b Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Wed, 30 Nov 2016 08:47:58 +0000 Subject: [PATCH 13/21] Create transportation name out of highway linestring --- layers/transportation_name/merge_highways.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layers/transportation_name/merge_highways.sql b/layers/transportation_name/merge_highways.sql index f6811633..42795310 100644 --- a/layers/transportation_name/merge_highways.sql +++ b/layers/transportation_name/merge_highways.sql @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring AS ( highway, min(z_order) AS z_order, array_agg(DISTINCT osm_id) AS member_osm_ids - FROM osm_transportation_linestring + FROM osm_highway_linestring -- We only care about highways (not railways) for labeling WHERE (name <> '' OR ref <> '') AND NULLIF(highway, '') IS NOT NULL GROUP BY name, highway, ref From ee9d4348e05871d62307c2246ddffcbf6e30538f Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Wed, 30 Nov 2016 12:38:47 +0000 Subject: [PATCH 14/21] Add possible values to place layer doc --- layers/place/place.yaml | 66 ++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/layers/place/place.yaml b/layers/place/place.yaml index e1949bed..443c268d 100644 --- a/layers/place/place.yaml +++ b/layers/place/place.yaml @@ -7,21 +7,59 @@ layer: We suggest you use different font styles and sizes to create a text hierarchy. fields: name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the POI. - name_en: The english `name:en` value if available. + name_en: The English `name:en` value or local `name` if not available. + capital: + description: | + The **capital** field marks the + [`admin_level`](http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative#admin_level) + of the boundary the place is a capital of. + values: [2, 4] 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 - than cities). - 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` 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 - 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`. + 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. + values: + - continent + - country + - state + - city + - town + - village + - hamlet + - suburb + - neighbourhood + - isolated_dwelling + rank: + description: | + 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` for the most important cities + and continues from `10` serially based on the + local importance of the city (derived from population and city class). + You can use the **rank** to limit density of labels or improve + the 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`. buffer_size: 128 datasource: geometry_field: geometry From 0cbc3fa8966c51cd1c6938ec11fd4e33b37d8b36 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Wed, 30 Nov 2016 12:57:25 +0000 Subject: [PATCH 15/21] Add values to transportation layers --- layers/transportation/transportation.yaml | 94 ++++++++++++++++--- .../transportation_name.yaml | 60 ++++++++++-- 2 files changed, 136 insertions(+), 18 deletions(-) diff --git a/layers/transportation/transportation.yaml b/layers/transportation/transportation.yaml index 12f64f3e..c6a47dc7 100644 --- a/layers/transportation/transportation.yaml +++ b/layers/transportation/transportation.yaml @@ -1,7 +1,7 @@ layer: id: "transportation" description: | - Roads or [`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) in OpenStreetMap lingo. + **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 @@ -15,17 +15,87 @@ layer: 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: | - Either `motorway`, `major_road` (containing `trunk`, `primary`, `secondary` and `tertiary` roads) and `minor_road` (less important roads in the hierarchy like `residential` or `service`) or `path` for - non vehicle paths (such as `cycleway` or `footpath`). - subclass: | - Original value of the [`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) tag. Use this to do more - precise styling. - properties: | - Additional properties describing the nature of road. - The properties `bridge` and `tunnel` can be combined with `oneway` as well. So to style all bridges the same you - should style both the properties `bridge` and `bridge:oneway`. - Properties can be one of `bridge:oneway`, `tunnel:oneway`, `ramp`, `ford`, `bridge`, `tunnel` or`oneway`. + class: + description: | + Distinguish between more and less important roads. + values: + - motorway + - trunk + - primary + - secondary + - tertiary + - minor + - track + - service + - 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 + brunnel: + description: | + Mark whether way is a tunnel or bridge. + values: + - bridge + - tunnel + - ford + oneway: + description: | + Mark with `1` whether way is a oneway (in the direction of the way) + or not with `0`. + values: [0, 1] + ramp: + description: | + Mark with `1` whether way is a ramp (link or steps) + or not with `0`. + values: [0, 1] + service: + description: | + Original value of the [`service`](http://wiki.openstreetmap.org/wiki/Key:service) tag. + values: + - spur + - yard + - siding + - crossover + - driveway + - alley + - parking_aisle datasource: geometry_field: geometry srid: 900913 diff --git a/layers/transportation_name/transportation_name.yaml b/layers/transportation_name/transportation_name.yaml index 27e55bf3..b5615a0a 100644 --- a/layers/transportation_name/transportation_name.yaml +++ b/layers/transportation_name/transportation_name.yaml @@ -11,12 +11,60 @@ layer: name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Highways#Names_and_references) value of the highway. ref: The OSM [`ref`](http://wiki.openstreetmap.org/wiki/Key:ref) tag of the motorway or road. ref_length: Length of the `ref` field. Useful for having a shield icon as background for labeling motorways. - class: | - Either `motorway`, `major_road` (containing `trunk`, `primary`, `secondary` and `tertiary` roads) and `minor_road` (less important roads in the hierarchy like `residential` or `service`) or `path` for - non vehicle paths (such as `cycleway` or `footpath`). - subclass: | - Original value of the [`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) tag. Use this to do more - precise styling. + network: The OSM [`network`](http://wiki.openstreetmap.org/wiki/Key:network) tag of the road. + class: + description: | + Distinguish between more and less important roads. + values: + - motorway + - trunk + - primary + - secondary + - tertiary + - minor + - track + - service + - 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 datasource: geometry_field: geometry srid: 900913 From d932fb96b33fe4ffcc31017b1e99b6dc3b10a4d7 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Wed, 30 Nov 2016 13:18:53 +0000 Subject: [PATCH 16/21] Limit service values --- layers/transportation/class.sql | 9 +++++++++ layers/transportation/layer.sql | 6 ++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/layers/transportation/class.sql b/layers/transportation/class.sql index 6e4e7e15..ff83b9b5 100644 --- a/layers/transportation/class.sql +++ b/layers/transportation/class.sql @@ -32,3 +32,12 @@ CREATE OR REPLACE FUNCTION railway_class(railway TEXT) RETURNS TEXT AS $$ ELSE NULL END; $$ LANGUAGE SQL IMMUTABLE STRICT; + +-- Limit service to only the most important values to ensure +-- we always know the values of service +CREATE OR REPLACE FUNCTION service_value(service TEXT) RETURNS TEXT AS $$ + SELECT CASE + WHEN service IN ('spur', 'yard', 'siding', 'crossover', 'driveway', 'alley', 'parking_aisle') THEN service + ELSE NULL + END; +$$ LANGUAGE SQL IMMUTABLE STRICT; diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index fdd0e502..0ce42708 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -80,7 +80,8 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp -- etldoc: osm_highway_linestring -> layer_transportation:z13 -- etldoc: osm_highway_linestring -> layer_transportation:z14_ SELECT - osm_id, geometry, highway, NULL AS railway, service, + osm_id, geometry, highway, NULL AS railway, + service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_highway_linestring WHERE NOT is_area AND ( @@ -96,7 +97,8 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp -- etldoc: osm_railway_linestring -> layer_transportation:z13 -- etldoc: osm_railway_linestring -> layer_transportation:z14 SELECT - osm_id, geometry, NULL AS highway, railway, service, + osm_id, geometry, NULL AS highway, railway, + service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, z_order FROM osm_railway_linestring WHERE zoom_level = 13 AND (railway='rail' AND service = '') From 3f5b1371e9611c4eedffeb1ff7805441e5862207 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Wed, 30 Nov 2016 16:19:49 +0000 Subject: [PATCH 17/21] Clarify etldoc for place layer --- layers/place/city.sql | 7 +++---- layers/place/mapping.yaml | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/layers/place/city.sql b/layers/place/city.sql index 1695f312..5e21bca5 100644 --- a/layers/place/city.sql +++ b/layers/place/city.sql @@ -1,10 +1,10 @@ --- etldoc: layer_city[shape=record fillcolor=lightpink, style="rounded,filled", --- etldoc: label="layer_city | z2-z7 | z8_z14_ " ] ; +-- etldoc: layer_city[shape=record fillcolor=lightpink, style="rounded,filled", +-- etldoc: label="layer_city | z2-z14" ] ; +-- etldoc: osm_city_point -> layer_city:z2_14 CREATE OR REPLACE FUNCTION layer_city(bbox geometry, zoom_level int, pixel_width numeric) RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, place city_place, "rank" int, capital int) AS $$ - -- etldoc: osm_city_point -> layer_city:z2_7 SELECT osm_id, geometry, name, COALESCE(NULLIF(name_en, ''), name) AS name_en, place, "rank", normalize_capital_level(capital) AS capital FROM osm_city_point WHERE geometry && bbox @@ -26,7 +26,6 @@ RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, place c population DESC NULLS LAST, length(name) ASC )::int AS gridrank - -- etldoc: osm_city_point -> layer_city:z8_14_ FROM osm_city_point WHERE geometry && bbox AND ((zoom_level = 8 AND place <= 'town'::city_place diff --git a/layers/place/mapping.yaml b/layers/place/mapping.yaml index aa3b1482..1cd4333d 100644 --- a/layers/place/mapping.yaml +++ b/layers/place/mapping.yaml @@ -47,7 +47,7 @@ tables: place: - country - # etldoc: imposm3 -> osm_state_point + # etldoc: imposm3 -> osm_state_point state_point: type: point fields: @@ -74,7 +74,7 @@ tables: place: - state - # etldoc: imposm3 -> osm_city_point + # etldoc: imposm3 -> osm_city_point city_point: type: point fields: From 4df25f25ef6809cf5d5ce08870f266d8cff0abd2 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Wed, 30 Nov 2016 19:07:55 +0000 Subject: [PATCH 18/21] Fix wrong etldoc slots in transportation --- layers/transportation/layer.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index 0ce42708..659033b2 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -4,7 +4,7 @@ $$ LANGUAGE SQL IMMUTABLE STRICT; -- etldoc: layer_transportation[shape=record fillcolor=lightpink, style="rounded,filled", --- etldoc: label=" layer_transportation | z4-z7 | z8 | z9 | z10 | z11 | z12| z13| z14_" ] ; +-- 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 $$ SELECT From d664a2fe256b7dc80ede9776e5f0323b4b19de78 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Thu, 1 Dec 2016 09:09:08 +0000 Subject: [PATCH 19/21] Map place=island into table --- layers/place/mapping.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/layers/place/mapping.yaml b/layers/place/mapping.yaml index 2e342325..c33e94c9 100644 --- a/layers/place/mapping.yaml +++ b/layers/place/mapping.yaml @@ -30,6 +30,24 @@ tables: place: - country + # etldoc: imposm3 -> osm_island_point + island_point: + type: point + fields: + - name: osm_id + type: id + - name: geometry + type: geometry + - *name + - *name_en + - *rank + filters: + exclude_tags: + - [ "name", "__nil__" ] + mapping: + place: + - island + # etldoc: imposm3 -> osm_state_point state_point: type: point From e1fc9481b73eab300e5f39d1b8fc7a6adb919767 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Thu, 1 Dec 2016 09:12:42 +0000 Subject: [PATCH 20/21] Add more languages for places --- layers/place/mapping.yaml | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/layers/place/mapping.yaml b/layers/place/mapping.yaml index c33e94c9..8faac36a 100644 --- a/layers/place/mapping.yaml +++ b/layers/place/mapping.yaml @@ -6,10 +6,43 @@ name_en_field: &name_en name: name_en key: name:en type: string +name_fr_field: &name_fr + name: name_fr + key: name:fr + type: string +name_de_field: &name_de + name: name_de + key: name:de + type: string +name_es_field: &name_es + name: name_es + key: name:es + type: string +name_pt_field: &name_pt + name: name_pt + key: name:pt + type: string +name_ru_field: &name_ru + name: name_ru + key: name:ru + type: string +name_zh_field: &name_zh + name: name_zh + key: name:zh + type: string +name_ar_field: &name_ar + name: name_ar + key: name:ar + type: string +name_ja_field: &name_ja + name: name_ja + key: name:ja + type: string rank_field: &rank name: rank key: rank type: integer + tables: # etldoc: imposm3 -> osm_country_point @@ -22,6 +55,14 @@ tables: type: geometry - *name - *name_en + - *name_de + - *name_fr + - *name_es + - *name_pt + - *name_ru + - *name_zh + - *name_ar + - *name_ja - *rank filters: exclude_tags: @@ -40,6 +81,14 @@ tables: type: geometry - *name - *name_en + - *name_de + - *name_fr + - *name_es + - *name_pt + - *name_ru + - *name_zh + - *name_ar + - *name_ja - *rank filters: exclude_tags: @@ -58,6 +107,14 @@ tables: type: geometry - *name - *name_en + - *name_de + - *name_fr + - *name_es + - *name_pt + - *name_ru + - *name_zh + - *name_ar + - *name_ja - name: is_in_country key: is_in:country type: string @@ -85,6 +142,14 @@ tables: type: geometry - *name - *name_en + - *name_de + - *name_fr + - *name_es + - *name_pt + - *name_ru + - *name_zh + - *name_ar + - *name_ja - name: place key: place type: string From be349acd588af01d3b67f954bde7af5e7ca0f296 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Thu, 1 Dec 2016 10:11:03 +0000 Subject: [PATCH 21/21] Fix etl doc issues with z14 --- layers/transportation/layer.sql | 2 +- layers/water_name/layer.sql | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index 659033b2..347e564e 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -95,7 +95,7 @@ RETURNS TABLE(osm_id bigint, geometry geometry, class text, subclass text, ramp UNION ALL -- etldoc: osm_railway_linestring -> layer_transportation:z13 - -- etldoc: osm_railway_linestring -> layer_transportation:z14 + -- etldoc: osm_railway_linestring -> layer_transportation:z14_ SELECT osm_id, geometry, NULL AS highway, railway, service_value(service) AS service, diff --git a/layers/water_name/layer.sql b/layers/water_name/layer.sql index b8935daa..bf715bb4 100644 --- a/layers/water_name/layer.sql +++ b/layers/water_name/layer.sql @@ -1,11 +1,11 @@ -- etldoc: layer_water_name[shape=record fillcolor=lightpink, style="rounded,filled", --- etldoc: label="layer_water_name | z9_13 | z14_" ] ; +-- etldoc: label="layer_water_name | z9_13 | z14+" ] ; CREATE OR REPLACE FUNCTION layer_water_name(bbox geometry, zoom_level integer) RETURNS TABLE(osm_id bigint, geometry geometry, name text, name_en text, class text) AS $$ -- etldoc: osm_water_lakeline -> layer_water_name:z9_13 - -- etldoc: osm_water_lakeline -> layer_water_name:z14 + -- etldoc: osm_water_lakeline -> layer_water_name:z14_ SELECT osm_id, geometry, name, name_en, 'lake'::text AS class FROM osm_water_lakeline WHERE geometry && bbox