kopia lustrzana https://github.com/openmaptiles/openmaptiles
Remove bridge/tunnel attributes from tiny bridges (#1283)
This PR now removes bridge/tunnel/ford attributes from the `transportation` layer from sections of bridge/tunnel etc that are too small to be meaningfully visible at a particular zoom level. This allows those segments to be generalized into geometries along with the surrounding sections of road, thereby dropping lots of useless little pieces of geometry in lower-zoom tiles.pull/1486/head^2
rodzic
0c6dd1fecb
commit
d8c367f42c
|
@ -7,6 +7,40 @@ DROP TRIGGER IF EXISTS trigger_store_transportation_highway_linestring_gen_z11 O
|
|||
DROP TRIGGER IF EXISTS trigger_flag_transportation_z11 ON osm_highway_linestring_gen_z11;
|
||||
DROP TRIGGER IF EXISTS trigger_refresh_z11 ON transportation.updates_z11;
|
||||
|
||||
-- Determine whether a segment is long enough to have bridge/tunnel attributes
|
||||
-- Dropping small brunnel sections allow for generalization as distinct segments get too small
|
||||
CREATE OR REPLACE FUNCTION visible_brunnel(g geometry, brunnel boolean, zoom_level integer)
|
||||
RETURNS boolean AS
|
||||
$$
|
||||
SELECT
|
||||
brunnel AND
|
||||
-- Width of a tile in meters (111,842 is the length of one degree of latitude at the equator in meters)
|
||||
-- 111,842 * 180 / 2^zoom_level
|
||||
-- = 20131560 / POW(2, zoom_level)
|
||||
-- Drop brunnel if length of way < 2% of tile width (less than 3 pixels)
|
||||
ST_Length(g) *
|
||||
COS(RADIANS(ST_Y(ST_Centroid(ST_Transform(g, 4326))))) *
|
||||
POW(2, zoom_level) / 20131560 > 0.02
|
||||
$$ LANGUAGE SQL IMMUTABLE LEAKPROOF
|
||||
PARALLEL SAFE;
|
||||
|
||||
-- Determine whether a segment is long enough to have layer attributes
|
||||
CREATE OR REPLACE FUNCTION visible_layer(g geometry, layer int, zoom_level integer)
|
||||
RETURNS int AS
|
||||
$$
|
||||
SELECT
|
||||
CASE WHEN
|
||||
-- Width of a tile in meters (111,842 is the length of one degree of latitude at the equator in meters)
|
||||
-- 111,842 * 180 / 2^zoom_level
|
||||
-- = 20131560 / POW(2, zoom_level)
|
||||
-- Drop brunnel if length of way < 2% of tile width (less than 3 pixels)
|
||||
ST_Length(g) *
|
||||
COS(RADIANS(ST_Y(ST_Centroid(ST_Transform(g, 4326))))) *
|
||||
POW(2, zoom_level) / 20131560 > 0.02
|
||||
THEN layer END
|
||||
$$ LANGUAGE SQL IMMUTABLE LEAKPROOF
|
||||
PARALLEL SAFE;
|
||||
|
||||
-- Instead of using relations to find out the road names we
|
||||
-- stitch together the touching ways with the same name
|
||||
-- to allow for nice label rendering
|
||||
|
@ -121,7 +155,28 @@ SELECT (ST_Dump(ST_LineMerge(ST_Collect(geometry)))).geom AS geometry,
|
|||
ELSE NULL::text END AS access,
|
||||
toll,
|
||||
layer
|
||||
FROM osm_highway_linestring_gen_z11
|
||||
FROM (
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
SELECT geometry,
|
||||
NULL::bigint AS osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
visible_brunnel(geometry, is_bridge, 11) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 11) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 11) AS is_ford,
|
||||
expressway,
|
||||
z_order,
|
||||
bicycle,
|
||||
foot,
|
||||
horse,
|
||||
mtb_scale,
|
||||
sac_scale,
|
||||
access,
|
||||
toll,
|
||||
visible_layer(geometry, layer, 11) AS layer
|
||||
FROM osm_highway_linestring_gen_z11
|
||||
) osm_highway_linestring_normalized_brunnel_z11
|
||||
-- mapping.yaml pre-filter: motorway/trunk/primary/secondary/tertiary, with _link variants, construction, ST_IsValid()
|
||||
GROUP BY highway, network, construction, is_bridge, is_tunnel, is_ford, expressway, bicycle, foot, horse, mtb_scale, sac_scale, access, toll, layer
|
||||
;
|
||||
|
@ -163,7 +218,29 @@ BEGIN
|
|||
access,
|
||||
toll,
|
||||
layer
|
||||
FROM osm_transportation_merge_linestring_gen_z11
|
||||
FROM (
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
SELECT geometry,
|
||||
id,
|
||||
NULL::bigint AS osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
visible_brunnel(geometry, is_bridge, 11) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 11) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 11) AS is_ford,
|
||||
expressway,
|
||||
z_order,
|
||||
bicycle,
|
||||
foot,
|
||||
horse,
|
||||
mtb_scale,
|
||||
sac_scale,
|
||||
access,
|
||||
toll,
|
||||
visible_layer(geometry, layer, 11) AS layer
|
||||
FROM osm_transportation_merge_linestring_gen_z11
|
||||
) osm_highway_linestring_normalized_brunnel_z11
|
||||
WHERE (update_id IS NULL OR id = update_id)
|
||||
AND highway NOT IN ('tertiary', 'tertiary_link', 'busway', 'bus_guideway')
|
||||
AND construction NOT IN ('tertiary', 'tertiary_link', 'busway', 'bus_guideway')
|
||||
|
@ -193,7 +270,29 @@ BEGIN
|
|||
access,
|
||||
toll,
|
||||
layer
|
||||
FROM osm_transportation_merge_linestring_gen_z10
|
||||
FROM (
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
SELECT geometry,
|
||||
id,
|
||||
NULL::bigint AS osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
visible_brunnel(geometry, is_bridge, 10) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 10) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 10) AS is_ford,
|
||||
expressway,
|
||||
z_order,
|
||||
bicycle,
|
||||
foot,
|
||||
horse,
|
||||
mtb_scale,
|
||||
sac_scale,
|
||||
access,
|
||||
toll,
|
||||
visible_layer(geometry, layer, 10) AS layer
|
||||
FROM osm_transportation_merge_linestring_gen_z10
|
||||
) osm_highway_linestring_normalized_brunnel_z10
|
||||
WHERE (update_id IS NULL OR id = update_id)
|
||||
;
|
||||
END;
|
||||
|
@ -238,11 +337,24 @@ SELECT ST_Simplify(ST_LineMerge(ST_Collect(geometry)), ZRes(10)) AS geometry,
|
|||
is_ford,
|
||||
expressway,
|
||||
min(z_order) as z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z9
|
||||
WHERE (highway IN ('motorway', 'trunk', 'primary') OR
|
||||
construction IN ('motorway', 'trunk', 'primary'))
|
||||
AND ST_IsValid(geometry)
|
||||
AND access IS NULL
|
||||
FROM (
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
SELECT geometry,
|
||||
osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
visible_brunnel(geometry, is_bridge, 9) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 9) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 9) AS is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z9
|
||||
WHERE (highway IN ('motorway', 'trunk', 'primary') OR
|
||||
construction IN ('motorway', 'trunk', 'primary'))
|
||||
AND ST_IsValid(geometry)
|
||||
AND access IS NULL
|
||||
) osm_highway_linestring_normalized_brunnel_z9
|
||||
GROUP BY highway, network, construction, is_bridge, is_tunnel, is_ford, expressway
|
||||
;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z8_geometry_idx
|
||||
|
@ -280,7 +392,21 @@ BEGIN
|
|||
is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z8
|
||||
FROM (
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
SELECT geometry,
|
||||
id,
|
||||
osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
visible_brunnel(geometry, is_bridge, 8) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 8) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 8) AS is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z8
|
||||
) osm_highway_linestring_normalized_brunnel_z8
|
||||
-- Current view: motorway/trunk/primary
|
||||
WHERE
|
||||
(update_id IS NULL OR id = update_id) AND
|
||||
|
@ -302,10 +428,26 @@ BEGIN
|
|||
is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z7
|
||||
FROM (
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
SELECT geometry,
|
||||
id,
|
||||
osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
visible_brunnel(geometry, is_bridge, 7) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 7) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 7) AS is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z7
|
||||
WHERE
|
||||
(highway IN ('motorway', 'trunk') OR construction IN ('motorway', 'trunk'))
|
||||
) osm_highway_linestring_normalized_brunnel_z7
|
||||
-- Current view: motorway/trunk/primary
|
||||
WHERE
|
||||
(update_id IS NULL OR id = update_id) AND
|
||||
(highway IN ('motorway', 'trunk') OR construction IN ('motorway', 'trunk')) AND
|
||||
ST_Length(geometry) > 100;
|
||||
|
||||
DELETE FROM osm_transportation_merge_linestring_gen_z5
|
||||
|
@ -324,15 +466,30 @@ BEGIN
|
|||
is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z6
|
||||
WHERE
|
||||
(update_id IS NULL OR id = update_id) AND
|
||||
-- Current view: all motorways and trunks of national-importance
|
||||
(highway = 'motorway'
|
||||
FROM (
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
SELECT geometry,
|
||||
id,
|
||||
osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
visible_brunnel(geometry, is_bridge, 6) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 6) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 6) AS is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z6
|
||||
WHERE
|
||||
(highway = 'motorway'
|
||||
OR construction = 'motorway'
|
||||
-- Allow trunk roads that are part of a nation's most important route network to show at z4
|
||||
OR (highway = 'trunk' AND osm_national_network(network))
|
||||
) AND
|
||||
)
|
||||
) osm_highway_linestring_normalized_brunnel_z6
|
||||
WHERE
|
||||
(update_id IS NULL OR id = update_id) AND
|
||||
-- Current view: all motorways and trunks of national-importance
|
||||
ST_Length(geometry) > 500;
|
||||
|
||||
DELETE FROM osm_transportation_merge_linestring_gen_z4
|
||||
|
@ -351,10 +508,24 @@ BEGIN
|
|||
is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z5
|
||||
FROM (
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
SELECT geometry,
|
||||
id,
|
||||
osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
visible_brunnel(geometry, is_bridge, 5) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 5) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 5) AS is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z5
|
||||
WHERE osm_national_network(network)
|
||||
) osm_highway_linestring_normalized_brunnel_z5
|
||||
WHERE
|
||||
(update_id IS NULL OR id = update_id) AND
|
||||
osm_national_network(network) AND
|
||||
-- Current view: national-importance motorways and trunks
|
||||
ST_Length(geometry) > 1000;
|
||||
END;
|
||||
|
|
Ładowanie…
Reference in New Issue