kopia lustrzana https://github.com/openmaptiles/openmaptiles
Sub-national routes in Canada and refactor national network list (#1446)
This PR defines the set of routes in Canada which are equivalent in national importance to the US Interstate Highway System, and are therefore appropriate to render at zoom 4. This creates a sane, connected highway network at this zoom level across the USA and Canada. This adds two additional network types for Canadian highways, ca-provincial for provincial-level roads, and ca-provincial-arterial for "highest importance" roads that are not part of the Trans-Canada highway but should be regarded as equivalent for low-zoom rendering purposes. Additionally, this extracts out the country-specific network checks to a separate function in order to define "equivalent top-level networks" by country, providing a place to add additional national definitions as they're added by contributors.pull/1456/head^2
rodzic
c4d86d44a6
commit
29e49f9424
|
@ -15,12 +15,23 @@ $$
|
||||||
WHEN undefined_object THEN
|
WHEN undefined_object 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',
|
'ca-transcanada', 'ca-provincial-arterial', 'ca-provincial',
|
||||||
'gb-motorway', 'gb-trunk'
|
'gb-motorway', 'gb-trunk'
|
||||||
);
|
);
|
||||||
END
|
END
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
-- Top-level national route networks that should display at the lowest zooms
|
||||||
|
CREATE OR REPLACE FUNCTION osm_national_network(network text) RETURNS boolean AS
|
||||||
|
$$
|
||||||
|
SELECT network <> '' AND network IN (
|
||||||
|
-- Canada
|
||||||
|
'ca-transcanada', 'ca-provincial-arterial',
|
||||||
|
-- United States
|
||||||
|
'us-interstate');
|
||||||
|
$$ LANGUAGE sql IMMUTABLE
|
||||||
|
PARALLEL SAFE;
|
||||||
|
|
||||||
DO
|
DO
|
||||||
$$
|
$$
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
|
@ -22,7 +22,7 @@ INSERT INTO osm_route_member (osm_id, member, ref, network)
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM gbr_route_members_view;
|
FROM gbr_route_members_view;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION osm_route_member_network_type(network text) RETURNS route_network_type AS
|
CREATE OR REPLACE FUNCTION osm_route_member_network_type(network text, ref text) RETURNS route_network_type AS
|
||||||
$$
|
$$
|
||||||
SELECT CASE
|
SELECT CASE
|
||||||
WHEN network = 'US:I' THEN 'us-interstate'::route_network_type
|
WHEN network = 'US:I' THEN 'us-interstate'::route_network_type
|
||||||
|
@ -30,6 +30,17 @@ SELECT CASE
|
||||||
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
|
-- https://en.wikipedia.org/wiki/Trans-Canada_Highway
|
||||||
WHEN network LIKE 'CA:transcanada%' THEN 'ca-transcanada'::route_network_type
|
WHEN network LIKE 'CA:transcanada%' THEN 'ca-transcanada'::route_network_type
|
||||||
|
WHEN network = 'CA:QC:A' THEN 'ca-provincial-arterial'::route_network_type
|
||||||
|
WHEN network = 'CA:ON:primary' THEN
|
||||||
|
CASE
|
||||||
|
WHEN ref LIKE '4__' THEN 'ca-provincial-arterial'::route_network_type
|
||||||
|
WHEN ref = 'QEW' THEN 'ca-provincial-arterial'::route_network_type
|
||||||
|
ELSE 'ca-provincial-arterial'::route_network_type
|
||||||
|
END
|
||||||
|
WHEN network = 'CA:MB:PTH' AND ref = '75' THEN 'ca-provincial-arterial'::route_network_type
|
||||||
|
WHEN network = 'CA:AB:primary' AND ref IN ('2','3','4') THEN 'ca-provincial-arterial'::route_network_type
|
||||||
|
WHEN network = 'CA:BC' AND ref IN ('3','5','99') THEN 'ca-provincial-arterial'::route_network_type
|
||||||
|
WHEN network LIKE 'CA:__' OR network LIKE 'CA:__:%' THEN 'ca-provincial'::route_network_type
|
||||||
WHEN network = 'omt-gb-motorway' THEN 'gb-motorway'::route_network_type
|
WHEN network = 'omt-gb-motorway' THEN 'gb-motorway'::route_network_type
|
||||||
WHEN network = 'omt-gb-trunk' THEN 'gb-trunk'::route_network_type
|
WHEN network = 'omt-gb-trunk' THEN 'gb-trunk'::route_network_type
|
||||||
END;
|
END;
|
||||||
|
@ -39,9 +50,9 @@ $$ LANGUAGE sql IMMUTABLE
|
||||||
-- etldoc: osm_route_member -> osm_route_member
|
-- etldoc: osm_route_member -> osm_route_member
|
||||||
-- see http://wiki.openstreetmap.org/wiki/Relation:route#Road_routes
|
-- see http://wiki.openstreetmap.org/wiki/Relation:route#Road_routes
|
||||||
UPDATE osm_route_member
|
UPDATE osm_route_member
|
||||||
SET network_type = osm_route_member_network_type(network)
|
SET network_type = osm_route_member_network_type(network, ref)
|
||||||
WHERE network != ''
|
WHERE network != ''
|
||||||
AND network_type IS DISTINCT FROM osm_route_member_network_type(network)
|
AND network_type IS DISTINCT FROM osm_route_member_network_type(network, ref)
|
||||||
;
|
;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION update_osm_route_member() RETURNS void AS
|
CREATE OR REPLACE FUNCTION update_osm_route_member() RETURNS void AS
|
||||||
|
@ -64,7 +75,7 @@ BEGIN
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
osm_id,
|
osm_id,
|
||||||
osm_route_member_network_type(network) AS network_type,
|
osm_route_member_network_type(network, ref) AS network_type,
|
||||||
DENSE_RANK() over (PARTITION BY member ORDER BY network_type, network, LENGTH(ref), ref) AS concurrency_index,
|
DENSE_RANK() over (PARTITION BY member ORDER BY network_type, network, LENGTH(ref), ref) AS concurrency_index,
|
||||||
CASE
|
CASE
|
||||||
WHEN network IN ('iwn', 'nwn', 'rwn') THEN 1
|
WHEN network IN ('iwn', 'nwn', 'rwn') THEN 1
|
||||||
|
@ -80,7 +91,7 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS osm_route_member_network_idx ON osm_route_member ("network");
|
CREATE INDEX IF NOT EXISTS osm_route_member_network_idx ON osm_route_member ("network", "ref");
|
||||||
CREATE INDEX IF NOT EXISTS osm_route_member_member_idx ON osm_route_member ("member");
|
CREATE INDEX IF NOT EXISTS osm_route_member_member_idx ON osm_route_member ("member");
|
||||||
CREATE INDEX IF NOT EXISTS osm_route_member_name_idx ON osm_route_member ("name");
|
CREATE INDEX IF NOT EXISTS osm_route_member_name_idx ON osm_route_member ("name");
|
||||||
CREATE INDEX IF NOT EXISTS osm_route_member_ref_idx ON osm_route_member ("ref");
|
CREATE INDEX IF NOT EXISTS osm_route_member_ref_idx ON osm_route_member ("ref");
|
||||||
|
|
|
@ -331,9 +331,7 @@ BEGIN
|
||||||
(highway = 'motorway'
|
(highway = 'motorway'
|
||||||
OR construction = 'motorway'
|
OR construction = 'motorway'
|
||||||
-- Allow trunk roads that are part of a nation's most important route network to show at z4
|
-- Allow trunk roads that are part of a nation's most important route network to show at z4
|
||||||
OR highway = 'trunk' AND
|
OR (highway = 'trunk' AND osm_national_network(network))
|
||||||
network <> '' AND
|
|
||||||
network IN ('ca-transcanada','us-interstate')
|
|
||||||
) AND
|
) AND
|
||||||
ST_Length(geometry) > 500;
|
ST_Length(geometry) > 500;
|
||||||
|
|
||||||
|
@ -356,8 +354,8 @@ BEGIN
|
||||||
FROM osm_transportation_merge_linestring_gen_z5
|
FROM osm_transportation_merge_linestring_gen_z5
|
||||||
WHERE
|
WHERE
|
||||||
(update_id IS NULL OR id = update_id) AND
|
(update_id IS NULL OR id = update_id) AND
|
||||||
|
osm_national_network(network) AND
|
||||||
-- Current view: national-importance motorways and trunks
|
-- Current view: national-importance motorways and trunks
|
||||||
network IN ('ca-transcanada','us-interstate') AND
|
|
||||||
ST_Length(geometry) > 1000;
|
ST_Length(geometry) > 1000;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
|
@ -28,6 +28,8 @@ layer:
|
||||||
- us-highway
|
- us-highway
|
||||||
- us-state
|
- us-state
|
||||||
- ca-transcanada
|
- ca-transcanada
|
||||||
|
- ca-provincial-arterial
|
||||||
|
- ca-provincial
|
||||||
- gb-motorway
|
- gb-motorway
|
||||||
- gb-trunk
|
- gb-trunk
|
||||||
- road (default)
|
- road (default)
|
||||||
|
|
Ładowanie…
Reference in New Issue