Add ca-transcanada network type

This commit is contained in:
jirik 2017-03-03 14:05:39 +01:00
parent 3af0204564
commit 7459cbe9c3
3 changed files with 21 additions and 2 deletions

View File

@ -224,6 +224,7 @@ tables:
type: member_type type: member_type
- *ref - *ref
- *network - *network
- *name
mapping: mapping:
route: route:
- road - road

View File

@ -15,7 +15,7 @@ CREATE MATERIALIZED VIEW osm_transportation_name_network AS (
COALESCE(NULLIF(hl.name_en, ''), hl.name) AS name_en, COALESCE(NULLIF(hl.name_en, ''), hl.name) AS name_en,
rm.network_type, rm.network_type,
CASE 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 then rm.ref::text
else hl.ref else hl.ref
end as ref, end as ref,

View File

@ -8,7 +8,8 @@ DO $$
BEGIN BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'route_network_type') THEN IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'route_network_type') THEN
CREATE TYPE route_network_type AS ENUM ( CREATE TYPE route_network_type AS ENUM (
'us-interstate', 'us-highway', 'us-state' 'us-interstate', 'us-highway', 'us-state',
'ca-transcanada'
); );
END IF; END IF;
END END
@ -33,6 +34,23 @@ SET network_type =
WHEN network = 'US:I' THEN 'us-interstate'::route_network_type WHEN network = 'US:I' THEN 'us-interstate'::route_network_type
WHEN network = 'US:US' THEN 'us-highway'::route_network_type WHEN network = 'US:US' THEN 'us-highway'::route_network_type
WHEN network LIKE 'US:__' THEN 'us-state'::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 ELSE NULL
END END
; ;