Refactor schema, one _gen_z view per zoom. (#1045)
* Refactor layer aeroway. * Refactor layer boundary. * Refactor layer landcover. * Refactor layer landuse. * Refactor layer park. * Refactor layer transportation. * Refactor layer water. * Refactor layer waterway. * Re-generate water* layers etl_diagrams. * Regenerate etl_diagrams for waterway. * Cast NULL to text.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 491 KiB After Width: | Height: | Size: 531 KiB |
@@ -1,55 +1,61 @@
|
||||
generalized_tables:
|
||||
# etldoc: imposm3 -> osm_railway_linestring_gen5
|
||||
railway_linestring_gen5:
|
||||
source: railway_linestring_gen4
|
||||
# etldoc: osm_railway_linestring_gen_z9 -> osm_railway_linestring_gen_z8
|
||||
railway_linestring_gen_z8:
|
||||
source: railway_linestring_gen_z9
|
||||
tolerance: ZRES9
|
||||
|
||||
# etldoc: imposm3 -> osm_railway_linestring_gen4
|
||||
railway_linestring_gen4:
|
||||
source: railway_linestring_gen3
|
||||
# etldoc: osm_railway_linestring_gen_z10 -> osm_railway_linestring_gen_z9
|
||||
railway_linestring_gen_z9:
|
||||
source: railway_linestring_gen_z10
|
||||
tolerance: ZRES10
|
||||
|
||||
# etldoc: imposm3 -> osm_railway_linestring_gen3
|
||||
railway_linestring_gen3:
|
||||
source: railway_linestring_gen2
|
||||
# etldoc: osm_railway_linestring_gen_z11 -> osm_railway_linestring_gen_z10
|
||||
railway_linestring_gen_z10:
|
||||
source: railway_linestring_gen_z11
|
||||
tolerance: ZRES11
|
||||
|
||||
# etldoc: imposm3 -> osm_railway_linestring_gen2
|
||||
railway_linestring_gen2:
|
||||
source: railway_linestring_gen1
|
||||
# etldoc: osm_railway_linestring_gen_z12 -> osm_railway_linestring_gen_z11
|
||||
railway_linestring_gen_z11:
|
||||
source: railway_linestring_gen_z12
|
||||
tolerance: ZRES12
|
||||
|
||||
# etldoc: imposm3 -> osm_railway_linestring_gen1
|
||||
railway_linestring_gen1:
|
||||
# etldoc: osm_railway_linestring -> osm_railway_linestring_gen_z12
|
||||
railway_linestring_gen_z12:
|
||||
source: railway_linestring
|
||||
sql_filter: railway IN ('rail', 'narrow_gauge', 'light_rail') AND service='' AND ST_IsValid(geometry)
|
||||
tolerance: ZRES13
|
||||
|
||||
# etldoc: imposm3 -> osm_aerialway_linestring_gen1
|
||||
aerialway_linestring_gen1:
|
||||
# etldoc: osm_aerialway_linestring -> osm_aerialway_linestring_gen_z12
|
||||
aerialway_linestring_gen_z12:
|
||||
source: aerialway_linestring
|
||||
sql_filter: ST_IsValid(geometry)
|
||||
tolerance: ZRES13
|
||||
|
||||
# etldoc: imposm3 -> osm_shipway_linestring_gen2
|
||||
shipway_linestring_gen2:
|
||||
source: shipway_linestring_gen1
|
||||
# etldoc: osm_shipway_linestring_gen_z12 -> osm_shipway_linestring_gen_z11
|
||||
shipway_linestring_gen_z11:
|
||||
source: shipway_linestring_gen_z12
|
||||
tolerance: ZRES12
|
||||
|
||||
# etldoc: imposm3 -> osm_shipway_linestring_gen1
|
||||
shipway_linestring_gen1:
|
||||
# etldoc: osm_shipway_linestring -> osm_shipway_linestring_gen_z12
|
||||
shipway_linestring_gen_z12:
|
||||
source: shipway_linestring
|
||||
sql_filter: ST_IsValid(geometry)
|
||||
tolerance: ZRES13
|
||||
|
||||
# etldoc: imposm3 -> osm_highway_linestring_gen2
|
||||
highway_linestring_gen2:
|
||||
source: highway_linestring_gen1
|
||||
# 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: imposm3 -> osm_highway_linestring_gen1
|
||||
highway_linestring_gen1:
|
||||
# etldoc: osm_highway_linestring -> osm_highway_linestring_gen_z11
|
||||
highway_linestring_gen_z11:
|
||||
source: highway_linestring
|
||||
sql_filter: (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link')) AND NOT is_area AND ST_IsValid(geometry)
|
||||
tolerance: ZRES12
|
||||
|
||||
@@ -64,7 +64,7 @@ SELECT osm_id,
|
||||
NULLIF(mtb_scale, '') AS mtb_scale,
|
||||
NULLIF(surface, '') AS surface
|
||||
FROM (
|
||||
-- etldoc: osm_transportation_merge_linestring_gen7 -> layer_transportation:z4
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z4 -> layer_transportation:z4
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
@@ -89,11 +89,11 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen7
|
||||
FROM osm_transportation_merge_linestring_gen_z4
|
||||
WHERE zoom_level = 4
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen6 -> layer_transportation:z5
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z5 -> layer_transportation:z5
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
@@ -118,11 +118,11 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen6
|
||||
FROM osm_transportation_merge_linestring_gen_z5
|
||||
WHERE zoom_level = 5
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen5 -> layer_transportation:z6
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z6 -> layer_transportation:z6
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
@@ -147,11 +147,11 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen5
|
||||
FROM osm_transportation_merge_linestring_gen_z6
|
||||
WHERE zoom_level = 6
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen4 -> layer_transportation:z7
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z7 -> layer_transportation:z7
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
@@ -176,11 +176,11 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen4
|
||||
FROM osm_transportation_merge_linestring_gen_z7
|
||||
WHERE zoom_level = 7
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen3 -> layer_transportation:z8
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z8 -> layer_transportation:z8
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
@@ -205,12 +205,11 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen3
|
||||
FROM osm_transportation_merge_linestring_gen_z8
|
||||
WHERE zoom_level = 8
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring_gen2 -> layer_transportation:z9
|
||||
-- etldoc: osm_highway_linestring_gen2 -> layer_transportation:z10
|
||||
-- etldoc: osm_highway_linestring_gen_z9 -> layer_transportation:z9
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
@@ -235,12 +234,12 @@ FROM (
|
||||
mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_highway_linestring_gen2
|
||||
WHERE zoom_level BETWEEN 9 AND 10
|
||||
AND st_length(geometry) > zres(11)
|
||||
FROM osm_highway_linestring_gen_z9
|
||||
WHERE zoom_level = 9
|
||||
AND ST_Length(geometry) > ZRes(11)
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring_gen1 -> layer_transportation:z11
|
||||
-- etldoc: osm_highway_linestring_gen_z10 -> layer_transportation:z10
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
@@ -265,14 +264,44 @@ FROM (
|
||||
mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_highway_linestring_gen1
|
||||
FROM osm_highway_linestring_gen_z10
|
||||
WHERE zoom_level = 10
|
||||
AND ST_Length(geometry) > ZRes(11)
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring_gen_z11 -> layer_transportation:z11
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
construction,
|
||||
NULL AS railway,
|
||||
NULL AS aerialway,
|
||||
NULL AS shipway,
|
||||
NULL AS public_transport,
|
||||
NULL AS service,
|
||||
is_bridge,
|
||||
is_tunnel,
|
||||
is_ford,
|
||||
NULL::boolean AS is_ramp,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
NULL::boolean AS indoor,
|
||||
bicycle,
|
||||
foot,
|
||||
horse,
|
||||
mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_highway_linestring_gen_z11
|
||||
WHERE zoom_level = 11
|
||||
AND st_length(geometry) > zres(12)
|
||||
AND ST_Length(geometry) > ZRes(12)
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_highway_linestring -> layer_transportation:z12
|
||||
-- etldoc: osm_highway_linestring -> layer_transportation:z13
|
||||
-- etldoc: osm_highway_linestring -> layer_transportation:z14_
|
||||
-- etldoc: osm_highway_linestring -> layer_transportation:z12
|
||||
-- etldoc: osm_highway_linestring -> layer_transportation:z13
|
||||
-- etldoc: osm_highway_linestring -> layer_transportation:z14_
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
@@ -320,7 +349,7 @@ FROM (
|
||||
)
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_railway_linestring_gen5 -> layer_transportation:z8
|
||||
-- etldoc: osm_railway_linestring_gen_z8 -> layer_transportation:z8
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -345,14 +374,14 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_railway_linestring_gen5
|
||||
FROM osm_railway_linestring_gen_z8
|
||||
WHERE zoom_level = 8
|
||||
AND railway = 'rail'
|
||||
AND service = ''
|
||||
AND usage = 'main'
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_railway_linestring_gen4 -> layer_transportation:z9
|
||||
-- etldoc: osm_railway_linestring_gen_z9 -> layer_transportation:z9
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -377,14 +406,14 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_railway_linestring_gen4
|
||||
FROM osm_railway_linestring_gen_z9
|
||||
WHERE zoom_level = 9
|
||||
AND railway = 'rail'
|
||||
AND service = ''
|
||||
AND usage = 'main'
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_railway_linestring_gen3 -> layer_transportation:z10
|
||||
-- etldoc: osm_railway_linestring_gen_z10 -> layer_transportation:z10
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -409,13 +438,13 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_railway_linestring_gen3
|
||||
FROM osm_railway_linestring_gen_z10
|
||||
WHERE zoom_level = 10
|
||||
AND railway IN ('rail', 'narrow_gauge')
|
||||
AND service = ''
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_railway_linestring_gen2 -> layer_transportation:z11
|
||||
-- etldoc: osm_railway_linestring_gen_z11 -> layer_transportation:z11
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -440,13 +469,13 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_railway_linestring_gen2
|
||||
FROM osm_railway_linestring_gen_z11
|
||||
WHERE zoom_level = 11
|
||||
AND railway IN ('rail', 'narrow_gauge', 'light_rail')
|
||||
AND service = ''
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_railway_linestring_gen1 -> layer_transportation:z12
|
||||
-- etldoc: osm_railway_linestring_gen_z12 -> layer_transportation:z12
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -471,14 +500,14 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_railway_linestring_gen1
|
||||
FROM osm_railway_linestring_gen_z12
|
||||
WHERE zoom_level = 12
|
||||
AND railway IN ('rail', 'narrow_gauge', 'light_rail')
|
||||
AND service = ''
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_railway_linestring -> layer_transportation:z13
|
||||
-- etldoc: osm_railway_linestring -> layer_transportation:z14_
|
||||
-- etldoc: osm_railway_linestring -> layer_transportation:z13
|
||||
-- etldoc: osm_railway_linestring -> layer_transportation:z14_
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -505,11 +534,12 @@ FROM (
|
||||
z_order
|
||||
FROM osm_railway_linestring
|
||||
WHERE zoom_level = 13
|
||||
AND railway IN ('rail', 'narrow_gauge', 'light_rail') AND service = ''
|
||||
OR zoom_level >= 14
|
||||
AND railway IN ('rail', 'narrow_gauge', 'light_rail')
|
||||
AND service = ''
|
||||
OR zoom_level >= 14
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_aerialway_linestring_gen1 -> layer_transportation:z12
|
||||
-- etldoc: osm_aerialway_linestring_gen_z12 -> layer_transportation:z12
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -534,12 +564,12 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_aerialway_linestring_gen1
|
||||
FROM osm_aerialway_linestring_gen_z12
|
||||
WHERE zoom_level = 12
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_aerialway_linestring -> layer_transportation:z13
|
||||
-- etldoc: osm_aerialway_linestring -> layer_transportation:z14_
|
||||
-- etldoc: osm_aerialway_linestring -> layer_transportation:z13
|
||||
-- etldoc: osm_aerialway_linestring -> layer_transportation:z14_
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -568,7 +598,7 @@ FROM (
|
||||
WHERE zoom_level >= 13
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_shipway_linestring_gen2 -> layer_transportation:z11
|
||||
-- etldoc: osm_shipway_linestring_gen_z11 -> layer_transportation:z11
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -593,11 +623,11 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_shipway_linestring_gen2
|
||||
FROM osm_shipway_linestring_gen_z11
|
||||
WHERE zoom_level = 11
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_shipway_linestring_gen1 -> layer_transportation:z12
|
||||
-- etldoc: osm_shipway_linestring_gen_z12 -> layer_transportation:z12
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -622,12 +652,12 @@ FROM (
|
||||
NULL AS mtb_scale,
|
||||
NULL AS surface,
|
||||
z_order
|
||||
FROM osm_shipway_linestring_gen1
|
||||
FROM osm_shipway_linestring_gen_z12
|
||||
WHERE zoom_level = 12
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_shipway_linestring -> layer_transportation:z13
|
||||
-- etldoc: osm_shipway_linestring -> layer_transportation:z14_
|
||||
-- etldoc: osm_shipway_linestring -> layer_transportation:z13
|
||||
-- etldoc: osm_shipway_linestring -> layer_transportation:z14_
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
NULL AS highway,
|
||||
@@ -660,8 +690,8 @@ FROM (
|
||||
-- careful to net get false positives here because
|
||||
-- it is possible that closed linestrings appear both as
|
||||
-- highway linestrings and as polygon
|
||||
-- etldoc: osm_highway_polygon -> layer_transportation:z13
|
||||
-- etldoc: osm_highway_polygon -> layer_transportation:z14_
|
||||
-- etldoc: osm_highway_polygon -> layer_transportation:z13
|
||||
-- etldoc: osm_highway_polygon -> layer_transportation:z14_
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
highway,
|
||||
|
||||
@@ -1,11 +1,3 @@
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring CASCADE;
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen3 CASCADE;
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen4 CASCADE;
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen5 CASCADE;
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen6 CASCADE;
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen7 CASCADE;
|
||||
|
||||
|
||||
DROP TRIGGER IF EXISTS trigger_flag_transportation ON osm_highway_linestring;
|
||||
DROP TRIGGER IF EXISTS trigger_refresh ON transportation.updates;
|
||||
|
||||
@@ -21,6 +13,7 @@ CREATE INDEX IF NOT EXISTS osm_highway_linestring_highway_partial_idx
|
||||
WHERE highway IN ('motorway', 'trunk', 'primary', 'construction');
|
||||
|
||||
-- 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
|
||||
(
|
||||
SELECT (ST_Dump(geometry)).geom AS geometry,
|
||||
@@ -52,73 +45,113 @@ CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_highway_partial_i
|
||||
ON osm_transportation_merge_linestring (highway, construction)
|
||||
WHERE highway IN ('motorway', 'trunk', 'primary', 'construction');
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring -> osm_transportation_merge_linestring_gen3
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen3 AS
|
||||
-- etldoc: osm_transportation_merge_linestring -> osm_transportation_merge_linestring_gen_z8
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen_z8 CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z8 AS
|
||||
(
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, highway, construction, is_bridge, is_tunnel, is_ford, z_order
|
||||
SELECT ST_Simplify(geometry, ZRes(10)) AS geometry,
|
||||
osm_id,
|
||||
highway,
|
||||
construction,
|
||||
is_bridge,
|
||||
is_tunnel,
|
||||
is_ford,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring
|
||||
WHERE highway IN ('motorway', 'trunk', 'primary')
|
||||
OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary')
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen3_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen3 USING gist (geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen3_highway_partial_idx
|
||||
ON osm_transportation_merge_linestring_gen3 (highway, construction)
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z8_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen_z8 USING gist (geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z8_highway_partial_idx
|
||||
ON osm_transportation_merge_linestring_gen_z8 (highway, construction)
|
||||
WHERE highway IN ('motorway', 'trunk', 'primary', 'construction');
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen3 -> osm_transportation_merge_linestring_gen4
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen4 AS
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z8 -> osm_transportation_merge_linestring_gen_z7
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen_z7 CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z7 AS
|
||||
(
|
||||
SELECT ST_Simplify(geometry, 200) AS geometry, osm_id, highway, construction, is_bridge, is_tunnel, is_ford, z_order
|
||||
FROM osm_transportation_merge_linestring_gen3
|
||||
SELECT ST_Simplify(geometry, ZRes(9)) AS geometry,
|
||||
osm_id,
|
||||
highway,
|
||||
construction,
|
||||
is_bridge,
|
||||
is_tunnel,
|
||||
is_ford,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z8
|
||||
WHERE (highway IN ('motorway', 'trunk', 'primary') OR
|
||||
highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary'))
|
||||
AND ST_Length(geometry) > 50
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen4_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen4 USING gist (geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen4_highway_partial_idx
|
||||
ON osm_transportation_merge_linestring_gen4 (highway, construction)
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z7_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen_z7 USING gist (geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z7_highway_partial_idx
|
||||
ON osm_transportation_merge_linestring_gen_z7 (highway, construction)
|
||||
WHERE highway IN ('motorway', 'trunk', 'primary', 'construction');
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen4 -> osm_transportation_merge_linestring_gen5
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen5 AS
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z7 -> osm_transportation_merge_linestring_gen_z6
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen_z6 CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z6 AS
|
||||
(
|
||||
SELECT ST_Simplify(geometry, 500) AS geometry, osm_id, highway, construction, is_bridge, is_tunnel, is_ford, z_order
|
||||
FROM osm_transportation_merge_linestring_gen4
|
||||
SELECT ST_Simplify(geometry, ZRes(8)) AS geometry,
|
||||
osm_id,
|
||||
highway,
|
||||
construction,
|
||||
is_bridge,
|
||||
is_tunnel,
|
||||
is_ford,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z7
|
||||
WHERE (highway IN ('motorway', 'trunk') OR highway = 'construction' AND construction IN ('motorway', 'trunk'))
|
||||
AND ST_Length(geometry) > 100
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen5_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen5 USING gist (geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen5_highway_partial_idx
|
||||
ON osm_transportation_merge_linestring_gen5 (highway, construction)
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z6_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen_z6 USING gist (geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z6_highway_partial_idx
|
||||
ON osm_transportation_merge_linestring_gen_z6 (highway, construction)
|
||||
WHERE highway IN ('motorway', 'trunk', 'construction');
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen5 -> osm_transportation_merge_linestring_gen6
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen6 AS
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z6 -> osm_transportation_merge_linestring_gen_z5
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen_z5 CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z5 AS
|
||||
(
|
||||
SELECT ST_Simplify(geometry, 1000) AS geometry, osm_id, highway, construction, is_bridge, is_tunnel, is_ford, z_order
|
||||
FROM osm_transportation_merge_linestring_gen5
|
||||
SELECT ST_Simplify(geometry, ZRes(7)) AS geometry,
|
||||
osm_id,
|
||||
highway,
|
||||
construction,
|
||||
is_bridge,
|
||||
is_tunnel,
|
||||
is_ford,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z6
|
||||
WHERE (highway IN ('motorway', 'trunk') OR highway = 'construction' AND construction IN ('motorway', 'trunk'))
|
||||
AND ST_Length(geometry) > 500
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen6_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen6 USING gist (geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen6_highway_partial_idx
|
||||
ON osm_transportation_merge_linestring_gen6 (highway, construction)
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z5_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen_z5 USING gist (geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z5_highway_partial_idx
|
||||
ON osm_transportation_merge_linestring_gen_z5 (highway, construction)
|
||||
WHERE highway IN ('motorway', 'trunk', 'construction');
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen6 -> osm_transportation_merge_linestring_gen7
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen7 AS
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z5 -> osm_transportation_merge_linestring_gen_z4
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_transportation_merge_linestring_gen_z4 CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z4 AS
|
||||
(
|
||||
SELECT ST_Simplify(geometry, 2000) AS geometry, osm_id, highway, construction, is_bridge, is_tunnel, is_ford, z_order
|
||||
FROM osm_transportation_merge_linestring_gen6
|
||||
SELECT ST_Simplify(geometry, ZRes(6)) AS geometry,
|
||||
osm_id,
|
||||
highway,
|
||||
construction,
|
||||
is_bridge,
|
||||
is_tunnel,
|
||||
is_ford,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z5
|
||||
WHERE (highway = 'motorway' OR highway = 'construction' AND construction = 'motorway')
|
||||
AND ST_Length(geometry) > 1000
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen7_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen7 USING gist (geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z4_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen_z4 USING gist (geometry);
|
||||
|
||||
|
||||
-- Handle updates
|
||||
@@ -146,11 +179,11 @@ DECLARE
|
||||
BEGIN
|
||||
RAISE LOG 'Refresh transportation';
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen3;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen4;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen5;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen6;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen7;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z8;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z7;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z6;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z5;
|
||||
REFRESH MATERIALIZED VIEW osm_transportation_merge_linestring_gen_z4;
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM transportation.updates;
|
||||
|
||||
@@ -170,4 +203,4 @@ CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
ON transportation.updates
|
||||
INITIALLY DEFERRED
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE transportation.refresh();
|
||||
EXECUTE PROCEDURE transportation.refresh();
|
||||
Reference in New Issue
Block a user