From d932fb96b33fe4ffcc31017b1e99b6dc3b10a4d7 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Wed, 30 Nov 2016 13:18:53 +0000 Subject: [PATCH] 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 = '')