Remove unneeded "else null" in conditions (#732)

Minor code cleanup:
SQL already returns NULL in the "WHEN" condition
if it is not matched by any of the cases.

Co-authored-by: Eva Jelinkova <evka.jelinkova@gmail.com>
This commit is contained in:
Yuri Astrakhan
2020-01-22 17:24:28 -05:00
committed by GitHub
parent 3449cecb22
commit c9e7ad90c6
13 changed files with 10 additions and 36 deletions

View File

@@ -3,7 +3,6 @@ CREATE OR REPLACE FUNCTION brunnel(is_bridge BOOL, is_tunnel BOOL, is_ford BOOL)
WHEN is_bridge THEN 'bridge'
WHEN is_tunnel THEN 'tunnel'
WHEN is_ford THEN 'ford'
ELSE NULL
END;
$$ LANGUAGE SQL IMMUTABLE STRICT;
@@ -24,9 +23,7 @@ CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT, co
WHEN construction = 'service' THEN 'service_construction'
WHEN construction = 'track' THEN 'track_construction'
WHEN construction = 'raceway' THEN 'raceway_construction'
ELSE NULL
END
ELSE NULL
END;
$$ LANGUAGE SQL IMMUTABLE;
@@ -36,7 +33,6 @@ CREATE OR REPLACE FUNCTION railway_class(railway TEXT) RETURNS TEXT AS $$
SELECT CASE
WHEN railway IN ('rail', 'narrow_gauge', 'preserved', 'funicular') THEN 'rail'
WHEN railway IN ('subway', 'light_rail', 'monorail', 'tram') THEN 'transit'
ELSE NULL
END;
$$ LANGUAGE SQL IMMUTABLE STRICT;
@@ -45,7 +41,6 @@ $$ LANGUAGE SQL IMMUTABLE STRICT;
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;
@@ -55,6 +50,5 @@ CREATE OR REPLACE FUNCTION surface_value(surface TEXT) RETURNS TEXT AS $$
SELECT CASE
WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'concrete', 'concrete:lanes', 'concrete:plates', 'metal', 'paving_stones', 'sett', 'unhewn_cobblestone', 'wood') THEN 'paved'
WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel', 'gravel_turf', 'ground', 'ice', 'mud', 'pebblestone', 'salt', 'sand', 'snow', 'woodchips') THEN 'unpaved'
ELSE NULL
END;
$$ LANGUAGE SQL IMMUTABLE STRICT;

View File

@@ -23,7 +23,6 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
WHEN (highway IS NOT NULL OR public_transport IS NOT NULL)
AND highway_class(highway, public_transport, construction) = 'path'
THEN COALESCE(NULLIF(public_transport, ''), highway)
ELSE NULL
END AS subclass,
-- All links are considered as ramps as well
CASE WHEN highway_is_link(highway) OR highway = 'steps'
@@ -33,7 +32,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
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 END as indoor,
NULLIF(bicycle, '') AS bicycle,
NULLIF(foot, '') AS foot,
NULLIF(horse, '') AS horse,
@@ -157,12 +156,8 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
public_transport, service_value(service) AS service,
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, man_made,
layer,
CASE WHEN highway IN ('footway', 'steps') THEN "level"
ELSE NULL::int
END AS "level",
CASE WHEN highway IN ('footway', 'steps') THEN indoor
ELSE NULL::boolean
END AS indoor,
CASE WHEN highway IN ('footway', 'steps') THEN "level" END AS "level",
CASE WHEN highway IN ('footway', 'steps') THEN indoor END AS indoor,
bicycle, foot, horse, mtb_scale,
surface_value(surface) AS "surface",
z_order