Refactor z12-14 transportation filter logic (#1207)

This PR is a refactor.  The purpose of this PR is to refactor the logic in the z12-z14 transportation layer to increase readability and reduce code complexity.

In addition, this fixes bugs in the original filter code:
* Create filter parity between `service` and `service_construction` highway classes.
* Removal of unintended `class` values `minor_construction`, `path_construction`, `service_construction`, and `track_construction` from zoom 12 filter by explicitly listing the highway classes that are included.
This commit is contained in:
Brian Sperlongano
2021-09-20 02:07:38 -04:00
committed by GitHub
parent d19aa5bf24
commit 849aca8da7
3 changed files with 46 additions and 21 deletions

View File

@@ -56,3 +56,37 @@ SELECT CASE
$$ LANGUAGE SQL IMMUTABLE
STRICT
PARALLEL SAFE;
-- Determine which transportation features are shown at zoom 12
CREATE OR REPLACE FUNCTION transportation_filter_z12(highway text, construction text) RETURNS boolean AS
$$
SELECT CASE
WHEN highway IN ('unclassified', 'residential') THEN TRUE
WHEN highway_class(highway, '', construction) IN
(
'motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'raceway',
'motorway_construction', 'trunk_construction', 'primary_construction',
'secondary_construction', 'tertiary_construction', 'raceway_construction'
) THEN TRUE --includes ramps
ELSE FALSE
END
$$ LANGUAGE SQL IMMUTABLE
STRICT
PARALLEL SAFE;
-- Determine which transportation features are shown at zoom 13
-- Assumes that piers have already been excluded
CREATE OR REPLACE FUNCTION transportation_filter_z13(highway text,
public_transport text,
construction text,
service text) RETURNS boolean AS
$$
SELECT CASE
WHEN transportation_filter_z12(highway, construction) THEN TRUE
WHEN highway = 'service' OR construction = 'service' THEN service NOT IN ('driveway', 'parking_aisle')
WHEN highway_class(highway, public_transport, construction) IN ('minor', 'minor_construction') THEN TRUE
ELSE FALSE
END
$$ LANGUAGE SQL IMMUTABLE
STRICT
PARALLEL SAFE;