diff --git a/layers/transportation/etl_diagram.png b/layers/transportation/etl_diagram.png index cea8f26..479b9ed 100644 Binary files a/layers/transportation/etl_diagram.png and b/layers/transportation/etl_diagram.png differ diff --git a/layers/transportation/mapping.yaml b/layers/transportation/mapping.yaml index d8cfe48..34984a0 100644 --- a/layers/transportation/mapping.yaml +++ b/layers/transportation/mapping.yaml @@ -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 diff --git a/layers/transportation/transportation.sql b/layers/transportation/transportation.sql index 416f8c8..6a60144 100644 --- a/layers/transportation/transportation.sql +++ b/layers/transportation/transportation.sql @@ -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 diff --git a/layers/transportation/update_transportation_merge.sql b/layers/transportation/update_transportation_merge.sql index 94ba324..2a46c75 100644 --- a/layers/transportation/update_transportation_merge.sql +++ b/layers/transportation/update_transportation_merge.sql @@ -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(); \ No newline at end of file +EXECUTE PROCEDURE transportation.refresh(); diff --git a/layers/transportation_name/etl_diagram.png b/layers/transportation_name/etl_diagram.png index 7ed7a04..dacb8c1 100644 Binary files a/layers/transportation_name/etl_diagram.png and b/layers/transportation_name/etl_diagram.png differ