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
pull/1110/head
Tomas Pohanka 2021-04-30 15:39:56 +02:00 zatwierdzone przez GitHub
rodzic 68ec5c7ac8
commit d0ebdde458
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 93 dodań i 22 usunięć

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 531 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 470 KiB

Wyświetl plik

@ -42,18 +42,6 @@ generalized_tables:
sql_filter: ST_IsValid(geometry)
tolerance: ZRES13
# etldoc: osm_highway_linestring_gen_z10 -> osm_highway_linestring_gen_z9
highway_linestring_gen_z9:
source: highway_linestring_gen_z10
sql_filter: (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link') OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link')) AND NOT is_area
tolerance: ZRES10
# etldoc: osm_highway_linestring_gen_z11 -> osm_highway_linestring_gen_z10
highway_linestring_gen_z10:
source: highway_linestring_gen_z11
sql_filter: (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link') OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link')) AND NOT is_area
tolerance: ZRES11
# etldoc: osm_highway_linestring -> osm_highway_linestring_gen_z11
highway_linestring_gen_z11:
source: highway_linestring

Wyświetl plik

@ -209,7 +209,7 @@ FROM (
WHERE zoom_level = 8
UNION ALL
-- etldoc: osm_highway_linestring_gen_z9 -> layer_transportation:z9
-- etldoc: osm_transportation_merge_linestring_gen_z9 -> layer_transportation:z9
SELECT osm_id,
geometry,
highway,
@ -234,12 +234,11 @@ FROM (
mtb_scale,
NULL AS surface,
z_order
FROM osm_highway_linestring_gen_z9
FROM osm_transportation_merge_linestring_gen_z9
WHERE zoom_level = 9
AND ST_Length(geometry) > ZRes(11)
UNION ALL
-- etldoc: osm_highway_linestring_gen_z10 -> layer_transportation:z10
-- etldoc: osm_transportation_merge_linestring_gen_z10 -> layer_transportation:z10
SELECT osm_id,
geometry,
highway,
@ -264,12 +263,11 @@ FROM (
mtb_scale,
NULL AS surface,
z_order
FROM osm_highway_linestring_gen_z10
FROM osm_transportation_merge_linestring_gen_z10
WHERE zoom_level = 10
AND ST_Length(geometry) > ZRes(11)
UNION ALL
-- etldoc: osm_highway_linestring_gen_z11 -> layer_transportation:z11
-- etldoc: osm_transportation_merge_linestring_gen_z11 -> layer_transportation:z11
SELECT osm_id,
geometry,
highway,
@ -294,9 +292,8 @@ FROM (
mtb_scale,
NULL AS surface,
z_order
FROM osm_highway_linestring_gen_z11
FROM osm_transportation_merge_linestring_gen_z11
WHERE zoom_level = 11
AND ST_Length(geometry) > ZRes(12)
UNION ALL
-- etldoc: osm_highway_linestring -> layer_transportation:z12

Wyświetl plik

@ -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();

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 225 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 217 KiB