Fix transportation road segments disconnection (#1109)

To avoid discontinuous transportation lines between zooms 9 and 11. 
 - Originally limit geometry by length for z9 - z11 (`ST_Length(geometry) > ZRes(11)`)
 - highway z9 to z11 was generalized during import-osm
 - now just create a filtered and generalized z11 table
 - then merge segments in the same way as from (full-featured) osm_highway_linestring and used this merged z11 for mat.view z10 and z9

Close #1107
This commit is contained in:
Tomas Pohanka
2021-04-30 15:39:56 +02:00
committed by GitHub
parent 68ec5c7ac8
commit d0ebdde458
5 changed files with 93 additions and 22 deletions

View File

@@ -12,6 +12,92 @@ CREATE INDEX IF NOT EXISTS osm_highway_linestring_highway_partial_idx
ON osm_highway_linestring (highway)
WHERE highway IN ('motorway', 'trunk', 'primary', 'construction');
-- etldoc: osm_highway_linestring_gen_z11 -> osm_transportation_merge_linestring_gen_z11
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen_z11 CASCADE;
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z11 AS
(
SELECT (ST_Dump(geometry)).geom AS geometry,
NULL::bigint AS osm_id,
highway,
construction,
is_bridge,
is_tunnel,
is_ford,
z_order,
bicycle,
foot,
horse,
mtb_scale,
layer
FROM (
SELECT ST_LineMerge(ST_Collect(geometry)) AS geometry,
highway,
construction,
is_bridge,
is_tunnel,
is_ford,
min(z_order) AS z_order,
bicycle,
foot,
horse,
mtb_scale,
layer
FROM osm_highway_linestring_gen_z11
WHERE ST_IsValid(geometry)
GROUP BY highway, construction, is_bridge, is_tunnel, is_ford, bicycle, foot, horse, mtb_scale, layer
) AS highway_union
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z11_geometry_idx
ON osm_transportation_merge_linestring_gen_z11 USING gist (geometry);
-- etldoc: osm_transportation_merge_linestring_gen_z11 -> osm_transportation_merge_linestring_gen_z10
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen_z10 CASCADE;
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z10 AS
(
SELECT ST_Simplify(geometry, ZRes(12)) AS geometry,
osm_id,
highway,
construction,
is_bridge,
is_tunnel,
is_ford,
z_order,
bicycle,
foot,
horse,
mtb_scale,
layer
FROM osm_transportation_merge_linestring_gen_z11
WHERE highway NOT IN ('tertiary', 'tertiary_link')
OR highway = 'construction' AND construction NOT IN ('tertiary', 'tertiary_link')
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z10_geometry_idx
ON osm_transportation_merge_linestring_gen_z10 USING gist (geometry);
-- etldoc: osm_transportation_merge_linestring_gen_z10 -> osm_transportation_merge_linestring_gen_z9
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen_z9 CASCADE;
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z9 AS
(
SELECT ST_Simplify(geometry, ZRes(11)) AS geometry,
osm_id,
highway,
construction,
is_bridge,
is_tunnel,
is_ford,
z_order,
bicycle,
foot,
horse,
mtb_scale,
layer
FROM osm_transportation_merge_linestring_gen_z10
WHERE highway NOT IN ('tertiary', 'tertiary_link')
OR highway = 'construction' AND construction NOT IN ('tertiary', 'tertiary_link')
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z9_geometry_idx
ON osm_transportation_merge_linestring_gen_z9 USING gist (geometry);
-- etldoc: osm_highway_linestring -> osm_transportation_merge_linestring
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring CASCADE;
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring AS
@@ -188,4 +274,4 @@ CREATE CONSTRAINT TRIGGER trigger_refresh
ON transportation.updates
INITIALLY DEFERRED
FOR EACH ROW
EXECUTE PROCEDURE transportation.refresh();
EXECUTE PROCEDURE transportation.refresh();