Merge branch 'master' into bicycle-foot-horse-mtb_scale
This commit is contained in:
@@ -9,7 +9,7 @@ $$ LANGUAGE SQL IMMUTABLE STRICT;
|
||||
|
||||
-- The classes for highways are derived from the classes used in ClearTables
|
||||
-- https://github.com/ClearTables/ClearTables/blob/master/transportation.lua
|
||||
CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT) RETURNS TEXT AS $$
|
||||
CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT, construction TEXT) RETURNS TEXT AS $$
|
||||
SELECT CASE
|
||||
WHEN highway IN ('motorway', 'motorway_link') THEN 'motorway'
|
||||
WHEN highway IN ('trunk', 'trunk_link') THEN 'trunk'
|
||||
@@ -17,9 +17,19 @@ CREATE OR REPLACE FUNCTION highway_class(highway TEXT, public_transport TEXT) RE
|
||||
WHEN highway IN ('secondary', 'secondary_link') THEN 'secondary'
|
||||
WHEN highway IN ('tertiary', 'tertiary_link') THEN 'tertiary'
|
||||
WHEN highway IN ('unclassified', 'residential', 'living_street', 'road') THEN 'minor'
|
||||
WHEN highway IN ('service', 'track') THEN highway
|
||||
WHEN highway IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps', 'bridleway', 'corridor') OR public_transport IN ('platform') THEN 'path'
|
||||
WHEN highway = 'raceway' THEN 'raceway'
|
||||
WHEN highway IN ('service', 'track', 'raceway') THEN highway
|
||||
WHEN highway = 'construction' THEN CASE
|
||||
WHEN construction IN ('motorway', 'motorway_link') THEN 'motorway_construction'
|
||||
WHEN construction IN ('trunk', 'trunk_link') THEN 'trunk_construction'
|
||||
WHEN construction IN ('primary', 'primary_link') THEN 'primary_construction'
|
||||
WHEN construction IN ('secondary', 'secondary_link') THEN 'secondary_construction'
|
||||
WHEN construction IN ('tertiary', 'tertiary_link') THEN 'tertiary_construction'
|
||||
WHEN construction = '' OR construction IN ('unclassified', 'residential', 'living_street', 'road') THEN 'minor_construction'
|
||||
WHEN construction IN ('pedestrian', 'path', 'footway', 'cycleway', 'steps', 'bridleway', 'corridor') OR public_transport IN ('platform') THEN 'path_construction'
|
||||
WHEN construction IN ('service', 'track', 'raceway') THEN CONCAT(highway, '_construction')
|
||||
ELSE NULL
|
||||
END
|
||||
ELSE NULL
|
||||
END;
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 436 KiB After Width: | Height: | Size: 491 KiB |
@@ -12,7 +12,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
CASE
|
||||
WHEN NULLIF(highway, '') IS NOT NULL OR NULLIF(public_transport, '') IS NOT NULL THEN highway_class(highway, public_transport)
|
||||
WHEN NULLIF(highway, '') IS NOT NULL OR NULLIF(public_transport, '') IS NOT NULL THEN highway_class(highway, public_transport, construction)
|
||||
WHEN NULLIF(railway, '') IS NOT NULL THEN railway_class(railway)
|
||||
WHEN NULLIF(aerialway, '') IS NOT NULL THEN aerialway
|
||||
WHEN NULLIF(shipway, '') IS NOT NULL THEN shipway
|
||||
@@ -21,7 +21,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
CASE
|
||||
WHEN railway IS NOT NULL THEN railway
|
||||
WHEN (highway IS NOT NULL OR public_transport IS NOT NULL)
|
||||
AND highway_class(highway, public_transport) = 'path'
|
||||
AND highway_class(highway, public_transport, construction) = 'path'
|
||||
THEN COALESCE(NULLIF(public_transport, ''), highway)
|
||||
ELSE NULL
|
||||
END AS subclass,
|
||||
@@ -43,7 +43,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_transportation_merge_linestring_gen7 -> layer_transportation:z4
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, NULL AS service,
|
||||
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
|
||||
NULL::boolean AS is_ford,
|
||||
@@ -58,7 +58,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_transportation_merge_linestring_gen6 -> layer_transportation:z5
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, NULL AS service,
|
||||
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
|
||||
NULL::boolean AS is_ford,
|
||||
@@ -73,7 +73,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_transportation_merge_linestring_gen5 -> layer_transportation:z6
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, NULL AS service,
|
||||
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
|
||||
NULL::boolean AS is_ford,
|
||||
@@ -88,7 +88,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_transportation_merge_linestring_gen4 -> layer_transportation:z7
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, NULL AS service,
|
||||
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
|
||||
NULL::boolean AS is_ford,
|
||||
@@ -103,7 +103,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_transportation_merge_linestring_gen3 -> layer_transportation:z8
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, NULL AS service,
|
||||
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
|
||||
NULL::boolean AS is_ford,
|
||||
@@ -119,7 +119,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_highway_linestring_gen2 -> layer_transportation:z10
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, NULL AS service,
|
||||
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
|
||||
NULL::boolean AS is_ford,
|
||||
@@ -135,7 +135,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_highway_linestring_gen1 -> layer_transportation:z11
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, NULL AS service,
|
||||
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
|
||||
NULL::boolean AS is_ford,
|
||||
@@ -153,7 +153,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_highway_linestring -> layer_transportation:z14_
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
highway, construction, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, man_made,
|
||||
layer,
|
||||
@@ -169,12 +169,12 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
FROM osm_highway_linestring
|
||||
WHERE NOT is_area AND (
|
||||
zoom_level = 12 AND (
|
||||
highway_class(highway, public_transport) NOT IN ('track', 'path', 'minor')
|
||||
highway_class(highway, public_transport, construction) NOT IN ('track', 'path', 'minor')
|
||||
OR highway IN ('unclassified', 'residential')
|
||||
) AND man_made <> 'pier'
|
||||
OR zoom_level = 13
|
||||
AND (
|
||||
highway_class(highway, public_transport) NOT IN ('track', 'path') AND man_made <> 'pier'
|
||||
highway_class(highway, public_transport, construction) NOT IN ('track', 'path') AND man_made <> 'pier'
|
||||
OR
|
||||
man_made = 'pier' AND NOT ST_IsClosed(geometry)
|
||||
)
|
||||
@@ -190,7 +190,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_railway_linestring_gen5 -> layer_transportation:z8
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
|
||||
NULL::boolean AS is_ford,
|
||||
@@ -206,7 +206,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_railway_linestring_gen4 -> layer_transportation:z9
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
NULL::boolean AS is_bridge, NULL::boolean AS is_tunnel,
|
||||
NULL::boolean AS is_ford,
|
||||
@@ -222,7 +222,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_railway_linestring_gen3 -> layer_transportation:z10
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made,
|
||||
layer, NULL::int AS level, NULL::boolean AS indoor,
|
||||
@@ -236,7 +236,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_railway_linestring_gen2 -> layer_transportation:z11
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made,
|
||||
layer, NULL::int AS level, NULL::boolean AS indoor,
|
||||
@@ -250,7 +250,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_railway_linestring_gen1 -> layer_transportation:z12
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made,
|
||||
layer, NULL::int AS level, NULL::boolean AS indoor,
|
||||
@@ -265,7 +265,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_railway_linestring -> layer_transportation:z14_
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS highway, NULL AS construction, railway, NULL AS aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made,
|
||||
layer, NULL::int AS level, NULL::boolean AS indoor,
|
||||
@@ -280,7 +280,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_aerialway_linestring_gen1 -> layer_transportation:z12
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, NULL as railway, aerialway, NULL AS shipway,
|
||||
NULL AS highway, NULL AS construction, NULL as railway, aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made,
|
||||
layer, NULL::int AS level, NULL::boolean AS indoor,
|
||||
@@ -294,7 +294,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_aerialway_linestring -> layer_transportation:z14_
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, NULL as railway, aerialway, NULL AS shipway,
|
||||
NULL AS highway, NULL AS construction, NULL as railway, aerialway, NULL AS shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made,
|
||||
layer, NULL::int AS level, NULL::boolean AS indoor,
|
||||
@@ -307,7 +307,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_shipway_linestring_gen2 -> layer_transportation:z11
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, NULL AS railway, NULL AS aerialway, shipway,
|
||||
NULL AS highway, NULL AS construction, NULL AS railway, NULL AS aerialway, shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made,
|
||||
layer, NULL::int AS level, NULL::boolean AS indoor,
|
||||
@@ -320,7 +320,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_shipway_linestring_gen1 -> layer_transportation:z12
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, NULL AS railway, NULL AS aerialway, shipway,
|
||||
NULL AS highway, NULL AS construction, NULL AS railway, NULL AS aerialway, shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made,
|
||||
layer, NULL::int AS level, NULL::boolean AS indoor,
|
||||
@@ -334,7 +334,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_shipway_linestring -> layer_transportation:z14_
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
NULL AS highway, NULL AS railway, NULL AS aerialway, shipway,
|
||||
NULL AS highway, NULL AS construction, NULL AS railway, NULL AS aerialway, shipway,
|
||||
NULL AS public_transport, service_value(service) AS service,
|
||||
is_bridge, is_tunnel, is_ford, is_ramp, is_oneway, NULL as man_made,
|
||||
layer, NULL::int AS level, NULL::boolean AS indoor,
|
||||
@@ -352,7 +352,7 @@ indoor INT, bicycle TEXT, foot TEXT, horse TEXT, mtb_scale TEXT, surface TEXT) A
|
||||
-- etldoc: osm_highway_polygon -> layer_transportation:z14_
|
||||
SELECT
|
||||
osm_id, geometry,
|
||||
highway, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
highway, NULL AS construction, NULL AS railway, NULL AS aerialway, NULL AS shipway,
|
||||
public_transport, NULL AS service,
|
||||
CASE WHEN man_made IN ('bridge') THEN TRUE
|
||||
ELSE FALSE
|
||||
|
||||
@@ -45,13 +45,13 @@ generalized_tables:
|
||||
# etldoc: imposm3 -> osm_highway_linestring_gen2
|
||||
highway_linestring_gen2:
|
||||
source: highway_linestring_gen1
|
||||
sql_filter: highway IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link') AND NOT is_area
|
||||
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:
|
||||
source: highway_linestring
|
||||
sql_filter: highway IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') AND NOT is_area AND ST_IsValid(geometry)
|
||||
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
|
||||
|
||||
name_field: &name
|
||||
@@ -166,6 +166,9 @@ tables:
|
||||
- name: highway
|
||||
key: highway
|
||||
type: string
|
||||
- name: construction
|
||||
key: construction
|
||||
type: string
|
||||
- *ref
|
||||
- *network
|
||||
- *z_order
|
||||
@@ -207,18 +210,19 @@ tables:
|
||||
- tertiary_link
|
||||
- unclassified
|
||||
- residential
|
||||
- road
|
||||
- living_street
|
||||
- raceway
|
||||
- track
|
||||
- service
|
||||
- path
|
||||
- cycleway
|
||||
- bridleway
|
||||
- footway
|
||||
- corridor
|
||||
- road
|
||||
- pedestrian
|
||||
- path
|
||||
- footway
|
||||
- cycleway
|
||||
- steps
|
||||
- bridleway
|
||||
- corridor
|
||||
- service
|
||||
- track
|
||||
- raceway
|
||||
- construction
|
||||
public_transport:
|
||||
- platform
|
||||
man_made:
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 128 KiB |
@@ -14,9 +14,10 @@ layer:
|
||||
fields:
|
||||
class:
|
||||
description: |
|
||||
Distinguish between more and less important roads or railways.
|
||||
Distinguish between more and less important roads or railways and roads under construction.
|
||||
Class is derived from the value of the
|
||||
[`highway`](http://wiki.openstreetmap.org/wiki/Key:highway),
|
||||
[`construction`](http://wiki.openstreetmap.org/wiki/Key:construction),
|
||||
[`railway`](http://wiki.openstreetmap.org/wiki/Key:railway),
|
||||
[`aerialway`](http://wiki.openstreetmap.org/wiki/Key:aerialway),
|
||||
[`route`](http://wiki.openstreetmap.org/wiki/Key:route) tag (for
|
||||
@@ -33,6 +34,16 @@ layer:
|
||||
- track
|
||||
- path
|
||||
- raceway
|
||||
- motorway_construction
|
||||
- trunk_construction
|
||||
- primary_construction
|
||||
- secondary_construction
|
||||
- tertiary_construction
|
||||
- minor_construction
|
||||
- service_construction
|
||||
- track_construction
|
||||
- path_construction
|
||||
- raceway_construction
|
||||
- rail
|
||||
- transit
|
||||
- cable_car
|
||||
|
||||
@@ -22,84 +22,88 @@ CREATE INDEX IF NOT EXISTS osm_highway_linestring_highway_idx
|
||||
-- Improve performance of the sql below
|
||||
CREATE INDEX IF NOT EXISTS osm_highway_linestring_highway_partial_idx
|
||||
ON osm_highway_linestring(highway)
|
||||
WHERE highway IN ('motorway','trunk', 'primary');
|
||||
WHERE highway IN ('motorway','trunk', 'primary', 'construction');
|
||||
|
||||
-- etldoc: osm_highway_linestring -> osm_transportation_merge_linestring
|
||||
CREATE MATERIALIZED VIEW osm_transportation_merge_linestring AS (
|
||||
SELECT
|
||||
(ST_Dump(geometry)).geom AS geometry,
|
||||
NULL::bigint AS osm_id,
|
||||
highway,
|
||||
highway, construction,
|
||||
z_order
|
||||
FROM (
|
||||
SELECT
|
||||
ST_LineMerge(ST_Collect(geometry)) AS geometry,
|
||||
highway,
|
||||
highway, construction,
|
||||
min(z_order) AS z_order
|
||||
FROM osm_highway_linestring
|
||||
WHERE highway IN ('motorway','trunk', 'primary') AND ST_IsValid(geometry)
|
||||
group by highway
|
||||
WHERE (highway IN ('motorway','trunk', 'primary') OR highway = 'construction' AND construction IN ('motorway','trunk', 'primary'))
|
||||
AND ST_IsValid(geometry)
|
||||
group by highway, construction
|
||||
) AS highway_union
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_geometry_idx
|
||||
ON osm_transportation_merge_linestring USING gist(geometry);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_highway_partial_idx
|
||||
ON osm_transportation_merge_linestring(highway)
|
||||
WHERE highway IN ('motorway','trunk', 'primary');
|
||||
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 (
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, highway, z_order
|
||||
SELECT ST_Simplify(geometry, 120) AS geometry, osm_id, highway, construction, z_order
|
||||
FROM osm_transportation_merge_linestring
|
||||
WHERE highway IN ('motorway','trunk', 'primary')
|
||||
OR highway = 'construction' AND construction IN ('motorway','trunk', 'primary')
|
||||
);
|
||||
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)
|
||||
WHERE highway IN ('motorway','trunk', 'primary');
|
||||
ON osm_transportation_merge_linestring_gen3(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 (
|
||||
SELECT ST_Simplify(geometry, 200) AS geometry, osm_id, highway, z_order
|
||||
SELECT ST_Simplify(geometry, 200) AS geometry, osm_id, highway, construction, z_order
|
||||
FROM osm_transportation_merge_linestring_gen3
|
||||
WHERE highway IN ('motorway','trunk', 'primary') AND ST_Length(geometry) > 50
|
||||
WHERE (highway IN ('motorway','trunk', 'primary') OR highway = 'construction' AND construction IN ('motorway','trunk', 'primary'))
|
||||
AND ST_Length(geometry) > 50
|
||||
);
|
||||
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)
|
||||
WHERE highway IN ('motorway','trunk', 'primary');
|
||||
ON osm_transportation_merge_linestring_gen4(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 (
|
||||
SELECT ST_Simplify(geometry, 500) AS geometry, osm_id, highway, z_order
|
||||
SELECT ST_Simplify(geometry, 500) AS geometry, osm_id, highway, construction, z_order
|
||||
FROM osm_transportation_merge_linestring_gen4
|
||||
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 100
|
||||
WHERE (highway IN ('motorway','trunk') OR highway = 'construction' AND construction IN ('motorway','trunk'))
|
||||
AND ST_Length(geometry) > 100
|
||||
);
|
||||
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)
|
||||
WHERE highway IN ('motorway', 'trunk');
|
||||
ON osm_transportation_merge_linestring_gen5(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 (
|
||||
SELECT ST_Simplify(geometry, 1000) AS geometry, osm_id, highway, z_order
|
||||
SELECT ST_Simplify(geometry, 1000) AS geometry, osm_id, highway, construction, z_order
|
||||
FROM osm_transportation_merge_linestring_gen5
|
||||
WHERE highway IN ('motorway','trunk') AND ST_Length(geometry) > 500
|
||||
WHERE (highway IN ('motorway','trunk') OR highway = 'construction' AND construction IN ('motorway','trunk')) AND ST_Length(geometry) > 500
|
||||
);
|
||||
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)
|
||||
WHERE highway IN ('motorway','trunk');
|
||||
ON osm_transportation_merge_linestring_gen6(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 (
|
||||
SELECT ST_Simplify(geometry, 2000) AS geometry, osm_id, highway, z_order
|
||||
SELECT ST_Simplify(geometry, 2000) AS geometry, osm_id, highway, construction, z_order
|
||||
FROM osm_transportation_merge_linestring_gen6
|
||||
WHERE highway IN ('motorway') AND ST_Length(geometry) > 1000
|
||||
WHERE (highway = 'motorway' OR highway = 'construction' AND construction = 'motorway') AND ST_Length(geometry) > 1000
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen7_geometry_idx
|
||||
ON osm_transportation_merge_linestring_gen7 USING gist(geometry);
|
||||
|
||||
Reference in New Issue
Block a user