From 2357bde1b9728ace2f99bb32f91b344b7cff3256 Mon Sep 17 00:00:00 2001 From: zstadler Date: Sun, 7 Apr 2019 21:05:00 +0300 Subject: [PATCH] Add bicycle, foot, horse, and mtb_scale to the transportation layer Resolve https://github.com/openmaptiles/openmaptiles/issues/422 Resolve https://github.com/openmaptiles/openmaptiles/issues/512 Resolve https://github.com/openmaptiles/openmaptiles/issues/602 An extended and refined alternative to https://github.com/openmaptiles/openmaptiles/pull/573 --- layers/transportation/layer.sql | 28 +++++++++++++++++++++-- layers/transportation/mapping.yaml | 20 ++++++++++++++++ layers/transportation/transportation.yaml | 20 ++++++++++++---- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/layers/transportation/layer.sql b/layers/transportation/layer.sql index dfa6dc85..9b555d08 100644 --- a/layers/transportation/layer.sql +++ b/layers/transportation/layer.sql @@ -8,7 +8,7 @@ $$ 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, service TEXT, layer INT, level INT, -indoor INT) AS $$ +indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT) AS $$ SELECT osm_id, geometry, CASE @@ -33,7 +33,11 @@ indoor INT) AS $$ NULLIF(service, '') AS service, NULLIF(layer, 0) AS layer, "level", - CASE WHEN indoor=TRUE THEN 1 ELSE NULL END as indoor + CASE WHEN indoor=TRUE THEN 1 ELSE NULL END as indoor, + NULLIF(bicycle, '') AS bicycle, + NULLIF(foot, '') AS foot, + NULLIF(horse, '') AS horse, + NULLIF(mtb_scale, '') AS mtb_scale FROM ( -- etldoc: osm_transportation_merge_linestring_gen7 -> layer_transportation:z4 SELECT @@ -44,6 +48,7 @@ indoor INT) AS $$ NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_transportation_merge_linestring_gen7 WHERE zoom_level = 4 @@ -58,6 +63,7 @@ indoor INT) AS $$ NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_transportation_merge_linestring_gen6 WHERE zoom_level = 5 @@ -72,6 +78,7 @@ indoor INT) AS $$ NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_transportation_merge_linestring_gen5 WHERE zoom_level = 6 @@ -86,6 +93,7 @@ indoor INT) AS $$ NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_transportation_merge_linestring_gen4 WHERE zoom_level = 7 @@ -100,6 +108,7 @@ indoor INT) AS $$ NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_transportation_merge_linestring_gen3 WHERE zoom_level = 8 @@ -115,6 +124,7 @@ indoor INT) AS $$ NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + bicycle, foot, horse, mtb_scale, z_order FROM osm_highway_linestring_gen2 WHERE zoom_level BETWEEN 9 AND 10 @@ -130,6 +140,7 @@ indoor INT) AS $$ NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + bicycle, foot, horse, mtb_scale, z_order FROM osm_highway_linestring_gen1 WHERE zoom_level = 11 @@ -151,6 +162,7 @@ indoor INT) AS $$ CASE WHEN highway IN ('footway', 'steps') THEN indoor ELSE NULL::boolean END AS indoor, + bicycle, foot, horse, mtb_scale, z_order FROM osm_highway_linestring WHERE NOT is_area AND ( @@ -182,6 +194,7 @@ indoor INT) AS $$ NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, NULL::int AS layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_railway_linestring_gen5 WHERE zoom_level = 8 @@ -197,6 +210,7 @@ indoor INT) AS $$ NULL::boolean AS is_ford, NULL::boolean AS is_ramp, NULL::int AS is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_railway_linestring_gen4 WHERE zoom_level = 9 @@ -210,6 +224,7 @@ indoor INT) AS $$ NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_railway_linestring_gen3 WHERE zoom_level = 10 @@ -223,6 +238,7 @@ indoor INT) AS $$ NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_railway_linestring_gen2 WHERE zoom_level = 11 @@ -236,6 +252,7 @@ indoor INT) AS $$ NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_railway_linestring_gen1 WHERE zoom_level = 12 @@ -250,6 +267,7 @@ indoor INT) AS $$ NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_railway_linestring WHERE zoom_level = 13 @@ -264,6 +282,7 @@ indoor INT) AS $$ NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_aerialway_linestring_gen1 WHERE zoom_level = 12 @@ -277,6 +296,7 @@ indoor INT) AS $$ NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_aerialway_linestring WHERE zoom_level >= 13 @@ -289,6 +309,7 @@ indoor INT) AS $$ NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_shipway_linestring_gen2 WHERE zoom_level = 11 @@ -301,6 +322,7 @@ indoor INT) AS $$ NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_shipway_linestring_gen1 WHERE zoom_level = 12 @@ -314,6 +336,7 @@ indoor INT) AS $$ NULL AS public_transport, service_value(service) AS service, is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_shipway_linestring WHERE zoom_level >= 13 @@ -334,6 +357,7 @@ indoor INT) AS $$ END AS is_bridge, FALSE AS is_tunnel, FALSE AS is_ford, FALSE AS is_ramp, FALSE::int AS is_oneway, man_made, layer, NULL::int AS level, NULL::boolean AS indoor, + NULL as bicycle, NULL as foot, NULL as horse, NULL as mtb_scale, z_order FROM osm_highway_polygon -- We do not want underground pedestrian areas for now diff --git a/layers/transportation/mapping.yaml b/layers/transportation/mapping.yaml index 8819329d..bddc8e9b 100644 --- a/layers/transportation/mapping.yaml +++ b/layers/transportation/mapping.yaml @@ -133,6 +133,22 @@ man_made_field: &man_made z_order_field: &z_order name: z_order type: wayzorder +bicycle_field: &bicycle + key: bicycle + name: bicycle + type: string +foot_field: &foot + key: foot + name: foot + type: string +horse_field: &horse + key: horse + name: horse + type: string +mtb_scale_field: &mtb_scale + key: mtb:scale + name: mtb_scale + type: string tables: # etldoc: imposm3 -> osm_highway_linestring @@ -168,6 +184,10 @@ tables: - *usage - *public_transport - *man_made + - *bicycle + - *foot + - *horse + - *mtb_scale mapping: highway: - motorway diff --git a/layers/transportation/transportation.yaml b/layers/transportation/transportation.yaml index f5311915..87aea720 100644 --- a/layers/transportation/transportation.yaml +++ b/layers/transportation/transportation.yaml @@ -94,21 +94,33 @@ layer: - parking_aisle layer: description: | - Original value of [`layer`](http://wiki.openstreetmap.org/wiki/Key:layer) tag. + Original value of the [`layer`](http://wiki.openstreetmap.org/wiki/Key:layer) tag. level: description: | Experimental feature! Filled only for steps and footways. Original - value of [`level`](http://wiki.openstreetmap.org/wiki/Key:level) tag. + value of the [`level`](http://wiki.openstreetmap.org/wiki/Key:level) tag. indoor: description: | Experimental feature! Filled only for steps and footways. Original - value of [`indoor`](http://wiki.openstreetmap.org/wiki/Key:indoor) tag. + value of the [`indoor`](http://wiki.openstreetmap.org/wiki/Key:indoor) tag. values: - 1 + bicycle: + description: | + Original value of the [`bicycle`](http://wiki.openstreetmap.org/wiki/Key:bicycle) tag (highways only). + foot: + description: | + Original value of the [`foot`](http://wiki.openstreetmap.org/wiki/Key:foot) tag (highways only). + hourse: + description: | + Original value of the [`hourse`](http://wiki.openstreetmap.org/wiki/Key:hourse) tag (highways only). + mtb_scale: + description: | + Original value of the [`mtb:scale`](http://wiki.openstreetmap.org/wiki/Key:mtb:scale) tag (highways only). datasource: geometry_field: geometry srid: 900913 - query: (SELECT geometry, class, subclass, oneway, ramp, brunnel, service, layer, level, indoor FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t + query: (SELECT geometry, class, subclass, oneway, ramp, brunnel, service, layer, level, indoor, bicycle, foot, horse, mtb_scale FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t schema: - ./class.sql - ./update_transportation_merge.sql