diff --git a/layers/transportation/class.sql b/layers/transportation/class.sql index 6e4e7e1..ff83b9b 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 fdd0e50..0ce4270 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 = '')