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
This commit is contained in:
zstadler
2019-04-07 21:05:00 +03:00
parent 0946790935
commit 2357bde1b9
3 changed files with 62 additions and 6 deletions

View File

@@ -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