diff --git a/signals.mml b/signals.mml index 4fd2ead3..08232ba2 100644 --- a/signals.mml +++ b/signals.mml @@ -112,9 +112,9 @@ Layer: tags->'railway:kvb' AS kvb, tags->'railway:tvm' AS tvm, tags->'railway:scmt' AS scmt, - railway_etcs_null_no(tags->'railway:ptc') AS ptc, - railway_etcs_null_no(tags->'railway:etcs') AS etcs, - railway_etcs_null_no(tags->'construction:railway:etcs') AS construction_etcs + railway_null_or_zero_to_no(tags->'railway:ptc') AS ptc, + railway_null_or_zero_to_no(tags->'railway:etcs') AS etcs, + railway_null_or_zero_to_no(tags->'construction:railway:etcs') AS construction_etcs FROM openrailwaymap_osm_line WHERE railway = 'rail' AND usage IN ('main', 'branch') AND service IS NULL ) AS r @@ -153,9 +153,9 @@ Layer: tags->'railway:kvb' AS kvb, tags->'railway:tvm' AS tvm, tags->'railway:scmt' AS scmt, - railway_etcs_null_no(tags->'railway:ptc') AS ptc, - railway_etcs_null_no(tags->'railway:etcs') AS etcs, - railway_etcs_null_no(tags->'construction:railway:etcs') AS construction_etcs + railway_null_or_zero_to_no(tags->'railway:ptc') AS ptc, + railway_null_or_zero_to_no(tags->'railway:etcs') AS etcs, + railway_null_or_zero_to_no(tags->'construction:railway:etcs') AS construction_etcs FROM openrailwaymap_osm_line WHERE railway = 'rail' AND usage = 'main' AND service IS NULL ) AS r @@ -201,9 +201,9 @@ Layer: tags->'railway:kvb' AS kvb, tags->'railway:tvm' AS tvm, tags->'railway:scmt' AS scmt, - railway_etcs_null_no(tags->'railway:ptc') AS ptc, - railway_etcs_null_no(tags->'railway:etcs') AS etcs, - railway_etcs_null_no(tags->'construction:railway:etcs') AS construction_etcs, + railway_null_or_zero_to_no(tags->'railway:ptc') AS ptc, + railway_null_or_zero_to_no(tags->'railway:etcs') AS etcs, + railway_null_or_zero_to_no(tags->'construction:railway:etcs') AS construction_etcs, layer FROM openrailwaymap_osm_line WHERE railway IN ('rail', 'tram', 'light_rail', 'subway', 'narrow_gauge', 'disused', 'construction', 'preserved') diff --git a/sql/functions.sql b/sql/functions.sql index ac37311d..22f34bc0 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -295,7 +295,7 @@ $$ LANGUAGE plpgsql; -- Set a value to 'no' if it is null or 0. -CREATE OR REPLACE FUNCTION railway_etcs_null_no(field TEXT) RETURNS +CREATE OR REPLACE FUNCTION railway_null_or_zero_to_no(field TEXT) RETURNS TEXT AS $$ BEGIN IF field = '0' THEN