diff --git a/layers/transportation/mapping.yaml b/layers/transportation/mapping.yaml index 392b910b..ab25d4a2 100644 --- a/layers/transportation/mapping.yaml +++ b/layers/transportation/mapping.yaml @@ -224,6 +224,7 @@ tables: type: member_type - *ref - *network + - *name mapping: route: - road diff --git a/layers/transportation_name/merge_highways.sql b/layers/transportation_name/merge_highways.sql index 6a9e933d..0e7c8f74 100644 --- a/layers/transportation_name/merge_highways.sql +++ b/layers/transportation_name/merge_highways.sql @@ -15,7 +15,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_network AS ( COALESCE(NULLIF(hl.name_en, ''), hl.name) AS name_en, rm.network_type, CASE - WHEN rm.network_type is not null + WHEN (rm.network_type is not null AND nullif(rm.ref::text, '') is not null) then rm.ref::text else hl.ref end as ref, diff --git a/layers/transportation_name/network_type.sql b/layers/transportation_name/network_type.sql index 462928a2..179ee108 100644 --- a/layers/transportation_name/network_type.sql +++ b/layers/transportation_name/network_type.sql @@ -8,7 +8,8 @@ DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'route_network_type') THEN CREATE TYPE route_network_type AS ENUM ( - 'us-interstate', 'us-highway', 'us-state' + 'us-interstate', 'us-highway', 'us-state', + 'ca-transcanada' ); END IF; END @@ -33,6 +34,23 @@ SET network_type = WHEN network = 'US:I' THEN 'us-interstate'::route_network_type WHEN network = 'US:US' THEN 'us-highway'::route_network_type WHEN network LIKE 'US:__' THEN 'us-state'::route_network_type + -- https://en.wikipedia.org/wiki/Trans-Canada_Highway + -- TODO: improve hierarchical queries using + -- http://www.openstreetmap.org/relation/1307243 + -- however the relation does not cover the whole Trans-Canada_Highway + WHEN + (network = 'CA:transcanada') OR + (network = 'CA:BC:primary' AND ref IN ('16')) OR + (name = 'Yellowhead Highway (AB)' AND ref IN ('16')) OR + (network = 'CA:SK' AND ref IN ('16')) OR + (network = 'CA:ON:primary' AND ref IN ('17', '417')) OR + (name = 'Route Transcanadienne (QC)') OR + (network = 'CA:NB' AND ref IN ('2', '16')) OR + (network = 'CA:PEI' AND ref IN ('1')) OR + (network = 'CA:NS' AND ref IN ('104', '105')) OR + (network = 'CA:NL:R' AND ref IN ('1')) OR + (name = ' Trans-Canada Highway (Super)') + THEN 'ca-transcanada'::route_network_type ELSE NULL END ;