Merge remote-tracking branch 'github/master' into merge-gh-2025
# Conflicts: # layers/boundary/mapping.yaml # layers/mountain_peak/style.json # layers/place/style.json # layers/poi/poi.yaml
@@ -5,9 +5,9 @@ layer:
|
||||
buffer_size: 64
|
||||
srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
|
||||
fields:
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the aerodrome.
|
||||
name_en: English name `name:en` if available, otherwise `name`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the aerodrome. Language-specific values are in `name:xx`.
|
||||
name_en: English name `name:en` if available, otherwise `name`. This is deprecated and will be removed in a future release in favor of `name:en`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`. This is deprecated and will be removed in a future release in favor of `name:de`.
|
||||
class:
|
||||
description: |
|
||||
Distinguish between more and less important aerodromes.
|
||||
|
||||
@@ -93,12 +93,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_aerodrome_label_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE aerodrome_label.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_aerodrome_label_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE aerodrome_label.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -150,38 +150,10 @@ CREATE MATERIALIZED VIEW osm_border_linestring_gen_z4 AS
|
||||
(
|
||||
SELECT ST_Simplify(geometry, ZRes(5)) AS geometry, adm0_l, adm0_r, admin_level, disputed, name, claimed_by, maritime
|
||||
FROM osm_border_linestring_gen_z5
|
||||
WHERE admin_level = 2 AND (maritime OR disputed)
|
||||
WHERE admin_level = 2 AND maritime
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
|
||||
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z4_idx ON osm_border_linestring_gen_z4 USING gist (geometry);
|
||||
|
||||
-- etldoc: osm_border_linestring_gen_z4 -> osm_border_disp_linestring_gen_z3
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_border_disp_linestring_gen_z3 CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_border_disp_linestring_gen_z3 AS
|
||||
(
|
||||
SELECT ST_Simplify(geometry, ZRes(4)) AS geometry, adm0_l, adm0_r, admin_level, TRUE AS disputed, name, claimed_by, maritime
|
||||
FROM osm_border_linestring_gen_z4
|
||||
WHERE disputed -- AND admin_level = 2
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
|
||||
CREATE INDEX IF NOT EXISTS osm_border_disp_linestring_gen_z3_idx ON osm_border_disp_linestring_gen_z3 USING gist (geometry);
|
||||
|
||||
-- etldoc: osm_border_disp_linestring_gen_z3 -> osm_border_disp_linestring_gen_z2
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_border_disp_linestring_gen_z2 CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_border_disp_linestring_gen_z2 AS
|
||||
(
|
||||
SELECT ST_Simplify(geometry, ZRes(3)) AS geometry, adm0_l, adm0_r, admin_level, TRUE AS disputed, name, claimed_by, maritime
|
||||
FROM osm_border_disp_linestring_gen_z3
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
|
||||
CREATE INDEX IF NOT EXISTS osm_border_disp_linestring_gen_z2_idx ON osm_border_disp_linestring_gen_z2 USING gist (geometry);
|
||||
|
||||
-- etldoc: osm_border_disp_linestring_gen_z2 -> osm_border_disp_linestring_gen_z1
|
||||
DROP MATERIALIZED VIEW IF EXISTS osm_border_disp_linestring_gen_z1 CASCADE;
|
||||
CREATE MATERIALIZED VIEW osm_border_disp_linestring_gen_z1 AS
|
||||
(
|
||||
SELECT ST_Simplify(geometry, ZRes(2)) AS geometry, adm0_l, adm0_r, admin_level, TRUE AS disputed, name, claimed_by, maritime
|
||||
FROM osm_border_disp_linestring_gen_z2
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
|
||||
CREATE INDEX IF NOT EXISTS osm_border_disp_linestring_gen_z1_idx ON osm_border_disp_linestring_gen_z1 USING gist (geometry);
|
||||
|
||||
-- ne_10m_admin_0_boundary_lines_land
|
||||
-- etldoc: ne_10m_admin_0_boundary_lines_land -> ne_10m_admin_0_boundary_lines_land_gen_z4
|
||||
DROP MATERIALIZED VIEW IF EXISTS ne_10m_admin_0_boundary_lines_land_gen_z4 CASCADE;
|
||||
@@ -190,7 +162,7 @@ CREATE MATERIALIZED VIEW ne_10m_admin_0_boundary_lines_land_gen_z4 AS
|
||||
SELECT ST_Simplify(geometry, ZRes(6)) as geometry,
|
||||
2 AS admin_level,
|
||||
(CASE WHEN featurecla LIKE 'Disputed%' THEN TRUE ELSE FALSE END) AS disputed,
|
||||
(CASE WHEN featurecla LIKE 'Disputed%' THEN 'ne10m_' || ogc_fid ELSE NULL::text END) AS disputed_name,
|
||||
NULL::text AS disputed_name,
|
||||
NULL::text AS claimed_by,
|
||||
FALSE AS maritime
|
||||
FROM ne_10m_admin_0_boundary_lines_land
|
||||
@@ -198,6 +170,21 @@ WHERE featurecla <> 'Lease limit'
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
|
||||
CREATE INDEX IF NOT EXISTS ne_10m_admin_0_boundary_lines_land_gen_z4_idx ON ne_10m_admin_0_boundary_lines_land_gen_z4 USING gist (geometry);
|
||||
|
||||
-- etldoc: ne_10m_admin_0_boundary_lines_land -> ne_10m_admin_0_boundary_lines_land_disputed
|
||||
DROP MATERIALIZED VIEW IF EXISTS ne_10m_admin_0_boundary_lines_land_disputed CASCADE;
|
||||
CREATE MATERIALIZED VIEW ne_10m_admin_0_boundary_lines_land_disputed AS
|
||||
(
|
||||
SELECT geometry,
|
||||
2 AS admin_level,
|
||||
(CASE WHEN featurecla LIKE 'Disputed%' THEN TRUE ELSE FALSE END) AS disputed,
|
||||
NULL::text AS disputed_name,
|
||||
NULL::text AS claimed_by,
|
||||
FALSE AS maritime
|
||||
FROM ne_10m_admin_0_boundary_lines_land
|
||||
WHERE featurecla LIKE 'Disputed%' AND adm0_left = 'South Sudan' AND adm0_right = 'Kenya'
|
||||
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
|
||||
CREATE INDEX IF NOT EXISTS ne_10m_admin_0_boundary_lines_land_disputed_idx ON ne_10m_admin_0_boundary_lines_land_disputed USING gist (geometry);
|
||||
|
||||
-- ne_10m_admin_1_states_provinces_lines
|
||||
-- etldoc: ne_10m_admin_1_states_provinces_lines -> ne_10m_admin_1_states_provinces_lines_gen_z4
|
||||
DROP MATERIALIZED VIEW IF EXISTS ne_10m_admin_1_states_provinces_lines_gen_z4 CASCADE;
|
||||
@@ -267,7 +254,7 @@ CREATE MATERIALIZED VIEW ne_50m_admin_0_boundary_lines_land_gen_z3 AS
|
||||
SELECT ST_Simplify(geometry, ZRes(5)) as geometry,
|
||||
2 AS admin_level,
|
||||
(CASE WHEN featurecla LIKE 'Disputed%' THEN TRUE ELSE FALSE END) AS disputed,
|
||||
(CASE WHEN featurecla LIKE 'Disputed%' THEN 'ne50m_' || ogc_fid ELSE NULL::text END) AS disputed_name,
|
||||
NULL::text AS disputed_name,
|
||||
NULL::text AS claimed_by,
|
||||
FALSE AS maritime
|
||||
FROM ne_50m_admin_0_boundary_lines_land
|
||||
@@ -310,7 +297,7 @@ CREATE MATERIALIZED VIEW ne_110m_admin_0_boundary_lines_land_gen_z0 AS
|
||||
SELECT ST_Simplify(geometry, ZRes(2)) as geometry,
|
||||
2 AS admin_level,
|
||||
(CASE WHEN featurecla LIKE 'Disputed%' THEN TRUE ELSE FALSE END) AS disputed,
|
||||
(CASE WHEN featurecla LIKE 'Disputed%' THEN 'ne110m_' || ogc_fid ELSE NULL::text END) AS disputed_name,
|
||||
NULL::text AS disputed_name,
|
||||
NULL::text AS claimed_by,
|
||||
FALSE AS maritime
|
||||
FROM ne_110m_admin_0_boundary_lines_land
|
||||
@@ -347,8 +334,10 @@ FROM ne_110m_admin_0_boundary_lines_land_gen_z0
|
||||
|
||||
-- etldoc: ne_50m_admin_0_boundary_lines_land_gen_z1 -> boundary_z1
|
||||
-- etldoc: ne_10m_admin_1_states_provinces_lines_gen_z1 -> boundary_z1
|
||||
-- etldoc: ne_10m_admin_0_boundary_lines_land_disputed -> boundary_z1
|
||||
-- etldoc: osm_border_disp_linestring_gen_z1 -> boundary_z1
|
||||
CREATE OR REPLACE VIEW boundary_z1 AS
|
||||
DROP MATERIALIZED VIEW IF EXISTS boundary_z1 CASCADE;
|
||||
CREATE MATERIALIZED VIEW boundary_z1 AS
|
||||
(
|
||||
SELECT geometry,
|
||||
admin_level,
|
||||
@@ -374,18 +363,21 @@ SELECT geometry,
|
||||
admin_level,
|
||||
NULL::text AS adm0_l,
|
||||
NULL::text AS adm0_r,
|
||||
TRUE AS disputed,
|
||||
edit_name(name) AS disputed_name,
|
||||
disputed,
|
||||
disputed_name,
|
||||
claimed_by,
|
||||
maritime
|
||||
FROM osm_border_disp_linestring_gen_z1
|
||||
FROM ne_10m_admin_0_boundary_lines_land_disputed
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS boundary_z1_idx ON boundary_z1 USING gist (geometry);
|
||||
|
||||
|
||||
-- etldoc: ne_50m_admin_0_boundary_lines_land_gen_z2 -> boundary_z2
|
||||
-- etldoc: ne_10m_admin_1_states_provinces_lines_gen_z2 -> boundary_z2
|
||||
-- etldoc: ne_10m_admin_0_boundary_lines_land_disputed -> boundary_z2
|
||||
-- etldoc: osm_border_disp_linestring_gen_z2 -> boundary_z2
|
||||
CREATE OR REPLACE VIEW boundary_z2 AS
|
||||
DROP MATERIALIZED VIEW IF EXISTS boundary_z2 CASCADE;
|
||||
CREATE MATERIALIZED VIEW boundary_z2 AS
|
||||
(
|
||||
SELECT geometry,
|
||||
admin_level,
|
||||
@@ -411,17 +403,20 @@ SELECT geometry,
|
||||
admin_level,
|
||||
NULL::text AS adm0_l,
|
||||
NULL::text AS adm0_r,
|
||||
TRUE AS disputed,
|
||||
edit_name(name) AS disputed_name,
|
||||
disputed,
|
||||
disputed_name,
|
||||
claimed_by,
|
||||
maritime
|
||||
FROM osm_border_disp_linestring_gen_z2
|
||||
FROM ne_10m_admin_0_boundary_lines_land_disputed
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS boundary_z2_idx ON boundary_z2 USING gist (geometry);
|
||||
|
||||
-- etldoc: ne_50m_admin_0_boundary_lines_land_gen_z3 -> boundary_z3
|
||||
-- etldoc: ne_10m_admin_1_states_provinces_lines_gen_z3 -> boundary_z3
|
||||
-- etldoc: ne_10m_admin_0_boundary_lines_land_disputed -> boundary_z3
|
||||
-- etldoc: osm_border_disp_linestring_gen_z3 -> boundary_z3
|
||||
CREATE OR REPLACE VIEW boundary_z3 AS
|
||||
DROP MATERIALIZED VIEW IF EXISTS boundary_z3 CASCADE;
|
||||
CREATE MATERIALIZED VIEW boundary_z3 AS
|
||||
(
|
||||
SELECT geometry,
|
||||
admin_level,
|
||||
@@ -447,17 +442,19 @@ SELECT geometry,
|
||||
admin_level,
|
||||
NULL::text AS adm0_l,
|
||||
NULL::text AS adm0_r,
|
||||
TRUE AS disputed,
|
||||
edit_name(name) AS disputed_name,
|
||||
disputed,
|
||||
disputed_name,
|
||||
claimed_by,
|
||||
maritime
|
||||
FROM osm_border_disp_linestring_gen_z3
|
||||
FROM ne_10m_admin_0_boundary_lines_land_disputed
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS boundary_z3_idx ON boundary_z3 USING gist (geometry);
|
||||
|
||||
-- etldoc: ne_10m_admin_0_boundary_lines_land_gen_z4 -> boundary_z4
|
||||
-- etldoc: ne_10m_admin_1_states_provinces_lines_gen_z4 -> boundary_z4
|
||||
-- etldoc: osm_border_linestring_gen_z4 -> boundary_z4
|
||||
CREATE OR REPLACE VIEW boundary_z4 AS
|
||||
DROP MATERIALIZED VIEW IF EXISTS boundary_z4 CASCADE;
|
||||
CREATE MATERIALIZED VIEW boundary_z4 AS
|
||||
(
|
||||
SELECT geometry,
|
||||
admin_level,
|
||||
@@ -489,6 +486,7 @@ SELECT geometry,
|
||||
maritime
|
||||
FROM osm_border_linestring_gen_z4
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS boundary_z4_idx ON boundary_z4 USING gist (geometry);
|
||||
|
||||
-- etldoc: osm_border_linestring_gen_z5 -> boundary_z5
|
||||
CREATE OR REPLACE VIEW boundary_z5 AS
|
||||
@@ -624,7 +622,7 @@ FROM osm_border_linestring_gen_z13
|
||||
);
|
||||
|
||||
-- etldoc: layer_boundary[shape=record fillcolor=lightpink, style="rounded,filled",
|
||||
-- etldoc: label="<sql> layer_boundary |<z0> z0 |<z1> z1 |<z2> z2 | <z3> z3 | <z4> z4 | <z5> z5 | <z6> z6 | <z7> z7 | <z8> z8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13+"]
|
||||
-- etldoc: label="<sql> layer_boundary |<z0> z0 |<z1> z1 |<z2> z2 | <z3> z3 | <z4> z4 | <z5> z5 | <z6> z6 | <z7> z7 | <z8> z8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14> z14+"]
|
||||
CREATE OR REPLACE FUNCTION layer_boundary(bbox geometry, zoom_level int)
|
||||
RETURNS TABLE
|
||||
(
|
||||
@@ -635,11 +633,14 @@ CREATE OR REPLACE FUNCTION layer_boundary(bbox geometry, zoom_level int)
|
||||
disputed int,
|
||||
disputed_name text,
|
||||
claimed_by text,
|
||||
maritime int
|
||||
maritime int,
|
||||
class text,
|
||||
name text,
|
||||
tags hstore
|
||||
)
|
||||
AS
|
||||
$$
|
||||
SELECT geometry, admin_level, adm0_l, adm0_r, disputed::int, disputed_name, claimed_by, maritime::int
|
||||
SELECT geometry, admin_level, adm0_l, adm0_r, disputed::int, disputed_name, claimed_by, maritime::int, NULL::text, NULL::text, NULL::hstore
|
||||
FROM (
|
||||
-- etldoc: boundary_z0 -> layer_boundary:z0
|
||||
SELECT *
|
||||
@@ -724,7 +725,134 @@ FROM (
|
||||
FROM boundary_z13
|
||||
WHERE geometry && bbox
|
||||
AND zoom_level >= 13
|
||||
) AS zoom_levels;
|
||||
) AS segment_zoom_levels
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT geometry, NULL::int, NULL::text, NULL::text, NULL::int, NULL::text, NULL::text, NULL::int, class, name, tags
|
||||
FROM (
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z4 -> layer_boundary:z4
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z4
|
||||
WHERE zoom_level = 4
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z5 -> layer_boundary:z5
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z5
|
||||
WHERE zoom_level = 5
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z6 -> layer_boundary:z6
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z6
|
||||
WHERE zoom_level = 6
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z7 -> layer_boundary:z7
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z7
|
||||
WHERE zoom_level = 7
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z8 -> layer_boundary:z8
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z8
|
||||
WHERE zoom_level = 8
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z9 -> layer_boundary:z9
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z9
|
||||
WHERE zoom_level = 9
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z10 -> layer_boundary:z10
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z10
|
||||
WHERE zoom_level = 10
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z11 -> layer_boundary:z11
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z11
|
||||
WHERE zoom_level = 11
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z12 -> layer_boundary:z12
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z12
|
||||
WHERE zoom_level = 12
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon_gen_z13 -> layer_boundary:z13
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon_gen_z13
|
||||
WHERE zoom_level = 13
|
||||
AND geometry && bbox
|
||||
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_boundary_polygon -> layer_boundary:z14
|
||||
SELECT geometry,
|
||||
boundary AS class,
|
||||
name,
|
||||
tags
|
||||
FROM osm_boundary_polygon
|
||||
WHERE zoom_level = 14
|
||||
AND geometry && bbox
|
||||
|
||||
) AS area_zoom_levels
|
||||
|
||||
$$ LANGUAGE SQL STABLE
|
||||
-- STRICT
|
||||
PARALLEL SAFE;
|
||||
|
||||
@@ -9,13 +9,17 @@ layer:
|
||||
- ne_50m_admin_0_boundary_lines_land
|
||||
- ne_110m_admin_0_boundary_lines_land
|
||||
description: |
|
||||
Contains administrative boundaries as linestrings.
|
||||
Contains administrative boundaries as linestrings and aboriginal lands as polygons.
|
||||
Until z4 [Natural Earth data](http://www.naturalearthdata.com/downloads/) is used after which
|
||||
OSM boundaries ([`boundary=administrative`](http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative))
|
||||
are present from z5 to z14 (also for maritime boundaries with `admin_level <= 2` at z4).
|
||||
OSM data contains several [`admin_level`](http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative#admin_level)
|
||||
but for most styles it makes sense to just style `admin_level=2` and `admin_level=4`.
|
||||
fields:
|
||||
class:
|
||||
description: |
|
||||
Use the **class** to differentiate between different kinds of boundaries. The class for `boundary=aboriginal_lands` is `aboriginal_lands`.
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value (area features only).
|
||||
admin_level: |
|
||||
OSM [admin_level](http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative#admin_level)
|
||||
indicating the level of importance of this boundary.
|
||||
@@ -58,8 +62,9 @@ layer:
|
||||
buffer_size: 4
|
||||
datasource:
|
||||
geometry_field: geometry
|
||||
query: (SELECT geometry, admin_level, adm0_l, adm0_r, disputed, disputed_name, claimed_by, maritime FROM layer_boundary(!bbox!, z(!scale_denominator!))) AS t
|
||||
query: (SELECT geometry, admin_level, adm0_l, adm0_r, disputed, disputed_name, claimed_by, maritime, class, name, {name_languages} FROM layer_boundary(!bbox!, z(!scale_denominator!))) AS t
|
||||
schema:
|
||||
- ./update_boundary_polygon.sql
|
||||
- ./boundary_name.sql
|
||||
- ./boundary.sql
|
||||
datasources:
|
||||
|
||||
|
Before Width: | Height: | Size: 552 KiB After Width: | Height: | Size: 750 KiB |
@@ -4,6 +4,67 @@ generalized_tables:
|
||||
source: border_linestring
|
||||
sql_filter: ST_GeometryType(geometry) = 'ST_LineString' AND (disputed OR dispute OR border_status = 'disputed' OR disputed_by <> '') AND admin_level = 2
|
||||
|
||||
# etldoc: osm_boundary_polygon_gen_z5 -> osm_boundary_polygon_gen_z4
|
||||
boundary_polygon_gen_z4:
|
||||
source: boundary_polygon_gen_z5
|
||||
sql_filter: area>power(ZRES3,2)
|
||||
tolerance: ZRES4
|
||||
|
||||
# etldoc: osm_boundary_polygon_gen_z6 -> osm_boundary_polygon_gen_z5
|
||||
boundary_polygon_gen_z5:
|
||||
source: boundary_polygon_gen_z6
|
||||
sql_filter: area>power(ZRES4,2)
|
||||
tolerance: ZRES5
|
||||
|
||||
# etldoc: osm_boundary_polygon_gen_z7 -> osm_boundary_polygon_gen_z6
|
||||
boundary_polygon_gen_z6:
|
||||
source: boundary_polygon_gen_z7
|
||||
sql_filter: area>power(ZRES5,2)
|
||||
tolerance: ZRES6
|
||||
|
||||
# etldoc: osm_boundary_polygon_gen_z8 -> osm_boundary_polygon_gen_z7
|
||||
boundary_polygon_gen_z7:
|
||||
source: boundary_polygon_gen_z8
|
||||
sql_filter: area>power(ZRES6,2)
|
||||
tolerance: ZRES7
|
||||
|
||||
# etldoc: osm_boundary_polygon_gen_z9 -> osm_boundary_polygon_gen_z8
|
||||
boundary_polygon_gen_z8:
|
||||
source: boundary_polygon_gen_z9
|
||||
sql_filter: area>power(ZRES7,2)
|
||||
tolerance: ZRES8
|
||||
|
||||
# etldoc: osm_boundary_polygon_gen_z10 -> osm_boundary_polygon_gen_z9
|
||||
boundary_polygon_gen_z9:
|
||||
source: boundary_polygon_gen_z10
|
||||
sql_filter: area>power(ZRES8,2)
|
||||
tolerance: ZRES9
|
||||
|
||||
# etldoc: osm_boundary_polygon_gen_z11 -> osm_boundary_polygon_gen_z10
|
||||
boundary_polygon_gen_z10:
|
||||
source: boundary_polygon_gen_z11
|
||||
sql_filter: area>power(ZRES9,2)
|
||||
tolerance: ZRES10
|
||||
|
||||
# etldoc: osm_boundary_polygon_gen_z12 -> osm_boundary_polygon_gen_z11
|
||||
boundary_polygon_gen_z11:
|
||||
source: boundary_polygon_gen_z12
|
||||
sql_filter: area>power(ZRES10,2)
|
||||
tolerance: ZRES11
|
||||
|
||||
# etldoc: osm_boundary_polygon_gen_z13 -> osm_boundary_polygon_gen_z12
|
||||
boundary_polygon_gen_z12:
|
||||
source: boundary_polygon_gen_z13
|
||||
sql_filter: area>power(ZRES11,2)
|
||||
tolerance: ZRES12
|
||||
|
||||
# etldoc: osm_boundary_polygon -> osm_boundary_polygon_gen_z13
|
||||
boundary_polygon_gen_z13:
|
||||
source: boundary_polygon
|
||||
sql_filter: area>power(ZRES12,2) AND ST_IsValid(geometry)
|
||||
tolerance: ZRES13
|
||||
|
||||
|
||||
tables:
|
||||
# etldoc: imposm3 -> osm_border_linestring
|
||||
border_linestring:
|
||||
@@ -78,6 +139,32 @@ tables:
|
||||
boundary_type:
|
||||
- maritime
|
||||
|
||||
# etldoc: imposm3 -> osm_boundary_polygon
|
||||
boundary_polygon:
|
||||
type: polygon
|
||||
filters:
|
||||
require:
|
||||
type: [boundary]
|
||||
boundary: [aboriginal_lands]
|
||||
columns:
|
||||
- name: osm_id
|
||||
type: id
|
||||
- name: geometry
|
||||
type: validated_geometry
|
||||
- name: name
|
||||
key: name
|
||||
type: string
|
||||
- name: tags
|
||||
type: hstore_tags
|
||||
- name: boundary
|
||||
key: boundary
|
||||
type: string
|
||||
- name: area
|
||||
type: area
|
||||
mapping:
|
||||
boundary:
|
||||
- aboriginal_lands
|
||||
|
||||
|
||||
# etldoc: imposm3 -> osm_border_disp_relation
|
||||
border_disp_relation:
|
||||
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 22 KiB |
170
layers/boundary/update_boundary_polygon.sql
Normal file
@@ -0,0 +1,170 @@
|
||||
ALTER TABLE osm_boundary_polygon
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
ALTER TABLE osm_boundary_polygon_gen_z13
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
ALTER TABLE osm_boundary_polygon_gen_z12
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
ALTER TABLE osm_boundary_polygon_gen_z11
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
ALTER TABLE osm_boundary_polygon_gen_z10
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
ALTER TABLE osm_boundary_polygon_gen_z9
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
ALTER TABLE osm_boundary_polygon_gen_z8
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
ALTER TABLE osm_boundary_polygon_gen_z7
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
ALTER TABLE osm_boundary_polygon_gen_z6
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
ALTER TABLE osm_boundary_polygon_gen_z5
|
||||
ADD COLUMN IF NOT EXISTS geometry_point geometry;
|
||||
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon_gen_z13;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon_gen_z12;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon_gen_z11;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon_gen_z10;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon_gen_z9;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon_gen_z8;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon_gen_z7;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon_gen_z6;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_boundary_polygon_gen_z5;
|
||||
|
||||
-- etldoc: osm_boundary_polygon -> osm_boundary_polygon
|
||||
-- etldoc: osm_boundary_polygon_gen_z13 -> osm_boundary_polygon_gen_z13
|
||||
-- etldoc: osm_boundary_polygon_gen_z12 -> osm_boundary_polygon_gen_z12
|
||||
-- etldoc: osm_boundary_polygon_gen_z11 -> osm_boundary_polygon_gen_z11
|
||||
-- etldoc: osm_boundary_polygon_gen_z10 -> osm_boundary_polygon_gen_z10
|
||||
-- etldoc: osm_boundary_polygon_gen_z9 -> osm_boundary_polygon_gen_z9
|
||||
-- etldoc: osm_boundary_polygon_gen_z8 -> osm_boundary_polygon_gen_z8
|
||||
-- etldoc: osm_boundary_polygon_gen_z7 -> osm_boundary_polygon_gen_z7
|
||||
-- etldoc: osm_boundary_polygon_gen_z6 -> osm_boundary_polygon_gen_z6
|
||||
-- etldoc: osm_boundary_polygon_gen_z5 -> osm_boundary_polygon_gen_z5
|
||||
CREATE OR REPLACE FUNCTION update_osm_boundary_polygon() RETURNS void AS
|
||||
$$
|
||||
BEGIN
|
||||
UPDATE osm_boundary_polygon
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_boundary_polygon_gen_z13
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_boundary_polygon_gen_z12
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_boundary_polygon_gen_z11
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_boundary_polygon_gen_z10
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_boundary_polygon_gen_z9
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_boundary_polygon_gen_z8
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_boundary_polygon_gen_z7
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_boundary_polygon_gen_z6
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_boundary_polygon_gen_z5
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
SELECT update_osm_boundary_polygon();
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_point_geom_idx ON osm_boundary_polygon USING gist (geometry_point);
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_gen_z13_point_geom_idx ON osm_boundary_polygon_gen_z13 USING gist (geometry_point);
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_gen_z12_point_geom_idx ON osm_boundary_polygon_gen_z12 USING gist (geometry_point);
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_gen_z11_point_geom_idx ON osm_boundary_polygon_gen_z11 USING gist (geometry_point);
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_gen_z10_point_geom_idx ON osm_boundary_polygon_gen_z10 USING gist (geometry_point);
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_gen_z9_point_geom_idx ON osm_boundary_polygon_gen_z9 USING gist (geometry_point);
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_gen_z8_point_geom_idx ON osm_boundary_polygon_gen_z8 USING gist (geometry_point);
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_gen_z7_point_geom_idx ON osm_boundary_polygon_gen_z7 USING gist (geometry_point);
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_gen_z6_point_geom_idx ON osm_boundary_polygon_gen_z6 USING gist (geometry_point);
|
||||
CREATE INDEX IF NOT EXISTS osm_boundary_polygon_gen_z5_point_geom_idx ON osm_boundary_polygon_gen_z5 USING gist (geometry_point);
|
||||
|
||||
CREATE OR REPLACE FUNCTION update_osm_boundary_polygon_row()
|
||||
RETURNS trigger
|
||||
AS
|
||||
$$
|
||||
BEGIN
|
||||
NEW.tags = update_tags(NEW.tags, NEW.geometry);
|
||||
NEW.geometry_point = ST_PointOnSurface(NEW.geometry);
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon_gen_z13
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon_gen_z12
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon_gen_z11
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon_gen_z10
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon_gen_z9
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon_gen_z8
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon_gen_z7
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon_gen_z6
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
|
||||
CREATE TRIGGER update_row
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON osm_boundary_polygon_gen_z5
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE update_osm_boundary_polygon_row();
|
||||
@@ -14,7 +14,7 @@ SELECT
|
||||
-- etldoc: osm_housenumber_point -> layer_housenumber:z14_
|
||||
osm_id,
|
||||
geometry,
|
||||
housenumber
|
||||
display_housenumber(housenumber)
|
||||
FROM (
|
||||
SELECT
|
||||
osm_id,
|
||||
|
||||
@@ -7,12 +7,14 @@ layer:
|
||||
buffer_size: 8
|
||||
srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
|
||||
fields:
|
||||
housenumber: Value of the [`addr:housenumber`](http://wiki.openstreetmap.org/wiki/Key:addr) tag.
|
||||
housenumber: Value of the [`addr:housenumber`](http://wiki.openstreetmap.org/wiki/Key:addr) tag.
|
||||
If there are multiple values separated by semi-colons, the first and last value separated by a dash.
|
||||
datasource:
|
||||
geometry_field: geometry
|
||||
srid: 900913
|
||||
query: (SELECT geometry, housenumber FROM layer_housenumber(!bbox!, z(!scale_denominator!))) AS t
|
||||
schema:
|
||||
- ./housenumber_display.sql
|
||||
- ./housenumber_centroid.sql
|
||||
- ./housenumber.sql
|
||||
datasources:
|
||||
|
||||
@@ -86,12 +86,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_housenumber_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE housenumber.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_housenumber_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE housenumber.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
20
layers/housenumber/housenumber_display.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
CREATE OR REPLACE FUNCTION display_housenumber_nonnumeric(raw_housenumber text)
|
||||
RETURNS text AS $$
|
||||
-- Find the position of the semicolon in the input string
|
||||
-- and extract the first and last value
|
||||
SELECT substring(raw_housenumber from 1 for position(';' in raw_housenumber) - 1)
|
||||
|| '–'
|
||||
|| substring(raw_housenumber from position(';' in raw_housenumber) + 1);
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION display_housenumber(raw_housenumber text)
|
||||
RETURNS text AS $$
|
||||
SELECT CASE
|
||||
WHEN raw_housenumber !~ ';' THEN raw_housenumber
|
||||
WHEN raw_housenumber ~ '[^0-9;]' THEN display_housenumber_nonnumeric(raw_housenumber)
|
||||
ELSE
|
||||
(SELECT min(value)::text || '–' || max(value)::text
|
||||
FROM unnest(array_remove(string_to_array(raw_housenumber, ';'), '')::bigint[]) AS value)
|
||||
END
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
@@ -26,7 +26,7 @@ layer:
|
||||
rock:
|
||||
subclass: ['bare_rock', 'scree']
|
||||
grass:
|
||||
subclass: ['fell', 'grassland', 'heath', 'scrub', 'shrubbery', 'tundra', 'grass', 'meadow', 'allotments', 'park', 'village_green', 'recreation_ground', 'garden', 'golf_course']
|
||||
subclass: ['fell', 'flowerbed', 'grassland', 'heath', 'scrub', 'shrubbery', 'tundra', 'grass', 'meadow', 'allotments', 'park', 'village_green', 'recreation_ground', 'garden', 'golf_course']
|
||||
wetland:
|
||||
subclass: ['wetland', 'bog', 'swamp', 'wet_meadow', 'marsh', 'reedbed', 'saltern', 'tidalflat', 'saltmarsh', 'mangrove']
|
||||
sand:
|
||||
@@ -50,6 +50,7 @@ layer:
|
||||
- farm
|
||||
- farmland
|
||||
- fell
|
||||
- flowerbed
|
||||
- forest
|
||||
- garden
|
||||
- glacier
|
||||
|
||||
@@ -18,6 +18,7 @@ tables:
|
||||
- farm
|
||||
- farmland
|
||||
- orchard
|
||||
- flowerbed
|
||||
- plant_nursery
|
||||
- vineyard
|
||||
- grass
|
||||
|
||||
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 68 KiB |
@@ -137,6 +137,8 @@
|
||||
"#f5dcba",
|
||||
"farmland",
|
||||
"#eef0d5",
|
||||
"flowerbed",
|
||||
"#cdebb0",
|
||||
"forest",
|
||||
"#add19e",
|
||||
"grass",
|
||||
@@ -201,6 +203,7 @@
|
||||
"scrub",
|
||||
"farm",
|
||||
"farmland",
|
||||
"flowerbed",
|
||||
"forest",
|
||||
"garden",
|
||||
"grass",
|
||||
@@ -275,6 +278,8 @@
|
||||
"wetland_bog",
|
||||
"scrub",
|
||||
"scrub",
|
||||
"flowerbed",
|
||||
"flowerbed_high_zoom",
|
||||
"forest",
|
||||
"leaftype_unknown",
|
||||
"garden",
|
||||
@@ -320,6 +325,7 @@
|
||||
"scrub",
|
||||
"farm",
|
||||
"farmland",
|
||||
"flowerbed",
|
||||
"forest",
|
||||
"garden",
|
||||
"grass",
|
||||
|
||||
@@ -55,9 +55,9 @@ SELECT
|
||||
FROM (
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
name,
|
||||
COALESCE(NULLIF(name_en, ''), name) AS name_en,
|
||||
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
||||
NULLIF(name, '') as name,
|
||||
COALESCE(NULLIF(name_en, ''), NULLIF(name, '')) AS name_en,
|
||||
COALESCE(NULLIF(name_de, ''), NULLIF(name, ''), NULLIF(name_en, '')) AS name_de,
|
||||
tags,
|
||||
substring(ele FROM E'^(-?\\d+)(\\D|$)')::int AS ele,
|
||||
round(substring(ele FROM E'^(-?\\d+)(\\D|$)')::int * 3.2808399)::int AS ele_ft,
|
||||
@@ -65,15 +65,17 @@ FROM (
|
||||
row_number() OVER (
|
||||
PARTITION BY LabelGrid(geometry, 100 * pixel_width)
|
||||
ORDER BY (
|
||||
substring(ele FROM E'^(-?\\d+)(\\D|$)')::int +
|
||||
(CASE WHEN ele <> '' THEN substring(ele FROM E'^(-?\\d+)(\\D|$)')::int ELSE 0 END) +
|
||||
(CASE WHEN wikipedia <> '' THEN 10000 ELSE 0 END) +
|
||||
(CASE WHEN name <> '' THEN 10000 ELSE 0 END)
|
||||
) DESC
|
||||
)::int AS "rank"
|
||||
FROM peak_point
|
||||
WHERE geometry && bbox
|
||||
AND ele IS NOT NULL
|
||||
AND ele ~ E'^-?\\d{1,4}(\\D|$)'
|
||||
AND (
|
||||
(ele <> '' AND ele ~ E'^-?\\d{1,4}(\\D|$)')
|
||||
OR name <> ''
|
||||
)
|
||||
) AS ranked_peaks
|
||||
WHERE zoom_level >= 7
|
||||
AND (rank <= 5 OR zoom_level >= 14)
|
||||
|
||||
@@ -8,9 +8,9 @@ layer:
|
||||
buffer_size: 64
|
||||
srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
|
||||
fields:
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the peak.
|
||||
name_en: English name `name:en` if available, otherwise `name`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the peak. Language-specific values are in `name:xx`.
|
||||
name_en: English name `name:en` if available, otherwise `name`. This is deprecated and will be removed in a future release in favor of `name:en`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`. This is deprecated and will be removed in a future release in favor of `name:de`.
|
||||
class:
|
||||
description: |
|
||||
Use the **class** to differentiate between natural objects.
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
"source": "openmaptiles",
|
||||
"source-layer": "mountain_peak",
|
||||
"maxzoom": 16,
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"!in",
|
||||
"class",
|
||||
"cliff",
|
||||
"volcano"
|
||||
]
|
||||
],
|
||||
"layout": {
|
||||
"text-size": 10,
|
||||
"icon-image": "peak",
|
||||
@@ -38,15 +47,55 @@
|
||||
"text-halo-color": "rgba(255, 255, 255, .8)",
|
||||
"text-halo-width": 1
|
||||
},
|
||||
"order": 197
|
||||
},
|
||||
{
|
||||
"id": "mountain_peak_volcano",
|
||||
"type": "symbol",
|
||||
"source": "openmaptiles",
|
||||
"source-layer": "mountain_peak",
|
||||
"maxzoom": 16,
|
||||
"filter": [
|
||||
"all",
|
||||
[
|
||||
"!=",
|
||||
"==",
|
||||
"class",
|
||||
"cliff"
|
||||
"volcano"
|
||||
]
|
||||
],
|
||||
"order": 192
|
||||
"layout": {
|
||||
"text-size": 10,
|
||||
"icon-image": "volcano",
|
||||
"text-field": {
|
||||
"stops": [
|
||||
[
|
||||
6,
|
||||
" "
|
||||
],
|
||||
[
|
||||
12,
|
||||
"{name} {ele}m"
|
||||
]
|
||||
]
|
||||
},
|
||||
"text-anchor": "top",
|
||||
"text-offset": [
|
||||
0,
|
||||
0.5
|
||||
],
|
||||
"text-max-width": 6,
|
||||
"text-line-height": 1.1,
|
||||
"text-font": [
|
||||
"Noto Sans Regular",
|
||||
"Noto Sans Italic"
|
||||
]
|
||||
},
|
||||
"paint": {
|
||||
"text-color": "#d40000",
|
||||
"text-halo-color": "rgba(255, 255, 255, .8)",
|
||||
"text-halo-width": 1
|
||||
},
|
||||
"order": 198
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -71,12 +71,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_mountain_linestring
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE mountain_linestring.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_mountain_linestring
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE mountain_linestring.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -71,12 +71,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_peak_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE mountain_peak_point.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_peak_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE mountain_peak_point.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -101,4 +101,3 @@ tables:
|
||||
boundary:
|
||||
- national_park
|
||||
- protected_area
|
||||
- aboriginal_lands
|
||||
|
||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@@ -26,12 +26,11 @@ SELECT osm_id,
|
||||
FROM (
|
||||
SELECT osm_id,
|
||||
geometry,
|
||||
CASE WHEN boundary='aboriginal_lands' THEN 'aboriginal_lands'
|
||||
ELSE COALESCE(
|
||||
LOWER(REPLACE(NULLIF(protection_title, ''), ' ', '_')),
|
||||
NULLIF(boundary, ''),
|
||||
NULLIF(leisure, '')
|
||||
) END AS class,
|
||||
COALESCE(
|
||||
LOWER(REPLACE(NULLIF(protection_title, ''), ' ', '_')),
|
||||
NULLIF(boundary, ''),
|
||||
NULLIF(leisure, ''))
|
||||
AS class,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
@@ -46,7 +45,7 @@ FROM (
|
||||
NULL AS name_de,
|
||||
NULL AS tags,
|
||||
NULL AS leisure,
|
||||
CASE WHEN boundary='aboriginal_lands' THEN boundary END AS boundary,
|
||||
NULL AS boundary,
|
||||
NULL AS protection_title
|
||||
FROM osm_park_polygon_dissolve_z4
|
||||
WHERE zoom_level = 4
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
layer:
|
||||
id: "park"
|
||||
description: |
|
||||
The park layer contains parks from OpenStreetMap tagged with
|
||||
[`boundary=national_park`](http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dnational_park),
|
||||
[`boundary=protected_area`](http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dprotected_area),
|
||||
or [`leisure=nature_reserve`](http://wiki.openstreetmap.org/wiki/Tag:leisure%3Dnature_reserve).
|
||||
The park layer in OpenMapTiles contains natural and protected areas from OpenStreetMap,
|
||||
such as parks tagged with [`boundary=national_park`](https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dnational_park),
|
||||
[`boundary=protected_area`](https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dprotected_area),
|
||||
or [`leisure=nature_reserve`](https://wiki.openstreetmap.org/wiki/Tag:leisure%3Dnature_reserve).
|
||||
buffer_size: 4
|
||||
fields:
|
||||
class:
|
||||
description: |
|
||||
Use the **class** to differentiate between different parks.
|
||||
The class for `boundary=protected_area` parks is the lower-case of the
|
||||
[`protection_title`](http://wiki.openstreetmap.org/wiki/key:protection_title)
|
||||
value with blanks replaced by `_`.
|
||||
`national_park` is the class of `protection_title=National Park` and `boundary=national_park`.
|
||||
`nature_reserve` is the class of `protection_title=Nature Reserve` and `leisure=nature_reserve`.
|
||||
The class for other [`protection_title`](http://wiki.openstreetmap.org/wiki/key:protection_title)
|
||||
values is similarly assigned.
|
||||
The class for `boundary=aboriginal_lands` is `aboriginal_lands`.
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the park (point features only).
|
||||
name_en: English name `name:en` if available, otherwise `name` (point features only).
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en` (point features only).
|
||||
Use the **class** to differentiate between different kinds of features in the `parks` layer.
|
||||
The class for `boundary=protected_area` parks is the lower-case of the
|
||||
[`protection_title`](http://wiki.openstreetmap.org/wiki/key:protection_title)
|
||||
value with blanks replaced by `_`.
|
||||
`national_park` is the class of `protection_title=National Park` and `boundary=national_park`.
|
||||
`nature_reserve` is the class of `protection_title=Nature Reserve` and `leisure=nature_reserve`.
|
||||
The class for other [`protection_title`](http://wiki.openstreetmap.org/wiki/key:protection_title)
|
||||
values is similarly assigned.
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the park (point features only). Language-specific values are in `name:xx`.
|
||||
name_en: English name `name:en` if available, otherwise `name` (point features only). This is deprecated and will be removed in a future release in favor of `name:en`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en` (point features only). This is deprecated and will be removed in a future release in favor of `name:de`.
|
||||
rank: Rank of the park within one tile, starting at 1 that is the most important park (point features only).
|
||||
datasource:
|
||||
geometry_field: geometry
|
||||
|
||||
@@ -48,8 +48,8 @@ DROP TRIGGER IF EXISTS update_row ON osm_park_polygon_gen_z7;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_park_polygon_gen_z6;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_park_polygon_gen_z5;
|
||||
DROP TRIGGER IF EXISTS update_row ON osm_park_polygon_gen_z4;
|
||||
DROP TRIGGER IF EXISTS tigger_flag ON osm_park_polygon;
|
||||
DROP TRIGGER IF EXISTS tigger_refresh ON park_polygon.updates;
|
||||
DROP TRIGGER IF EXISTS trigger_flag ON osm_park_polygon;
|
||||
DROP TRIGGER IF EXISTS trigger_refresh ON park_polygon.updates;
|
||||
|
||||
-- etldoc: osm_park_polygon -> osm_park_polygon
|
||||
-- etldoc: osm_park_polygon_gen_z13 -> osm_park_polygon_gen_z13
|
||||
@@ -67,43 +67,43 @@ $$
|
||||
BEGIN
|
||||
UPDATE osm_park_polygon
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_park_polygon_gen_z13
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_park_polygon_gen_z12
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_park_polygon_gen_z11
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_park_polygon_gen_z10
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_park_polygon_gen_z9
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_park_polygon_gen_z8
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_park_polygon_gen_z7
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_park_polygon_gen_z6
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
UPDATE osm_park_polygon_gen_z5
|
||||
SET tags = update_tags(tags, geometry),
|
||||
geometry_point = st_centroid(geometry);
|
||||
geometry_point = ST_PointOnSurface(geometry);
|
||||
|
||||
REFRESH MATERIALIZED VIEW CONCURRENTLY osm_park_polygon_dissolve_z4;
|
||||
END;
|
||||
@@ -149,7 +149,7 @@ BEGIN
|
||||
|
||||
-- Analyze tracking and source tables before performing update
|
||||
ANALYZE osm_park_polygon_gen_z4;
|
||||
REFRESH MATERIALIZED VIEW osm_park_polygon_dissolve_z4;
|
||||
REFRESH MATERIALIZED VIEW CONCURRENTLY osm_park_polygon_dissolve_z4;
|
||||
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM park_polygon.updates;
|
||||
@@ -165,7 +165,7 @@ AS
|
||||
$$
|
||||
BEGIN
|
||||
NEW.tags = update_tags(NEW.tags, NEW.geometry);
|
||||
NEW.geometry_point = st_centroid(NEW.geometry);
|
||||
NEW.geometry_point = ST_PointOnSurface(NEW.geometry);
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
@@ -248,7 +248,7 @@ EXECUTE PROCEDURE update_osm_park_dissolved_polygon_row();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON osm_park_polygon_gen_z4
|
||||
ON osm_park_polygon
|
||||
FOR EACH STATEMENT
|
||||
EXECUTE PROCEDURE park_polygon.flag();
|
||||
|
||||
|
||||
14
layers/place/area_rank.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
CREATE OR REPLACE FUNCTION area_rank(area real) RETURNS int AS
|
||||
$$
|
||||
SELECT CASE
|
||||
WHEN area > 640000000 THEN 1
|
||||
WHEN area > 160000000 THEN 2
|
||||
WHEN area > 40000000 THEN 3
|
||||
WHEN area > 15000000 THEN 4
|
||||
WHEN area > 10000000 THEN 5
|
||||
WHEN area > 0 THEN 6
|
||||
ELSE 7
|
||||
END;
|
||||
$$ LANGUAGE SQL IMMUTABLE
|
||||
STRICT
|
||||
PARALLEL SAFE;
|
||||
|
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 152 KiB |
@@ -1,12 +0,0 @@
|
||||
CREATE OR REPLACE FUNCTION island_rank(area real) RETURNS int AS
|
||||
$$
|
||||
SELECT CASE
|
||||
WHEN area < 10000000 THEN 6
|
||||
WHEN area BETWEEN 1000000 AND 15000000 THEN 5
|
||||
WHEN area BETWEEN 15000000 AND 40000000 THEN 4
|
||||
WHEN area > 40000000 THEN 3
|
||||
ELSE 7
|
||||
END;
|
||||
$$ LANGUAGE SQL IMMUTABLE
|
||||
STRICT
|
||||
PARALLEL SAFE;
|
||||
@@ -109,17 +109,39 @@ FROM (
|
||||
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
|
||||
tags,
|
||||
'island' AS class,
|
||||
island_rank(area) AS "rank",
|
||||
area_rank(area) AS "rank",
|
||||
NULL::int AS capital,
|
||||
NULL::text AS iso_a2
|
||||
FROM osm_island_polygon
|
||||
WHERE geometry && bbox
|
||||
AND ((zoom_level = 8 AND island_rank(area) <= 3)
|
||||
OR (zoom_level = 9 AND island_rank(area) <= 4)
|
||||
AND ((zoom_level = 8 AND area_rank(area) <= 3)
|
||||
OR (zoom_level = 9 AND area_rank(area) <= 4)
|
||||
OR (zoom_level >= 10))
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
-- etldoc: osm_boundary_polygon -> layer_place:z6_11
|
||||
-- etldoc: osm_boundary_polygon -> layer_place:z12_14
|
||||
osm_id * 10 AS osm_id,
|
||||
geometry_point,
|
||||
name,
|
||||
NULL::text AS name_en, -- deprecated
|
||||
NULL::text AS name_de, -- deprecated
|
||||
tags,
|
||||
'aboriginal_lands' AS class,
|
||||
area_rank(area) AS "rank",
|
||||
NULL::int AS capital,
|
||||
NULL::text AS iso_a2
|
||||
FROM osm_boundary_polygon
|
||||
WHERE geometry_point && bbox
|
||||
AND ((zoom_level = 6 AND area_rank(area) <= 1)
|
||||
OR (zoom_level = 7 AND area_rank(area) <= 2)
|
||||
OR (zoom_level = 8 AND area_rank(area) <= 3)
|
||||
OR (zoom_level = 9 AND area_rank(area) <= 4)
|
||||
OR (zoom_level >= 10))
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
-- etldoc: layer_city -> layer_place:z0_3
|
||||
-- etldoc: layer_city -> layer_place:z4_7
|
||||
|
||||
@@ -5,6 +5,8 @@ layer:
|
||||
- ne_10m_admin_1_states_provinces
|
||||
- ne_10m_admin_0_countries
|
||||
- ne_10m_populated_places
|
||||
layers:
|
||||
- boundary
|
||||
description: |
|
||||
The place layer consists out of [countries](http://wiki.openstreetmap.org/wiki/Tag:place%3Dcountry),
|
||||
[states](http://wiki.openstreetmap.org/wiki/Tag:place%3Dstate), [cities](http://wiki.openstreetmap.org/wiki/Key:place)
|
||||
@@ -12,9 +14,9 @@ layer:
|
||||
Apart from the roads this is also one of the more important layers to create a beautiful map.
|
||||
We suggest you use different font styles and sizes to create a text hierarchy.
|
||||
fields:
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the POI.
|
||||
name_en: English name `name:en` if available, otherwise `name`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the place. Language-specific values are in `name:xx`.
|
||||
name_en: English name `name:en` if available, otherwise `name`. This is deprecated and will be removed in a future release in favor of `name:en`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`. This is deprecated and will be removed in a future release in favor of `name:de`.
|
||||
capital:
|
||||
description: |
|
||||
The **capital** field marks the
|
||||
@@ -28,7 +30,9 @@ layer:
|
||||
Distinguish between continents, countries, states, islands and
|
||||
places like settlements or smaller entities.
|
||||
Use **class** to separately style the different places and build
|
||||
a text hierarchy according to their importance.
|
||||
a text hierarchy according to their importance. For places derived
|
||||
from boundaries, the original value of the
|
||||
[`boundary`](http://wiki.openstreetmap.org/wiki/Key:boundary) tag.
|
||||
values:
|
||||
- continent
|
||||
- country
|
||||
@@ -44,6 +48,7 @@ layer:
|
||||
- neighbourhood
|
||||
- isolated_dwelling
|
||||
- island
|
||||
- aboriginal_lands
|
||||
iso_a2:
|
||||
description: |
|
||||
Two-letter country code [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). Available only for `class=country`.
|
||||
@@ -75,7 +80,7 @@ schema:
|
||||
- ./types.sql
|
||||
- ./capital.sql
|
||||
- ./city.sql
|
||||
- ./island_rank.sql
|
||||
- ./area_rank.sql
|
||||
- ./update_continent_point.sql
|
||||
- ./update_country_point.sql
|
||||
- ./update_island_polygon.sql
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
"village"
|
||||
]
|
||||
],
|
||||
"order": 193
|
||||
"order": 199
|
||||
},
|
||||
{
|
||||
"id": "place_town",
|
||||
@@ -177,7 +177,7 @@
|
||||
"town"
|
||||
]
|
||||
],
|
||||
"order": 194
|
||||
"order": 200
|
||||
},
|
||||
{
|
||||
"id": "place_state",
|
||||
@@ -228,7 +228,7 @@
|
||||
3
|
||||
]
|
||||
],
|
||||
"order": 195
|
||||
"order": 201
|
||||
},
|
||||
{
|
||||
"id": "place_city",
|
||||
@@ -311,7 +311,7 @@
|
||||
1
|
||||
]
|
||||
],
|
||||
"order": 196
|
||||
"order": 202
|
||||
},
|
||||
{
|
||||
"id": "place_capital",
|
||||
@@ -396,7 +396,7 @@
|
||||
2
|
||||
]
|
||||
],
|
||||
"order": 197
|
||||
"order": 203
|
||||
},
|
||||
{
|
||||
"id": "country_other",
|
||||
@@ -449,7 +449,7 @@
|
||||
"iso_a2"
|
||||
]
|
||||
],
|
||||
"order": 198
|
||||
"order": 204
|
||||
},
|
||||
{
|
||||
"id": "country_3",
|
||||
@@ -518,7 +518,7 @@
|
||||
"iso_a2"
|
||||
]
|
||||
],
|
||||
"order": 199
|
||||
"order": 205
|
||||
},
|
||||
{
|
||||
"id": "country_2",
|
||||
@@ -587,7 +587,7 @@
|
||||
"iso_a2"
|
||||
]
|
||||
],
|
||||
"order": 200
|
||||
"order": 206
|
||||
},
|
||||
{
|
||||
"id": "country_1",
|
||||
@@ -656,7 +656,7 @@
|
||||
"iso_a2"
|
||||
]
|
||||
],
|
||||
"order": 201
|
||||
"order": 207
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -49,8 +49,6 @@ $$ LANGUAGE SQL;
|
||||
|
||||
SELECT update_osm_city_point(true);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_city_point_rank_idx ON osm_city_point ("rank");
|
||||
|
||||
-- Handle updates
|
||||
|
||||
CREATE OR REPLACE FUNCTION place_city.store() RETURNS trigger AS
|
||||
@@ -101,12 +99,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_city_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_city.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_city_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_city.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -71,12 +71,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_continent_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_continent_point.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_continent_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_continent_point.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -98,8 +98,6 @@ $$ LANGUAGE SQL;
|
||||
|
||||
SELECT update_osm_country_point(true);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_country_point_rank_idx ON osm_country_point ("rank");
|
||||
|
||||
-- Handle updates
|
||||
|
||||
CREATE OR REPLACE FUNCTION place_country.store() RETURNS trigger AS
|
||||
@@ -150,12 +148,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_country_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_country.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_country_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_country.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -71,12 +71,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_island_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_island_point.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_island_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_island_point.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -78,12 +78,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_island_polygon
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_island_polygon.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_island_polygon
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_island_polygon.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -60,8 +60,6 @@ $$ LANGUAGE SQL;
|
||||
|
||||
SELECT update_osm_state_point(true);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_state_point_rank_idx ON osm_state_point ("rank");
|
||||
|
||||
-- Handle updates
|
||||
|
||||
CREATE OR REPLACE FUNCTION place_state.store() RETURNS trigger AS
|
||||
@@ -112,12 +110,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_state_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_state.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_state_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE place_state.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -76,6 +76,8 @@ CREATE OR REPLACE FUNCTION poi_class(subclass text, mapping_key text, subtype te
|
||||
RETURNS text AS
|
||||
$$
|
||||
SELECT CASE
|
||||
-- Special case subclass collision between office=university and amenity=university
|
||||
WHEN mapping_key = 'amenity' AND subclass = 'university' THEN 'college'
|
||||
%%FIELD_MAPPING: class %%
|
||||
ELSE subclass
|
||||
END;
|
||||
|
||||
@@ -18,6 +18,7 @@ def_poi_mapping_amenity: &poi_mapping_amenity
|
||||
- biergarten
|
||||
- bus_station
|
||||
- cafe
|
||||
- charging_station
|
||||
- cinema
|
||||
- clinic
|
||||
- college
|
||||
@@ -124,7 +125,66 @@ def_poi_mapping_leisure: &poi_mapping_leisure
|
||||
|
||||
# office values , see http://taginfo.openstreetmap.org/keys/office#values
|
||||
def_poi_mapping_office: &poi_mapping_office
|
||||
- accountant
|
||||
- advertising_agency
|
||||
- architect
|
||||
- association
|
||||
- bail_bond_agent
|
||||
- charity
|
||||
- company
|
||||
- construction_company
|
||||
- consulting
|
||||
- cooperative
|
||||
- courier
|
||||
- coworking
|
||||
- diplomatic
|
||||
- educational_institution
|
||||
- employment_agency
|
||||
- energy_supplier
|
||||
- engineer
|
||||
- estate_agent
|
||||
- financial
|
||||
- financial_advisor
|
||||
- forestry
|
||||
- foundation
|
||||
- geodesist
|
||||
- government
|
||||
- graphic_design
|
||||
- guide
|
||||
- harbour_master
|
||||
- health_insurance
|
||||
- insurance
|
||||
- interior_design
|
||||
- it
|
||||
- lawyer
|
||||
- logistics
|
||||
- marketing
|
||||
- moving_company
|
||||
- newspaper
|
||||
- ngo
|
||||
- notary
|
||||
- physician
|
||||
- political_party
|
||||
- private_investigator
|
||||
- property_management
|
||||
- publisher
|
||||
- quango
|
||||
- religion
|
||||
- research
|
||||
- security
|
||||
- surveyor
|
||||
- tax_advisor
|
||||
- taxi
|
||||
- telecommunication
|
||||
- therapist
|
||||
- translator
|
||||
- travel_agent
|
||||
- tutoring
|
||||
- union
|
||||
- university
|
||||
- water_utility
|
||||
- web_design
|
||||
- wedding_planner
|
||||
|
||||
# railway values , see http://taginfo.openstreetmap.org/keys/railway#values
|
||||
def_poi_mapping_railway: &poi_mapping_railway
|
||||
@@ -199,6 +259,7 @@ def_poi_mapping_shop: &poi_mapping_shop
|
||||
- newsagent
|
||||
- optician
|
||||
- outdoor
|
||||
- paint
|
||||
- perfume
|
||||
- perfumery
|
||||
- pet
|
||||
|
||||
|
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.7 MiB |
@@ -116,7 +116,7 @@ FROM (
|
||||
ELSE osm_id * 10 + 1
|
||||
END AS osm_id_hash
|
||||
FROM osm_poi_polygon
|
||||
WHERE geometry && bbox AND
|
||||
WHERE zoom_level > 9 AND geometry && bbox AND
|
||||
CASE
|
||||
WHEN zoom_level >= 14 THEN TRUE
|
||||
WHEN zoom_level >= 12 AND
|
||||
|
||||
@@ -6,9 +6,9 @@ layer:
|
||||
buffer_size: 64
|
||||
srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
|
||||
fields:
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the POI.
|
||||
name_en: English name `name:en` if available, otherwise `name`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the POI. Language-specific values are in `name:xx`.
|
||||
name_en: English name `name:en` if available, otherwise `name`. This is deprecated and will be removed in a future release in favor of `name:en`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`. This is deprecated and will be removed in a future release in favor of `name:de`.
|
||||
class:
|
||||
description: |
|
||||
More general classes of POIs. If there is no more general `class` for the `subclass`
|
||||
@@ -17,40 +17,50 @@ layer:
|
||||
and `kindergarten`. Or use the class `shop` to style all shops.
|
||||
values:
|
||||
shop:
|
||||
subclass: ['accessories', 'antiques', 'beauty', 'bed', 'boutique', 'camera', 'carpet', 'charity', 'chemist',
|
||||
'coffee', 'computer', 'convenience', 'copyshop', 'cosmetics', 'garden_centre', 'doityourself',
|
||||
subclass: ['accessories', 'antiques', 'beauty', 'bed', 'boutique', 'camera', 'carpet', 'charity', 'chemist', 'chocolate',
|
||||
'coffee', 'computer', 'convenience', 'confectionery', 'copyshop', 'cosmetics', 'garden_centre', 'doityourself',
|
||||
'erotic', 'electronics', 'fabric', 'florist', 'frozen_food', 'furniture', 'video_games', 'video',
|
||||
'general', 'gift', 'hardware', 'hearing_aids', 'hifi', 'ice_cream', 'interior_decoration',
|
||||
'jewelry', 'kiosk', 'locksmith', 'lamps', 'mall', 'massage', 'motorcycle', 'mobile_phone',
|
||||
'newsagent', 'optician', 'outdoor', 'perfumery', 'perfume', 'pet', 'photo', 'second_hand', 'shoes', 'sports',
|
||||
'newsagent', 'optician', 'outdoor', 'paint', 'perfumery', 'perfume', 'pet', 'photo', 'second_hand', 'shoes', 'sports',
|
||||
'stationery', 'tailor', 'tattoo', 'ticket', 'tobacco', 'toys', 'travel_agency',
|
||||
'watches', 'weapons', 'wholesale' ]
|
||||
optician:
|
||||
subclass: [ 'optician' ]
|
||||
toys:
|
||||
subclass: [ 'toys' ]
|
||||
jewelry:
|
||||
subclass: [ 'jewelry' ]
|
||||
furniture:
|
||||
subclass: [ 'furniture' ]
|
||||
newsagent:
|
||||
subclass: [ 'newsagent' ]
|
||||
paint:
|
||||
subclass: [ 'paint' ]
|
||||
beverages:
|
||||
subclass: [ 'beverages' ]
|
||||
electronics:
|
||||
subclass: [ 'electronics' ]
|
||||
garden_centre:
|
||||
subclass: [ 'garden_centre' ]
|
||||
mobile_phone:
|
||||
subclass: [ 'mobile_phone' ]
|
||||
shoes:
|
||||
subclass: [ 'shoes' ]
|
||||
hardware:
|
||||
subclass: [ 'hardware', 'doityourself' ]
|
||||
florist:
|
||||
subclass: [ 'florist' ]
|
||||
office:
|
||||
subclass: ['accountant', 'advertising_agency', 'architect', 'association', 'bail_bond_agent', 'charity',
|
||||
'company', 'construction_company', 'consulting', 'cooperative', 'courier', 'coworking', 'diplomatic',
|
||||
'educational_institution', 'employment_agency', 'energy_supplier', 'engineer', 'estate_agent', 'financial',
|
||||
'financial_advisor', 'forestry', 'foundation', 'geodesist', 'government', 'graphic_design', 'guide',
|
||||
'harbour_master', 'health_insurance', 'insurance', 'interior_design', 'it', 'lawyer', 'logistics', 'marketing',
|
||||
'moving_company', 'newspaper', 'ngo', 'notary', 'physician', 'political_party', 'private_investigator',
|
||||
'property_management', 'publisher', 'quango', 'religion', 'research', 'security', 'surveyor', 'tax_advisor',
|
||||
'taxi', 'telecommunication', 'therapist', 'translator', 'travel_agent', 'tutoring', 'union', 'university',
|
||||
'water_utility', 'web_design', 'wedding_planner']
|
||||
# optician:
|
||||
# subclass: [ 'optician' ]
|
||||
# toys:
|
||||
# subclass: [ 'toys' ]
|
||||
# jewelry:
|
||||
# subclass: [ 'jewelry' ]
|
||||
# furniture:
|
||||
# subclass: [ 'furniture' ]
|
||||
# newsagent:
|
||||
# subclass: [ 'newsagent' ]
|
||||
# paint:
|
||||
# subclass: [ 'paint' ]
|
||||
# beverages:
|
||||
# subclass: [ 'beverages' ]
|
||||
# electronics:
|
||||
# subclass: [ 'electronics' ]
|
||||
# garden_centre:
|
||||
# subclass: [ 'garden_centre' ]
|
||||
# mobile_phone:
|
||||
# subclass: [ 'mobile_phone' ]
|
||||
# shoes:
|
||||
# subclass: [ 'shoes' ]
|
||||
# hardware:
|
||||
# subclass: [ 'hardware', 'doityourself' ]
|
||||
# florist:
|
||||
# subclass: [ 'florist' ]
|
||||
town_hall:
|
||||
subclass: ['townhall', 'public_building', 'courthouse']
|
||||
community_centre:
|
||||
@@ -87,7 +97,7 @@ layer:
|
||||
lodging:
|
||||
subclass: ['hotel', 'motel', 'bed_and_breakfast', 'guest_house', 'hostel', 'chalet', 'alpine_hut', 'dormitory']
|
||||
ice_cream:
|
||||
subclass: ['chocolate', 'confectionery', 'ice_cream']
|
||||
subclass: ['ice_cream', 'ice_cream']
|
||||
post:
|
||||
subclass: ['post_box', 'post_office', 'parcel_locker']
|
||||
cafe:
|
||||
@@ -130,6 +140,8 @@ layer:
|
||||
subclass: ['castle', 'ruins']
|
||||
atm:
|
||||
subclass: ['atm']
|
||||
fuel:
|
||||
subclass: ['fuel', 'charging_station']
|
||||
airport:
|
||||
subclass: [ 'aerodrome' ]
|
||||
heliport:
|
||||
|
||||
@@ -22,7 +22,37 @@
|
||||
]
|
||||
]
|
||||
},
|
||||
"icon-image": "{subclass}",
|
||||
"icon-image": [
|
||||
"coalesce",
|
||||
[
|
||||
"image",
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"subclass"
|
||||
],
|
||||
"chocolate",
|
||||
"confectionery",
|
||||
"wine",
|
||||
"alcohol",
|
||||
"kiosk",
|
||||
"newsagent",
|
||||
"perfume",
|
||||
"perfumery",
|
||||
"wholesale",
|
||||
"trade",
|
||||
[
|
||||
"get",
|
||||
"subclass"
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
"image",
|
||||
"shop"
|
||||
]
|
||||
],
|
||||
"text-field": "{name:latin}\n{name:nonlatin}",
|
||||
"visibility": "visible",
|
||||
"text-anchor": "top",
|
||||
@@ -35,16 +65,7 @@
|
||||
"icon-allow-overlap": true
|
||||
},
|
||||
"paint": {
|
||||
"text-color": [
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
"ice_cream",
|
||||
"#C77400",
|
||||
"#939"
|
||||
],
|
||||
"text-color": "#939",
|
||||
"icon-opacity": 1,
|
||||
"icon-halo-blur": 1,
|
||||
"text-halo-blur": 0.5,
|
||||
@@ -72,7 +93,9 @@
|
||||
"subclass",
|
||||
"mall",
|
||||
"library",
|
||||
"artwork"
|
||||
"artwork",
|
||||
"arts_centre",
|
||||
"gallery"
|
||||
]
|
||||
],
|
||||
"order": 150
|
||||
@@ -99,7 +122,19 @@
|
||||
]
|
||||
]
|
||||
},
|
||||
"icon-image": "{subclass}",
|
||||
"icon-image": [
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"subclass"
|
||||
],
|
||||
"chocolate",
|
||||
"confectionery",
|
||||
[
|
||||
"get",
|
||||
"subclass"
|
||||
]
|
||||
],
|
||||
"text-field": "{name:latin}\n{name:nonlatin}",
|
||||
"visibility": "visible",
|
||||
"text-anchor": "top",
|
||||
@@ -112,16 +147,7 @@
|
||||
"icon-allow-overlap": true
|
||||
},
|
||||
"paint": {
|
||||
"text-color": [
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
"ice_cream",
|
||||
"#C77400",
|
||||
"#939"
|
||||
],
|
||||
"text-color": "#939",
|
||||
"icon-opacity": 1,
|
||||
"icon-halo-blur": 1,
|
||||
"text-halo-blur": 0.5,
|
||||
@@ -743,7 +769,27 @@
|
||||
]
|
||||
]
|
||||
},
|
||||
"icon-image": "{subclass}",
|
||||
"icon-image": [
|
||||
"coalesce",
|
||||
[
|
||||
"image",
|
||||
[
|
||||
"get",
|
||||
"subclass"
|
||||
]
|
||||
],
|
||||
[
|
||||
"image",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
]
|
||||
],
|
||||
[
|
||||
"image",
|
||||
""
|
||||
]
|
||||
],
|
||||
"text-field": "{name:latin}\n{name:nonlatin}",
|
||||
"visibility": "visible",
|
||||
"text-anchor": "top",
|
||||
@@ -778,7 +824,8 @@
|
||||
"information",
|
||||
"cinema",
|
||||
"theatre",
|
||||
"fire_station"
|
||||
"fire_station",
|
||||
"office"
|
||||
],
|
||||
[
|
||||
"!=",
|
||||
@@ -840,7 +887,6 @@
|
||||
"class",
|
||||
"cinema",
|
||||
"library",
|
||||
"music",
|
||||
"museum",
|
||||
"castle",
|
||||
"monument",
|
||||
@@ -850,9 +896,7 @@
|
||||
"!in",
|
||||
"subclass",
|
||||
"books",
|
||||
"musical_instrument",
|
||||
"art",
|
||||
"gallery"
|
||||
"art"
|
||||
]
|
||||
],
|
||||
"order": 163
|
||||
@@ -976,7 +1020,8 @@
|
||||
"class",
|
||||
"car",
|
||||
"bicycle_parking",
|
||||
"fuel"
|
||||
"fuel",
|
||||
"charging_station"
|
||||
]
|
||||
],
|
||||
"order": 165
|
||||
|
||||
@@ -43,11 +43,11 @@ BEGIN
|
||||
-- (using name for parcel lockers is discouraged, see osm wiki)
|
||||
UPDATE osm_poi_point
|
||||
SET (name, tags) = (
|
||||
CONCAT(COALESCE(tags -> 'brand', tags -> 'operator'), concat(' ', tags -> 'ref')),
|
||||
tags || hstore('name', CONCAT(COALESCE(tags -> 'brand', tags -> 'operator'), concat(' ', tags -> 'ref')))
|
||||
TRIM(CONCAT(COALESCE(tags -> 'brand', tags -> 'operator'), concat(' ', tags -> 'ref'))),
|
||||
tags || hstore('name', TRIM(CONCAT(COALESCE(tags -> 'brand', tags -> 'operator'), concat(' ', tags -> 'ref'))))
|
||||
)
|
||||
WHERE (full_update OR osm_id IN (SELECT osm_id FROM poi_point.osm_ids))
|
||||
AND subclass = 'parcel_locker'
|
||||
AND subclass IN ('parcel_locker', 'charging_station')
|
||||
AND name = ''
|
||||
AND COALESCE(tags -> 'brand', tags -> 'operator') IS NOT NULL;
|
||||
|
||||
@@ -155,12 +155,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_poi_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE poi_point.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_poi_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE poi_point.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -36,6 +36,19 @@ $$
|
||||
AND funicular = 'yes'
|
||||
AND subclass = 'station';
|
||||
|
||||
-- Parcel locker and charging_station without name
|
||||
-- use either brand or operator and add ref if present
|
||||
-- (using name for parcel lockers is discouraged, see osm wiki)
|
||||
UPDATE osm_poi_polygon
|
||||
SET (name, tags) = (
|
||||
TRIM(CONCAT(COALESCE(tags -> 'brand', tags -> 'operator'), concat(' ', tags -> 'ref'))),
|
||||
tags || hstore('name', TRIM(CONCAT(COALESCE(tags -> 'brand', tags -> 'operator'), concat(' ', tags -> 'ref'))))
|
||||
)
|
||||
WHERE (full_update OR osm_id IN (SELECT osm_id FROM poi_polygon.osm_ids))
|
||||
AND subclass IN ('parcel_locker', 'charging_station')
|
||||
AND name = ''
|
||||
AND COALESCE(tags -> 'brand', tags -> 'operator') IS NOT NULL;
|
||||
|
||||
UPDATE osm_poi_polygon
|
||||
SET tags = update_tags(tags, geometry)
|
||||
WHERE (full_update OR osm_id IN (SELECT osm_id FROM poi_polygon.osm_ids))
|
||||
@@ -96,12 +109,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_poi_polygon
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE poi_polygon.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_poi_polygon
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE poi_polygon.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
|
Before Width: | Height: | Size: 772 KiB After Width: | Height: | Size: 865 KiB |
@@ -102,10 +102,6 @@ name_de_field: &name_de
|
||||
name: name_de
|
||||
key: name:de
|
||||
type: string
|
||||
short_name_field: &short_name
|
||||
key: short_name
|
||||
name: short_name
|
||||
type: string
|
||||
tunnel_field: &tunnel
|
||||
key: tunnel
|
||||
name: is_tunnel
|
||||
@@ -236,7 +232,6 @@ tables:
|
||||
- *name_de
|
||||
- name: tags
|
||||
type: hstore_tags
|
||||
- *short_name
|
||||
- *tunnel
|
||||
- *bridge
|
||||
- *ramp
|
||||
@@ -316,12 +311,10 @@ tables:
|
||||
- *name_de
|
||||
- name: tags
|
||||
type: hstore_tags
|
||||
- *short_name
|
||||
- *tunnel
|
||||
- *bridge
|
||||
- *ramp
|
||||
- *ford
|
||||
- *oneway
|
||||
- *area
|
||||
- *service
|
||||
- *usage
|
||||
@@ -355,7 +348,6 @@ tables:
|
||||
- *name_de
|
||||
- name: tags
|
||||
type: hstore_tags
|
||||
- *short_name
|
||||
- *tunnel
|
||||
- *bridge
|
||||
- *ramp
|
||||
@@ -394,12 +386,10 @@ tables:
|
||||
- *name_de
|
||||
- name: tags
|
||||
type: hstore_tags
|
||||
- *short_name
|
||||
- *tunnel
|
||||
- *bridge
|
||||
- *ramp
|
||||
- *ford
|
||||
- *oneway
|
||||
- *area
|
||||
- *service
|
||||
- *usage
|
||||
@@ -493,6 +483,9 @@ tables:
|
||||
- name: colour
|
||||
key: colour
|
||||
type: string
|
||||
- name: ref_colour
|
||||
key: ref:colour
|
||||
type: string
|
||||
mapping:
|
||||
route:
|
||||
- road
|
||||
|
||||
@@ -17,7 +17,9 @@ $$
|
||||
'us-interstate', 'us-highway', 'us-state',
|
||||
'ca-transcanada', 'ca-provincial-arterial', 'ca-provincial',
|
||||
'gb-motorway', 'gb-trunk', 'gb-primary',
|
||||
'ie-motorway', 'ie-national', 'ie-regional'
|
||||
'ie-motorway', 'ie-national', 'ie-regional',
|
||||
'e-road',
|
||||
'a-road'
|
||||
);
|
||||
END
|
||||
$$;
|
||||
@@ -29,6 +31,27 @@ $$
|
||||
-- Canada
|
||||
'ca-transcanada', 'ca-provincial-arterial',
|
||||
-- United States
|
||||
'us-interstate');
|
||||
'us-interstate', 'us-highway',
|
||||
-- UK
|
||||
'gb-motorway', 'gb-trunk',
|
||||
-- Ireland
|
||||
'ie-motorway', 'ie-national',
|
||||
-- Europe
|
||||
'e-road',
|
||||
-- Asia
|
||||
'a-road'
|
||||
);
|
||||
$$ LANGUAGE sql IMMUTABLE
|
||||
PARALLEL SAFE;
|
||||
|
||||
CREATE OR REPLACE FUNCTION create_route_hstore(network TEXT, ref TEXT, name TEXT, colour TEXT, ref_colour TEXT)
|
||||
RETURNS hstore AS $$
|
||||
SELECT CASE
|
||||
WHEN network = '' THEN hstore('')
|
||||
ELSE hstore(
|
||||
ARRAY['network', 'ref', 'name', 'colour'],
|
||||
ARRAY[network, NULLIF(ref, ''), NULLIF(name, ''), COALESCE(NULLIF(colour, ''), NULLIF(ref_colour, ''))]
|
||||
)
|
||||
END;
|
||||
$$ LANGUAGE sql IMMUTABLE
|
||||
PARALLEL SAFE;
|
||||
|
||||
@@ -4529,37 +4529,21 @@
|
||||
"all",
|
||||
[
|
||||
"==",
|
||||
[
|
||||
"geometry-type"
|
||||
],
|
||||
"$type",
|
||||
"LineString"
|
||||
],
|
||||
[
|
||||
"all",
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"brunnel"
|
||||
],
|
||||
[
|
||||
"bridge",
|
||||
"tunnel"
|
||||
],
|
||||
false,
|
||||
true
|
||||
"!in",
|
||||
"brunnel",
|
||||
"bridge",
|
||||
"tunnel"
|
||||
],
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
[
|
||||
"minor"
|
||||
],
|
||||
true,
|
||||
false
|
||||
"in",
|
||||
"class",
|
||||
"minor"
|
||||
]
|
||||
]
|
||||
],
|
||||
@@ -4633,37 +4617,21 @@
|
||||
"all",
|
||||
[
|
||||
"==",
|
||||
[
|
||||
"geometry-type"
|
||||
],
|
||||
"$type",
|
||||
"LineString"
|
||||
],
|
||||
[
|
||||
"all",
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"brunnel"
|
||||
],
|
||||
[
|
||||
"bridge",
|
||||
"tunnel"
|
||||
],
|
||||
false,
|
||||
true
|
||||
"!in",
|
||||
"brunnel",
|
||||
"bridge",
|
||||
"tunnel"
|
||||
],
|
||||
[
|
||||
"match",
|
||||
[
|
||||
"get",
|
||||
"class"
|
||||
],
|
||||
[
|
||||
"minor_construction"
|
||||
],
|
||||
true,
|
||||
false
|
||||
"in",
|
||||
"class",
|
||||
"minor_construction"
|
||||
]
|
||||
]
|
||||
],
|
||||
@@ -5607,7 +5575,7 @@
|
||||
"stops": [
|
||||
[
|
||||
8,
|
||||
" #787878"
|
||||
"#787878"
|
||||
],
|
||||
[
|
||||
14,
|
||||
@@ -7834,4 +7802,4 @@
|
||||
"order": 178
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ SELECT osm_id,
|
||||
NULLIF(service, '') AS service,
|
||||
access,
|
||||
CASE WHEN toll = TRUE THEN 1 END AS toll,
|
||||
CASE WHEN highway NOT IN ('', 'motorway') AND expressway = TRUE THEN 1 END AS expressway,
|
||||
CASE WHEN highway NOT IN ('', 'motorway') AND NOT is_ramp AND expressway = TRUE THEN 1 END AS expressway,
|
||||
NULLIF(layer, 0) AS layer,
|
||||
"level",
|
||||
CASE WHEN indoor = TRUE THEN 1 END AS indoor,
|
||||
@@ -372,7 +372,7 @@ FROM (
|
||||
hl.z_order
|
||||
FROM osm_highway_linestring hl
|
||||
LEFT OUTER JOIN osm_transportation_name_network n ON hl.osm_id = n.osm_id
|
||||
WHERE NOT is_area
|
||||
WHERE zoom_level > 11 AND NOT is_area
|
||||
AND
|
||||
CASE WHEN zoom_level = 12 THEN
|
||||
CASE WHEN transportation_filter_z12(hl.highway, hl.construction) THEN TRUE
|
||||
@@ -483,7 +483,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -518,7 +518,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -553,7 +553,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -589,7 +589,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -625,7 +625,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -659,7 +659,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -692,7 +692,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -725,7 +725,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -758,7 +758,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -791,7 +791,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -824,7 +824,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -857,7 +857,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -890,7 +890,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -923,7 +923,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -956,7 +956,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
@@ -990,7 +990,7 @@ FROM (
|
||||
is_ford,
|
||||
NULL::boolean AS expressway,
|
||||
is_ramp,
|
||||
is_oneway,
|
||||
NULL::int AS is_oneway,
|
||||
NULL AS man_made,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
|
||||
@@ -48,6 +48,7 @@ WHERE length(ref) > 1
|
||||
CREATE OR REPLACE FUNCTION osm_route_member_network_type(network text, ref text) RETURNS route_network_type AS
|
||||
$$
|
||||
SELECT CASE
|
||||
-- https://wiki.openstreetmap.org/wiki/United_States_roads_tagging
|
||||
WHEN network = 'US:I' THEN 'us-interstate'::route_network_type
|
||||
WHEN network = 'US:US' THEN 'us-highway'::route_network_type
|
||||
WHEN network LIKE 'US:__' THEN 'us-state'::route_network_type
|
||||
@@ -58,7 +59,7 @@ SELECT CASE
|
||||
CASE
|
||||
WHEN ref LIKE '4__' THEN 'ca-provincial-arterial'::route_network_type
|
||||
WHEN ref = 'QEW' THEN 'ca-provincial-arterial'::route_network_type
|
||||
ELSE 'ca-provincial-arterial'::route_network_type
|
||||
ELSE 'ca-provincial'::route_network_type
|
||||
END
|
||||
WHEN network = 'CA:MB:PTH' AND ref = '75' THEN 'ca-provincial-arterial'::route_network_type
|
||||
WHEN network = 'CA:AB:primary' AND ref IN ('2','3','4') THEN 'ca-provincial-arterial'::route_network_type
|
||||
@@ -85,6 +86,7 @@ CREATE TABLE IF NOT EXISTS transportation_route_member_coalesced
|
||||
name varchar,
|
||||
osmc_symbol varchar,
|
||||
colour varchar,
|
||||
ref_colour varchar,
|
||||
network_type route_network_type,
|
||||
concurrency_index integer,
|
||||
rank integer,
|
||||
@@ -104,33 +106,6 @@ BEGIN
|
||||
USING transportation_name.network_changes c
|
||||
WHERE c.is_old IS TRUE AND transportation_route_member_coalesced.member = c.osm_id;
|
||||
|
||||
-- Create GBR/IRE relations (so we can use it in the same way as other relations)
|
||||
-- etldoc: gbr_route_members_view -> transportation_route_member_coalesced
|
||||
INSERT INTO transportation_route_member_coalesced (member, network, ref, network_type, concurrency_index, osm_id)
|
||||
SELECT member, network, ref, osm_route_member_network_type(network, ref) AS network_type,
|
||||
1 AS concurrency_index, 0 AS osm_id
|
||||
FROM gbr_route_members_view
|
||||
WHERE full_update OR EXISTS(
|
||||
SELECT NULL
|
||||
FROM transportation_name.network_changes c
|
||||
WHERE c.is_old IS FALSE AND c.osm_id = gbr_route_members_view.member
|
||||
)
|
||||
GROUP BY member, network, ref
|
||||
ON CONFLICT (member, network, ref) DO NOTHING;
|
||||
|
||||
-- etldoc: ire_route_members_view -> transportation_route_member_coalesced
|
||||
INSERT INTO transportation_route_member_coalesced (member, network, ref, network_type, concurrency_index, osm_id)
|
||||
SELECT member, network, ref, osm_route_member_network_type(network, ref) AS network_type,
|
||||
1 AS concurrency_index, 0 AS osm_id
|
||||
FROM ire_route_members_view
|
||||
WHERE full_update OR EXISTS(
|
||||
SELECT NULL
|
||||
FROM transportation_name.network_changes c
|
||||
WHERE c.is_old IS FALSE AND c.osm_id = ire_route_members_view.member
|
||||
)
|
||||
GROUP BY member, network, ref
|
||||
ON CONFLICT (member, network, ref) DO NOTHING;
|
||||
|
||||
-- etldoc: osm_route_member -> transportation_route_member_coalesced
|
||||
INSERT INTO transportation_route_member_coalesced
|
||||
SELECT
|
||||
@@ -147,33 +122,40 @@ BEGIN
|
||||
END AS rank
|
||||
FROM (
|
||||
-- etldoc: osm_route_member -> osm_route_member
|
||||
-- etldoc: gbr_route_members_view -> osm_route_member
|
||||
-- etldoc: ire_route_members_view -> osm_route_member
|
||||
-- see http://wiki.openstreetmap.org/wiki/Relation:route#Road_routes
|
||||
SELECT DISTINCT ON (member, network, ref)
|
||||
member,
|
||||
network,
|
||||
ref,
|
||||
SELECT DISTINCT ON (member, COALESCE(rel.network, ''), COALESCE(rel.ref, ''))
|
||||
rel.member,
|
||||
COALESCE(NULLIF(rel.network,''), gb_way.network, ir_way.network, '') AS network,
|
||||
COALESCE(rel.ref, '') AS ref,
|
||||
osm_id,
|
||||
role,
|
||||
type,
|
||||
name,
|
||||
osmc_symbol,
|
||||
colour
|
||||
FROM osm_route_member
|
||||
colour,
|
||||
ref_colour
|
||||
FROM osm_route_member rel
|
||||
LEFT JOIN gbr_route_members_view gb_way ON (gb_way.member=rel.member)
|
||||
LEFT JOIN ire_route_members_view ir_way ON (ir_way.member=rel.member)
|
||||
WHERE full_update OR EXISTS(
|
||||
SELECT NULL
|
||||
FROM transportation_name.network_changes c
|
||||
WHERE c.is_old IS FALSE AND c.osm_id = osm_route_member.member
|
||||
WHERE c.is_old IS FALSE AND c.osm_id = rel.member
|
||||
)
|
||||
) osm_route_member_filtered
|
||||
ON CONFLICT (member, network, ref) DO UPDATE SET osm_id = EXCLUDED.osm_id, role = EXCLUDED.role,
|
||||
type = EXCLUDED.type, name = EXCLUDED.name,
|
||||
osmc_symbol = EXCLUDED.osmc_symbol, colour = EXCLUDED.colour,
|
||||
osmc_symbol = EXCLUDED.osmc_symbol, colour = EXCLUDED.colour, ref_colour = EXCLUDED.ref_colour,
|
||||
concurrency_index = EXCLUDED.concurrency_index,
|
||||
rank = EXCLUDED.rank;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
-- Indexes which can be utilized during full-update for queries originating from update_osm_route_member() function
|
||||
CREATE INDEX IF NOT EXISTS osm_route_member_member_network_ref_idx ON osm_route_member (member, network, ref);
|
||||
CREATE INDEX IF NOT EXISTS osm_route_member_member_network_ref_idx
|
||||
ON osm_route_member (member, COALESCE(network, ''), COALESCE(ref, ''));
|
||||
|
||||
-- Analyze created index
|
||||
ANALYZE osm_route_member;
|
||||
|
||||
@@ -22,7 +22,7 @@ SELECT
|
||||
ST_Length(g) *
|
||||
COS(RADIANS(ST_Y(ST_Centroid(ST_Transform(g, 4326))))) *
|
||||
POW(2, zoom_level) / 20131560 > 0.02
|
||||
$$ LANGUAGE SQL IMMUTABLE LEAKPROOF
|
||||
$$ LANGUAGE SQL IMMUTABLE
|
||||
PARALLEL SAFE;
|
||||
|
||||
-- Determine whether a segment is long enough to have layer attributes
|
||||
@@ -39,7 +39,24 @@ SELECT
|
||||
COS(RADIANS(ST_Y(ST_Centroid(ST_Transform(g, 4326))))) *
|
||||
POW(2, zoom_level) / 20131560 > 0.02
|
||||
THEN layer END
|
||||
$$ LANGUAGE SQL IMMUTABLE LEAKPROOF
|
||||
$$ LANGUAGE SQL IMMUTABLE
|
||||
PARALLEL SAFE;
|
||||
|
||||
-- Determine whether a segment is long enough to have an attribute
|
||||
CREATE OR REPLACE FUNCTION visible_text(g geometry, attr text, zoom_level integer)
|
||||
RETURNS text AS
|
||||
$$
|
||||
SELECT
|
||||
CASE WHEN
|
||||
-- Width of a tile in meters (111,842 is the length of one degree of latitude at the equator in meters)
|
||||
-- 111,842 * 180 / 2^zoom_level
|
||||
-- = 20131560 / POW(2, zoom_level)
|
||||
-- Drop brunnel if length of way < 2% of tile width (less than 3 pixels)
|
||||
ST_Length(g) *
|
||||
COS(RADIANS(ST_Y(ST_Centroid(ST_Transform(g, 4326))))) *
|
||||
POW(2, zoom_level) / 20131560 > 0.02
|
||||
THEN attr END
|
||||
$$ LANGUAGE SQL IMMUTABLE
|
||||
PARALLEL SAFE;
|
||||
|
||||
-- Instead of using relations to find out the road names we
|
||||
@@ -49,7 +66,8 @@ $$ LANGUAGE SQL IMMUTABLE LEAKPROOF
|
||||
|
||||
-- etldoc: osm_highway_linestring -> osm_transportation_name_network
|
||||
-- etldoc: transportation_route_member_coalesced -> osm_transportation_name_network
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_name_network AS
|
||||
DROP TABLE IF EXISTS osm_transportation_name_network;
|
||||
CREATE TABLE osm_transportation_name_network AS
|
||||
SELECT
|
||||
geometry,
|
||||
osm_id,
|
||||
@@ -84,12 +102,12 @@ FROM (
|
||||
CASE WHEN highway IN ('footway', 'steps') THEN layer END AS layer,
|
||||
CASE WHEN highway IN ('footway', 'steps') THEN level END AS level,
|
||||
CASE WHEN highway IN ('footway', 'steps') THEN indoor END AS indoor,
|
||||
NULLIF(rm1.network, '') || '=' || COALESCE(rm1.ref, '') AS route_1,
|
||||
NULLIF(rm2.network, '') || '=' || COALESCE(rm2.ref, '') AS route_2,
|
||||
NULLIF(rm3.network, '') || '=' || COALESCE(rm3.ref, '') AS route_3,
|
||||
NULLIF(rm4.network, '') || '=' || COALESCE(rm4.ref, '') AS route_4,
|
||||
NULLIF(rm5.network, '') || '=' || COALESCE(rm5.ref, '') AS route_5,
|
||||
NULLIF(rm6.network, '') || '=' || COALESCE(rm6.ref, '') AS route_6,
|
||||
create_route_hstore(rm1.network, rm1.ref, rm1.name, rm1.colour, rm1.ref_colour) AS route_1,
|
||||
create_route_hstore(rm2.network, rm2.ref, rm2.name, rm2.colour, rm2.ref_colour) AS route_2,
|
||||
create_route_hstore(rm3.network, rm3.ref, rm3.name, rm3.colour, rm3.ref_colour) AS route_3,
|
||||
create_route_hstore(rm4.network, rm4.ref, rm4.name, rm4.colour, rm4.ref_colour) AS route_4,
|
||||
create_route_hstore(rm5.network, rm5.ref, rm5.name, rm5.colour, rm5.ref_colour) AS route_5,
|
||||
create_route_hstore(rm6.network, rm6.ref, rm6.name, rm6.colour, rm6.ref_colour) AS route_6,
|
||||
hl.z_order,
|
||||
LEAST(rm1.rank, rm2.rank, rm3.rank, rm4.rank, rm5.rank, rm6.rank) AS route_rank
|
||||
FROM osm_highway_linestring hl
|
||||
@@ -126,6 +144,8 @@ CREATE TABLE IF NOT EXISTS osm_transportation_merge_linestring_gen_z11(
|
||||
id SERIAL,
|
||||
osm_id bigint,
|
||||
source_ids bigint[],
|
||||
new_source_ids bigint[],
|
||||
old_source_ids bigint[],
|
||||
highway character varying,
|
||||
network character varying,
|
||||
construction character varying,
|
||||
@@ -144,12 +164,23 @@ CREATE TABLE IF NOT EXISTS osm_transportation_merge_linestring_gen_z11(
|
||||
layer integer
|
||||
);
|
||||
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z11 ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z11 ADD COLUMN IF NOT EXISTS new_source_ids BIGINT[];
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z11 ADD COLUMN IF NOT EXISTS old_source_ids BIGINT[];
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z11_n_source_ids_not_null_idx
|
||||
ON osm_transportation_merge_linestring_gen_z11 ((new_source_ids IS NOT NULL));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z11_o_source_ids_not_null_idx
|
||||
ON osm_transportation_merge_linestring_gen_z11 ((old_source_ids IS NOT NULL));
|
||||
|
||||
-- Create osm_transportation_merge_linestring_gen_z10 as a copy of osm_transportation_merge_linestring_gen_z11 but
|
||||
-- drop the "source_ids" column. This can be done because z10 and z9 tables are only simplified and not merged,
|
||||
-- therefore relations to sources are direct via the id column.
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_merge_linestring_gen_z10
|
||||
(LIKE osm_transportation_merge_linestring_gen_z11);
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z10 DROP COLUMN IF EXISTS source_ids;
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z10 DROP COLUMN IF EXISTS new_source_ids;
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z10 DROP COLUMN IF EXISTS old_source_ids;
|
||||
|
||||
-- Create osm_transportation_merge_linestring_gen_z9 as a copy of osm_transportation_merge_linestring_gen_z10
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_merge_linestring_gen_z9
|
||||
@@ -445,10 +476,12 @@ CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z9_geometry_i
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z9 -> osm_transportation_merge_linestring_gen_z8
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_merge_linestring_gen_z8(
|
||||
geometry geometry('LineString'),
|
||||
geometry geometry,
|
||||
id SERIAL,
|
||||
osm_id bigint,
|
||||
source_ids int[],
|
||||
new_source_ids bigint[],
|
||||
old_source_ids bigint[],
|
||||
highway character varying,
|
||||
network character varying,
|
||||
construction character varying,
|
||||
@@ -459,12 +492,23 @@ CREATE TABLE IF NOT EXISTS osm_transportation_merge_linestring_gen_z8(
|
||||
z_order integer
|
||||
);
|
||||
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z8 ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z8 ADD COLUMN IF NOT EXISTS new_source_ids bigint[];
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z8 ADD COLUMN IF NOT EXISTS old_source_ids bigint[];
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z8_n_source_ids_not_null_idx
|
||||
ON osm_transportation_merge_linestring_gen_z8 ((new_source_ids IS NOT NULL));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z8_o_source_ids_not_null_idx
|
||||
ON osm_transportation_merge_linestring_gen_z8 ((old_source_ids IS NOT NULL));
|
||||
|
||||
-- Create osm_transportation_merge_linestring_gen_z7 as a copy of osm_transportation_merge_linestring_gen_z8 but
|
||||
-- drop the "source_ids" column. This can be done because z7 to z5 tables are only simplified and not merged,
|
||||
-- therefore relations to sources are direct via the id column.
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_merge_linestring_gen_z7
|
||||
(LIKE osm_transportation_merge_linestring_gen_z8);
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z7 DROP COLUMN IF EXISTS source_ids;
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z7 DROP COLUMN IF EXISTS new_source_ids;
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z7 DROP COLUMN IF EXISTS old_source_ids;
|
||||
|
||||
-- Create osm_transportation_merge_linestring_gen_z6 as a copy of osm_transportation_merge_linestring_gen_z7
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_merge_linestring_gen_z6
|
||||
@@ -662,25 +706,68 @@ BEGIN
|
||||
|
||||
-- etldoc: osm_transportation_merge_linestring_gen_z8 -> osm_transportation_merge_linestring_gen_z7
|
||||
INSERT INTO osm_transportation_merge_linestring_gen_z7
|
||||
SELECT ST_Simplify(geometry, ZRes(9)) AS geometry,
|
||||
id,
|
||||
osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
visible_brunnel(geometry, is_bridge, 8) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 8) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 8) AS is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z8
|
||||
WITH roads_z8 AS (
|
||||
SELECT id,
|
||||
osm_id,
|
||||
ST_SnapToGrid(
|
||||
ST_Node(
|
||||
ST_Collect(
|
||||
ST_Simplify(geometry, ZRes(9))
|
||||
)
|
||||
), ZRes(9)
|
||||
) AS geometry,
|
||||
highway,
|
||||
NULLIF(network, '') as network,
|
||||
construction,
|
||||
is_bridge,
|
||||
is_tunnel,
|
||||
is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z8
|
||||
GROUP BY id, osm_id, highway, construction, network, is_bridge, is_tunnel, is_ford, expressway, z_order
|
||||
),
|
||||
roads_z8_merge AS (
|
||||
SELECT id,
|
||||
osm_id,
|
||||
ST_LineMerge(
|
||||
ST_Union(geometry)
|
||||
) AS geometry,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
is_bridge,
|
||||
is_tunnel,
|
||||
is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM roads_z8
|
||||
GROUP BY id, osm_id, highway, network, construction, is_bridge, is_tunnel, is_ford, expressway, z_order
|
||||
)
|
||||
|
||||
SELECT CASE
|
||||
WHEN ST_StartPoint(geometry) = ST_EndPoint(geometry)
|
||||
THEN ST_RemovePoint(geometry, ST_NPoints(geometry) - 1)
|
||||
ELSE geometry
|
||||
END AS geometry,
|
||||
id,
|
||||
osm_id,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
-- Remove bridge/tunnel/ford attributes from short sections of road so they can be merged
|
||||
visible_brunnel(geometry, is_bridge, 8) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 8) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 8) AS is_ford,
|
||||
expressway,
|
||||
z_order
|
||||
FROM roads_z8_merge
|
||||
-- Current view: motorway/trunk/primary
|
||||
WHERE
|
||||
(full_update IS TRUE OR EXISTS(
|
||||
SELECT NULL FROM transportation.changes_z4_z5_z6_z7
|
||||
WHERE transportation.changes_z4_z5_z6_z7.is_old IS FALSE AND
|
||||
transportation.changes_z4_z5_z6_z7.id = osm_transportation_merge_linestring_gen_z8.id
|
||||
transportation.changes_z4_z5_z6_z7.id = roads_z8_merge.id
|
||||
)) AND
|
||||
(ST_Length(geometry) > 50)
|
||||
ON CONFLICT (id) DO UPDATE SET osm_id = excluded.osm_id, highway = excluded.highway, network = excluded.network,
|
||||
@@ -803,7 +890,12 @@ BEGIN
|
||||
WHERE transportation.changes_z4_z5_z6_z7.is_old IS FALSE AND
|
||||
transportation.changes_z4_z5_z6_z7.id = osm_transportation_merge_linestring_gen_z5.id
|
||||
)) AND
|
||||
osm_national_network(network) AND
|
||||
-- All motorways without network (e.g. EU, Asia, South America)
|
||||
((highway = 'motorway' OR construction = 'motorway') AND (network is NULL or network = '')
|
||||
) OR
|
||||
-- All roads in network included in osm_national_network except gb-trunk and us-highway
|
||||
( (osm_national_network(network) AND network NOT IN ('gb-trunk', 'us-highway')
|
||||
)) AND
|
||||
-- Current view: national-importance motorways and trunks
|
||||
ST_Length(geometry) > 1000
|
||||
ON CONFLICT (id) DO UPDATE SET osm_id = excluded.osm_id, highway = excluded.highway, network = excluded.network,
|
||||
@@ -857,6 +949,12 @@ CREATE INDEX IF NOT EXISTS osm_transportation_merge_linestring_gen_z4_geometry_i
|
||||
-- osm_highway_linestring_gen_z11 -> osm_transportation_merge_linestring_gen_z11
|
||||
-- osm_transportation_merge_linestring_gen_z11 -> osm_transportation_merge_linestring_gen_z10
|
||||
-- osm_transportation_merge_linestring_gen_z11 -> osm_transportation_merge_linestring_gen_z9
|
||||
CREATE OR REPLACE AGGREGATE array_cat_agg(anycompatiblearray) (
|
||||
SFUNC=array_cat,
|
||||
STYPE=anycompatiblearray,
|
||||
INITCOND = '{}'
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS transportation.changes_z11
|
||||
(
|
||||
is_old boolean NULL,
|
||||
@@ -958,7 +1056,8 @@ BEGIN
|
||||
-- Create a table containing all LineStrings which should be merged
|
||||
CREATE TEMPORARY TABLE linestrings_to_merge AS
|
||||
-- Add all Source-LineStrings affected by this update
|
||||
SELECT osm_highway_linestring_gen_z11.osm_id, NULL::INTEGER AS id, geometry, highway, network, construction,
|
||||
SELECT osm_highway_linestring_gen_z11.osm_id, NULL::INTEGER AS id, NULL::BIGINT[] AS source_ids,
|
||||
geometry, highway, network, construction,
|
||||
visible_brunnel(geometry, is_bridge, 11) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 11) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 11) AS is_ford,
|
||||
@@ -981,22 +1080,22 @@ BEGIN
|
||||
-- Drop temporary tables early to save resources
|
||||
DROP TABLE affected_merged_linestrings;
|
||||
|
||||
-- Create index on geometry column and analyze the created table to speed up subsequent queries
|
||||
CREATE INDEX ON linestrings_to_merge USING GIST (geometry);
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
|
||||
-- Add all Merged-LineStrings intersecting with Source-LineStrings affected by this update
|
||||
INSERT INTO linestrings_to_merge
|
||||
SELECT s.source_id AS osm_id, m.id,
|
||||
geometry, highway, network, construction,
|
||||
visible_brunnel(geometry, is_bridge, 11) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 11) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 11) AS is_ford,
|
||||
expressway, bicycle, foot, horse, mtb_scale, sac_scale, access, toll,
|
||||
visible_layer(geometry, layer, 11) AS layer, z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z11 m
|
||||
JOIN osm_transportation_merge_linestring_gen_z11_source_ids s ON (m.id = s.id)
|
||||
WHERE EXISTS(SELECT NULL FROM linestrings_to_merge WHERE ST_Intersects(linestrings_to_merge.geometry, m.geometry));
|
||||
SELECT NULL::BIGINT AS osm_id, m.id,
|
||||
ARRAY(
|
||||
SELECT s.source_id FROM osm_transportation_merge_linestring_gen_z11_source_ids s WHERE s.id = m.id
|
||||
)::BIGINT[] AS source_ids, m.geometry, m.highway, m.network, m.construction,
|
||||
visible_brunnel(m.geometry, m.is_bridge, 11) AS is_bridge,
|
||||
visible_brunnel(m.geometry, m.is_tunnel, 11) AS is_tunnel,
|
||||
visible_brunnel(m.geometry, m.is_ford, 11) AS is_ford,
|
||||
m.expressway, m.bicycle, m.foot, m.horse, m.mtb_scale, m.sac_scale, m.access, m.toll,
|
||||
visible_layer(m.geometry, m.layer, 11) AS layer, m.z_order
|
||||
FROM linestrings_to_merge
|
||||
JOIN osm_transportation_merge_linestring_gen_z11 m ON (ST_Intersects(linestrings_to_merge.geometry, m.geometry));
|
||||
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
@@ -1039,16 +1138,12 @@ BEGIN
|
||||
CREATE INDEX ON clustered_linestrings_to_merge (cluster_group, cluster);
|
||||
ANALYZE clustered_linestrings_to_merge;
|
||||
|
||||
-- Create temporary Merged-LineString to Source-LineStrings-ID column to store relations before they have been
|
||||
-- intersected
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z11 ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
|
||||
WITH inserted_linestrings AS (
|
||||
-- Merge LineStrings of each cluster and insert them
|
||||
INSERT INTO osm_transportation_merge_linestring_gen_z11(geometry, source_ids, highway, network, construction,
|
||||
is_bridge, is_tunnel, is_ford, expressway, z_order,
|
||||
bicycle, foot, horse, mtb_scale, sac_scale, access,
|
||||
toll, layer)
|
||||
INSERT INTO osm_transportation_merge_linestring_gen_z11(geometry, new_source_ids, old_source_ids, highway,
|
||||
network, construction, is_bridge, is_tunnel, is_ford,
|
||||
expressway, z_order, bicycle, foot, horse, mtb_scale,
|
||||
sac_scale, access, toll, layer)
|
||||
SELECT (ST_Dump(ST_LineMerge(ST_Union(geometry)))).geom AS geometry,
|
||||
-- We use St_Union instead of St_Collect to ensure no overlapping points exist within the geometries to
|
||||
-- merge. https://postgis.net/docs/ST_Union.html
|
||||
@@ -1057,7 +1152,8 @@ BEGIN
|
||||
-- https://postgis.net/docs/ST_LineMerge.html
|
||||
-- In order to not end up with a mixture of LineStrings and MultiLineStrings we dump eventual
|
||||
-- MultiLineStrings via ST_Dump. https://postgis.net/docs/ST_Dump.html
|
||||
array_agg(osm_id) AS source_ids,
|
||||
coalesce( array_agg(osm_id) FILTER (WHERE osm_id IS NOT NULL), '{}' )::BIGINT[] AS new_source_ids,
|
||||
array_cat_agg(source_ids)::BIGINT[] AS old_source_ids,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
@@ -1077,7 +1173,7 @@ BEGIN
|
||||
FROM clustered_linestrings_to_merge
|
||||
GROUP BY cluster_group, cluster, highway, network, construction, is_bridge, is_tunnel, is_ford, expressway,
|
||||
bicycle, foot, horse, mtb_scale, sac_scale, access, toll, layer
|
||||
RETURNING id, source_ids, geometry
|
||||
RETURNING id, new_source_ids, old_source_ids, geometry
|
||||
)
|
||||
-- Store OSM-IDs of Source-LineStrings by intersecting Merged-LineStrings with their sources.
|
||||
-- This is required because ST_LineMerge only merges across singular intersections and groups its output into a
|
||||
@@ -1085,8 +1181,14 @@ BEGIN
|
||||
INSERT INTO osm_transportation_merge_linestring_gen_z11_source_ids (id, source_id)
|
||||
SELECT m.id, source_id
|
||||
FROM (
|
||||
SELECT id, unnest(source_ids) AS source_id, geometry
|
||||
SELECT id, source_id, geometry
|
||||
FROM inserted_linestrings
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT DISTINCT all_source_ids.source_id
|
||||
FROM unnest(
|
||||
array_cat(inserted_linestrings.new_source_ids, inserted_linestrings.old_source_ids)
|
||||
) AS all_source_ids(source_id)
|
||||
) source_ids
|
||||
) m
|
||||
JOIN osm_highway_linestring_gen_z11 s ON (m.source_id = s.osm_id)
|
||||
WHERE ST_Intersects(s.geometry, m.geometry)
|
||||
@@ -1095,8 +1197,9 @@ BEGIN
|
||||
-- Cleanup remaining table
|
||||
DROP TABLE clustered_linestrings_to_merge;
|
||||
|
||||
-- Drop temporary Merged-LineString to Source-LineStrings-ID column
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z11 DROP COLUMN IF EXISTS source_ids;
|
||||
-- Restore temporary Merged-LineString to Source-LineStrings-ID columns
|
||||
UPDATE osm_transportation_merge_linestring_gen_z11 SET new_source_ids = NULL WHERE new_source_ids IS NOT NULL;
|
||||
UPDATE osm_transportation_merge_linestring_gen_z11 SET old_source_ids = NULL WHERE old_source_ids IS NOT NULL;
|
||||
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM transportation.changes_z11;
|
||||
@@ -1246,7 +1349,7 @@ BEGIN
|
||||
-- Create a table containing all LineStrings which should be merged
|
||||
CREATE TEMPORARY TABLE linestrings_to_merge AS
|
||||
-- Add all Source-LineStrings affected by this update
|
||||
SELECT id AS source_id, NULL::int AS id, geometry, highway, network, construction,
|
||||
SELECT id AS source_id, NULL::INT AS id, NULL::INT[] AS source_ids, geometry, highway, network, construction,
|
||||
visible_brunnel(geometry, is_bridge, 9) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 9) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 9) AS is_ford, expressway, z_order
|
||||
@@ -1260,31 +1363,32 @@ BEGIN
|
||||
ORDER BY source_id
|
||||
) affected_source_linestrings
|
||||
JOIN osm_transportation_merge_linestring_gen_z9 ON (
|
||||
affected_source_linestrings.source_id = osm_transportation_merge_linestring_gen_z9.id AND
|
||||
(
|
||||
highway IN ('motorway', 'trunk', 'primary') OR
|
||||
construction IN ('motorway', 'trunk', 'primary')
|
||||
) AND
|
||||
ST_IsValid(geometry) AND
|
||||
access IS NULL
|
||||
);
|
||||
affected_source_linestrings.source_id = osm_transportation_merge_linestring_gen_z9.id
|
||||
)
|
||||
WHERE (
|
||||
highway IN ('motorway', 'trunk', 'primary') OR
|
||||
construction IN ('motorway', 'trunk', 'primary')
|
||||
) AND
|
||||
ST_IsValid(geometry) AND
|
||||
access IS NULL;
|
||||
|
||||
-- Drop temporary tables early to save resources
|
||||
DROP TABLE affected_merged_linestrings;
|
||||
|
||||
-- Create index on geometry column and analyze the created table to speed up subsequent queries
|
||||
CREATE INDEX ON linestrings_to_merge USING GIST (geometry);
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
|
||||
-- Add all Merged-LineStrings intersecting with Source-LineStrings affected by this update
|
||||
INSERT INTO linestrings_to_merge
|
||||
SELECT s.source_id, m.id, geometry, highway, network, construction,
|
||||
visible_brunnel(geometry, is_bridge, 9) AS is_bridge,
|
||||
visible_brunnel(geometry, is_tunnel, 9) AS is_tunnel,
|
||||
visible_brunnel(geometry, is_ford, 9) AS is_ford, expressway, z_order
|
||||
FROM osm_transportation_merge_linestring_gen_z8 m
|
||||
JOIN osm_transportation_merge_linestring_gen_z8_source_ids s ON (m.id = s.id)
|
||||
WHERE EXISTS(SELECT NULL FROM linestrings_to_merge WHERE ST_Intersects(linestrings_to_merge.geometry, m.geometry));
|
||||
SELECT NULL::INT AS source_id, m.id,
|
||||
ARRAY(
|
||||
SELECT s.source_id FROM osm_transportation_merge_linestring_gen_z8_source_ids s WHERE s.id = m.id
|
||||
)::INT[] AS source_ids, m.geometry, m.highway, m.network, m.construction,
|
||||
visible_brunnel(m.geometry, m.is_bridge, 9) AS is_bridge,
|
||||
visible_brunnel(m.geometry, m.is_tunnel, 9) AS is_tunnel,
|
||||
visible_brunnel(m.geometry, m.is_ford, 9) AS is_ford, m.expressway, m.z_order
|
||||
FROM linestrings_to_merge
|
||||
JOIN osm_transportation_merge_linestring_gen_z8 m ON (ST_Intersects(linestrings_to_merge.geometry, m.geometry));
|
||||
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
@@ -1325,14 +1429,13 @@ BEGIN
|
||||
CREATE INDEX ON clustered_linestrings_to_merge (cluster_group, cluster);
|
||||
ANALYZE clustered_linestrings_to_merge;
|
||||
|
||||
-- Create temporary Merged-LineString to Source-LineStrings-ID column to store relations before they have been
|
||||
-- Create temporary Merged-LineString to Source-LineStrings-ID columns to store relations before they have been
|
||||
-- intersected
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z8 ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
|
||||
WITH inserted_linestrings AS (
|
||||
-- Merge LineStrings of each cluster and insert them
|
||||
INSERT INTO osm_transportation_merge_linestring_gen_z8(geometry, source_ids, highway, network, construction,
|
||||
is_bridge, is_tunnel, is_ford, expressway, z_order)
|
||||
INSERT INTO osm_transportation_merge_linestring_gen_z8(geometry, new_source_ids, old_source_ids, highway,
|
||||
network, construction, is_bridge, is_tunnel, is_ford,
|
||||
expressway, z_order)
|
||||
SELECT (ST_Dump(ST_Simplify(ST_LineMerge(ST_Union(geometry)), ZRes(10)))).geom AS geometry,
|
||||
-- We use St_Union instead of St_Collect to ensure no overlapping points exist within the geometries to
|
||||
-- merge. https://postgis.net/docs/ST_Union.html
|
||||
@@ -1341,7 +1444,8 @@ BEGIN
|
||||
-- https://postgis.net/docs/ST_LineMerge.html
|
||||
-- In order to not end up with a mixture of LineStrings and MultiLineStrings we dump eventual
|
||||
-- MultiLineStrings via ST_Dump. https://postgis.net/docs/ST_Dump.html
|
||||
array_agg(source_id) as source_ids,
|
||||
coalesce( array_agg(source_id) FILTER (WHERE source_id IS NOT NULL), '{}' )::INT[] AS new_source_ids,
|
||||
array_cat_agg(source_ids)::INT[] as old_source_ids,
|
||||
highway,
|
||||
network,
|
||||
construction,
|
||||
@@ -1352,7 +1456,7 @@ BEGIN
|
||||
min(z_order) as z_order
|
||||
FROM clustered_linestrings_to_merge
|
||||
GROUP BY cluster_group, cluster, highway, network, construction, is_bridge, is_tunnel, is_ford, expressway
|
||||
RETURNING id, source_ids, geometry
|
||||
RETURNING id, new_source_ids, old_source_ids, geometry
|
||||
)
|
||||
-- Store OSM-IDs of Source-LineStrings by intersecting Merged-LineStrings with their sources. This required because
|
||||
-- ST_LineMerge only merges across singular intersections and groups its output into a MultiLineString if
|
||||
@@ -1360,8 +1464,14 @@ BEGIN
|
||||
INSERT INTO osm_transportation_merge_linestring_gen_z8_source_ids (id, source_id)
|
||||
SELECT m.id, m.source_id
|
||||
FROM (
|
||||
SELECT id, unnest(source_ids) AS source_id, geometry
|
||||
SELECT id, source_id, geometry
|
||||
FROM inserted_linestrings
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT DISTINCT all_source_ids.source_id
|
||||
FROM unnest(
|
||||
array_cat(inserted_linestrings.new_source_ids, inserted_linestrings.old_source_ids)
|
||||
) AS all_source_ids(source_id)
|
||||
) source_ids
|
||||
) m
|
||||
JOIN osm_transportation_merge_linestring_gen_z9 s ON (m.source_id = s.id)
|
||||
WHERE ST_Intersects(s.geometry, m.geometry)
|
||||
@@ -1370,9 +1480,10 @@ BEGIN
|
||||
-- Cleanup
|
||||
DROP TABLE clustered_linestrings_to_merge;
|
||||
|
||||
-- Drop temporary Merged-LineString to Source-LineStrings-ID column
|
||||
ALTER TABLE osm_transportation_merge_linestring_gen_z8 DROP COLUMN IF EXISTS source_ids;
|
||||
-- Restore temporary Merged-LineString to Source-LineStrings-ID columns
|
||||
|
||||
UPDATE osm_transportation_merge_linestring_gen_z8 SET new_source_ids = NULL WHERE new_source_ids IS NOT NULL;
|
||||
UPDATE osm_transportation_merge_linestring_gen_z8 SET old_source_ids = NULL WHERE old_source_ids IS NOT NULL;
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM transportation.changes_z9;
|
||||
-- noinspection SqlWithoutWhere
|
||||
|
||||
@@ -1,52 +1,46 @@
|
||||
CREATE OR REPLACE FUNCTION highway_to_val(hwy_class varchar)
|
||||
RETURNS int
|
||||
IMMUTABLE
|
||||
LANGUAGE plpgsql
|
||||
LANGUAGE sql
|
||||
AS $$
|
||||
BEGIN
|
||||
CASE hwy_class
|
||||
WHEN 'motorway' THEN RETURN 6;
|
||||
WHEN 'trunk' THEN RETURN 5;
|
||||
WHEN 'primary' THEN RETURN 4;
|
||||
WHEN 'secondary' THEN RETURN 3;
|
||||
WHEN 'tertiary' THEN RETURN 2;
|
||||
WHEN 'unclassified' THEN RETURN 1;
|
||||
else RETURN 0;
|
||||
END CASE;
|
||||
END;
|
||||
SELECT CASE hwy_class
|
||||
WHEN 'motorway' THEN 6
|
||||
WHEN 'trunk' THEN 5
|
||||
WHEN 'primary' THEN 4
|
||||
WHEN 'secondary' THEN 3
|
||||
WHEN 'tertiary' THEN 2
|
||||
WHEN 'unclassified' THEN 1
|
||||
ELSE 0
|
||||
END;
|
||||
$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION val_to_highway(hwy_val int)
|
||||
RETURNS varchar
|
||||
IMMUTABLE
|
||||
LANGUAGE plpgsql
|
||||
LANGUAGE sql
|
||||
AS $$
|
||||
BEGIN
|
||||
CASE hwy_val
|
||||
WHEN 6 THEN RETURN 'motorway';
|
||||
WHEN 5 THEN RETURN 'trunk';
|
||||
WHEN 4 THEN RETURN 'primary';
|
||||
WHEN 3 THEN RETURN 'secondary';
|
||||
WHEN 2 THEN RETURN 'tertiary';
|
||||
WHEN 1 THEN RETURN 'unclassified';
|
||||
else RETURN null;
|
||||
END CASE;
|
||||
END;
|
||||
SELECT CASE hwy_val
|
||||
WHEN 6 THEN 'motorway'
|
||||
WHEN 5 THEN 'trunk'
|
||||
WHEN 4 THEN 'primary'
|
||||
WHEN 3 THEN 'secondary'
|
||||
WHEN 2 THEN 'tertiary'
|
||||
WHEN 1 THEN 'unclassified'
|
||||
ELSE null
|
||||
END;
|
||||
$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION highest_hwy_sfunc(agg_state varchar, hwy_class varchar)
|
||||
RETURNS varchar
|
||||
IMMUTABLE
|
||||
LANGUAGE plpgsql
|
||||
LANGUAGE sql
|
||||
AS $$
|
||||
BEGIN
|
||||
RETURN val_to_highway(
|
||||
SELECT val_to_highway(
|
||||
GREATEST(
|
||||
highway_to_val(agg_state),
|
||||
highway_to_val(hwy_class)
|
||||
)
|
||||
);
|
||||
END;
|
||||
$$;
|
||||
|
||||
DROP AGGREGATE IF EXISTS highest_highway (varchar);
|
||||
|
||||
@@ -4,26 +4,44 @@
|
||||
CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level integer)
|
||||
RETURNS TABLE
|
||||
(
|
||||
geometry geometry,
|
||||
name text,
|
||||
name_en text,
|
||||
name_de text,
|
||||
tags hstore,
|
||||
ref text,
|
||||
ref_length int,
|
||||
network text,
|
||||
route_1 text,
|
||||
route_2 text,
|
||||
route_3 text,
|
||||
route_4 text,
|
||||
route_5 text,
|
||||
route_6 text,
|
||||
class text,
|
||||
subclass text,
|
||||
brunnel text,
|
||||
layer int,
|
||||
level int,
|
||||
indoor int
|
||||
geometry geometry,
|
||||
name text,
|
||||
name_en text,
|
||||
name_de text,
|
||||
tags hstore,
|
||||
ref text,
|
||||
ref_length int,
|
||||
network text,
|
||||
route_1_network text,
|
||||
route_1_ref text,
|
||||
route_1_name text,
|
||||
route_1_colour text,
|
||||
route_2_network text,
|
||||
route_2_ref text,
|
||||
route_2_name text,
|
||||
route_2_colour text,
|
||||
route_3_network text,
|
||||
route_3_ref text,
|
||||
route_3_name text,
|
||||
route_3_colour text,
|
||||
route_4_network text,
|
||||
route_4_ref text,
|
||||
route_4_name text,
|
||||
route_4_colour text,
|
||||
route_5_network text,
|
||||
route_5_ref text,
|
||||
route_5_name text,
|
||||
route_5_colour text,
|
||||
route_6_network text,
|
||||
route_6_ref text,
|
||||
route_6_name text,
|
||||
route_6_colour text,
|
||||
class text,
|
||||
subclass text,
|
||||
brunnel text,
|
||||
layer int,
|
||||
level int,
|
||||
indoor int
|
||||
)
|
||||
AS
|
||||
$$
|
||||
@@ -40,14 +58,42 @@ SELECT geometry,
|
||||
WHEN length(coalesce(ref, '')) > 0
|
||||
THEN 'road'
|
||||
END AS network,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6,
|
||||
route_1->'network' AS route_1_network,
|
||||
route_1->'ref' AS route_1_ref,
|
||||
route_1->'name' AS route_1_name,
|
||||
route_1->'colour' AS route_1_colour,
|
||||
|
||||
route_2->'network' AS route_2_network,
|
||||
route_2->'ref' AS route_2_ref,
|
||||
route_2->'name' AS route_2_name,
|
||||
route_2->'colour' AS route_2_colour,
|
||||
|
||||
route_3->'network' AS route_3_network,
|
||||
route_3->'ref' AS route_3_ref,
|
||||
route_3->'name' AS route_3_name,
|
||||
route_3->'colour' AS route_3_colour,
|
||||
|
||||
route_4->'network' AS route_4_network,
|
||||
route_4->'ref' AS route_4_ref,
|
||||
route_4->'name' AS route_4_name,
|
||||
route_4->'colour' AS route_4_colour,
|
||||
|
||||
route_5->'network' AS route_5_network,
|
||||
route_5->'ref' AS route_5_ref,
|
||||
route_5->'name' AS route_5_name,
|
||||
route_5->'colour' AS route_5_colour,
|
||||
|
||||
route_6->'network' AS route_6_network,
|
||||
route_6->'ref' AS route_6_ref,
|
||||
route_6->'name' AS route_6_name,
|
||||
route_6->'colour' AS route_6_colour,
|
||||
highway_class(highway, '', subclass) AS class,
|
||||
CASE
|
||||
WHEN highway IS NOT NULL AND highway_class(highway, '', subclass) = 'path'
|
||||
THEN highway
|
||||
ELSE subclass
|
||||
END AS subclass,
|
||||
brunnel,
|
||||
NULLIF(brunnel, '') AS brunnel,
|
||||
NULLIF(layer, 0) AS layer,
|
||||
"level",
|
||||
CASE WHEN indoor = TRUE THEN 1 END AS indoor
|
||||
@@ -94,7 +140,7 @@ FROM (
|
||||
NULL::int AS level,
|
||||
NULL::boolean AS indoor
|
||||
FROM osm_transportation_name_linestring_gen3
|
||||
WHERE zoom_level = 7
|
||||
WHERE ST_Length(geometry) > 20000 AND zoom_level = 7
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring_gen2 -> layer_transportation_name:z8
|
||||
@@ -116,7 +162,7 @@ FROM (
|
||||
NULL::int AS level,
|
||||
NULL::boolean AS indoor
|
||||
FROM osm_transportation_name_linestring_gen2
|
||||
WHERE zoom_level = 8
|
||||
WHERE ST_Length(geometry) > 14000 AND zoom_level = 8
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring_gen1 -> layer_transportation_name:z9
|
||||
@@ -140,7 +186,7 @@ FROM (
|
||||
NULL::int AS level,
|
||||
NULL::boolean AS indoor
|
||||
FROM osm_transportation_name_linestring_gen1
|
||||
WHERE zoom_level BETWEEN 9 AND 11
|
||||
WHERE ST_Length(geometry) > 8000 / POWER(2, zoom_level - 9) AND zoom_level BETWEEN 9 AND 11
|
||||
UNION ALL
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z12
|
||||
@@ -158,7 +204,7 @@ FROM (
|
||||
indoor
|
||||
FROM osm_transportation_name_linestring
|
||||
WHERE zoom_level = 12
|
||||
AND LineLabel(zoom_level, COALESCE(tags->'name', ref), geometry)
|
||||
AND LineLabel(zoom_level, COALESCE(ref, tags->'name'), geometry)
|
||||
AND NOT highway_is_link(highway)
|
||||
AND
|
||||
CASE WHEN highway_class(highway, NULL::text, NULL::text) NOT IN ('path', 'minor') THEN TRUE
|
||||
@@ -182,7 +228,7 @@ FROM (
|
||||
indoor
|
||||
FROM osm_transportation_name_linestring
|
||||
WHERE zoom_level = 13
|
||||
AND LineLabel(zoom_level, COALESCE(tags->'name', ref), geometry)
|
||||
AND LineLabel(zoom_level, COALESCE(ref, tags->'name'), geometry)
|
||||
AND
|
||||
CASE WHEN highway <> 'path' THEN TRUE
|
||||
WHEN highway = 'path' AND (
|
||||
@@ -225,12 +271,12 @@ FROM (
|
||||
'junction'::text AS subclass,
|
||||
NULL AS brunnel,
|
||||
NULL AS network,
|
||||
NULL::text AS route_1,
|
||||
NULL::text AS route_2,
|
||||
NULL::text AS route_3,
|
||||
NULL::text AS route_4,
|
||||
NULL::text AS route_5,
|
||||
NULL::text AS route_6,
|
||||
NULL::hstore AS route_1,
|
||||
NULL::hstore AS route_2,
|
||||
NULL::hstore AS route_3,
|
||||
NULL::hstore AS route_4,
|
||||
NULL::hstore AS route_5,
|
||||
NULL::hstore AS route_6,
|
||||
z_order,
|
||||
layer,
|
||||
NULL::int AS level,
|
||||
|
||||
@@ -13,8 +13,8 @@ layer:
|
||||
srs: +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over
|
||||
fields:
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Highways#Names_and_references) value of the highway.
|
||||
name_en: English name `name:en` if available, otherwise `name`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
||||
name_en: English name `name:en` if available, otherwise `name`. This is deprecated and will be removed in a future release in favor of `name:en`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`. This is deprecated and will be removed in a future release in favor of `name:de`.
|
||||
ref: The OSM [`ref`](http://wiki.openstreetmap.org/wiki/Key:ref) tag of the motorway or its network.
|
||||
ref_length: Length of the `ref` field. Useful for having a shield icon as background for labeling motorways.
|
||||
network:
|
||||
@@ -101,16 +101,34 @@ layer:
|
||||
value of [`indoor`](http://wiki.openstreetmap.org/wiki/Key:indoor) tag.
|
||||
values:
|
||||
- 1
|
||||
route_1: 1st route concurrency.
|
||||
route_2: 2nd route concurrency.
|
||||
route_3: 3rd route concurrency.
|
||||
route_4: 4th route concurrency.
|
||||
route_5: 5th route concurrency.
|
||||
route_6: 6th route concurrency.
|
||||
route_1_network: 1st route concurrency network.
|
||||
route_1_ref: 1st route concurrency ref.
|
||||
route_1_name: 1st route concurrency name.
|
||||
route_1_colour: 1st route concurrency colour.
|
||||
route_2_network: 2nd route concurrency network.
|
||||
route_2_ref: 2nd route concurrency ref.
|
||||
route_2_name: 2nd route concurrency name.
|
||||
route_2_colour: 2nd route concurrency colour.
|
||||
route_3_network: 3rd route concurrency network.
|
||||
route_3_ref: 3rd route concurrency ref.
|
||||
route_3_name: 3rd route concurrency name.
|
||||
route_3_colour: 3rd route concurrency colour.
|
||||
route_4_network: 4th route concurrency network.
|
||||
route_4_ref: 4th route concurrency ref.
|
||||
route_4_name: 4th route concurrency name.
|
||||
route_4_colour: 4th route concurrency colour.
|
||||
route_5_network: 5th route concurrency network.
|
||||
route_5_ref: 5th route concurrency ref.
|
||||
route_5_name: 5th route concurrency name.
|
||||
route_5_colour: 5th route concurrency colour.
|
||||
route_6_network: 6th route concurrency network.
|
||||
route_6_ref: 6th route concurrency ref.
|
||||
route_6_name: 6th route concurrency name.
|
||||
route_6_colour: 6th route concurrency colour.
|
||||
datasource:
|
||||
geometry_field: geometry
|
||||
srid: 900913
|
||||
query: (SELECT geometry, name, name_en, name_de, {name_languages}, ref, ref_length, network::text, class::text, subclass, brunnel, layer, level, indoor, route_1, route_2, route_3, route_4, route_5, route_6 FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
|
||||
query: (SELECT geometry, name, name_en, name_de, {name_languages}, ref, ref_length, network::text, class::text, subclass, brunnel, layer, level, indoor, route_1_network, route_1_ref, route_1_name, route_1_colour, route_2_network, route_2_ref, route_2_name, route_2_colour, route_3_network, route_3_ref, route_3_name, route_3_colour, route_4_network, route_4_ref, route_4_name, route_4_colour, route_5_network, route_5_ref, route_5_name, route_5_colour, route_6_network, route_6_ref, route_6_name, route_6_colour FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
|
||||
schema:
|
||||
- ./highway_classification.sql
|
||||
- ./update_transportation_name.sql
|
||||
|
||||
@@ -41,6 +41,8 @@ CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring(
|
||||
source integer,
|
||||
geometry geometry('LineString'),
|
||||
source_ids bigint[],
|
||||
new_source_ids bigint[],
|
||||
old_source_ids bigint[],
|
||||
tags hstore,
|
||||
ref text,
|
||||
highway varchar,
|
||||
@@ -51,16 +53,27 @@ CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring(
|
||||
layer integer,
|
||||
indoor boolean,
|
||||
network route_network_type,
|
||||
route_1 text,
|
||||
route_2 text,
|
||||
route_3 text,
|
||||
route_4 text,
|
||||
route_5 text,
|
||||
route_6 text,
|
||||
route_1 hstore,
|
||||
route_2 hstore,
|
||||
route_3 hstore,
|
||||
route_4 hstore,
|
||||
route_5 hstore,
|
||||
route_6 hstore,
|
||||
z_order integer,
|
||||
route_rank integer
|
||||
);
|
||||
|
||||
ALTER TABLE osm_transportation_name_linestring ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
-- Create temporary Merged-LineString to Source-LineStrings-ID columns to store relations before they have been
|
||||
-- intersected.
|
||||
ALTER TABLE osm_transportation_name_linestring ADD COLUMN IF NOT EXISTS new_source_ids BIGINT[];
|
||||
ALTER TABLE osm_transportation_name_linestring ADD COLUMN IF NOT EXISTS old_source_ids BIGINT[];
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_n_source_ids_not_null_idx
|
||||
ON osm_transportation_name_linestring ((new_source_ids IS NOT NULL));
|
||||
CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_o_source_ids_not_null_idx
|
||||
ON osm_transportation_name_linestring ((old_source_ids IS NOT NULL));
|
||||
|
||||
-- Create OneToMany-Relation-Table storing relations of a Merged-LineString in table
|
||||
-- osm_transportation_name_linestring to Source-LineStrings from tables osm_transportation_name_network,
|
||||
-- osm_shipway_linestring and osm_aerialway_linestring
|
||||
@@ -168,12 +181,12 @@ FROM (
|
||||
layer,
|
||||
NULL AS indoor,
|
||||
NULL AS network_type,
|
||||
NULL AS route_1,
|
||||
NULL AS route_2,
|
||||
NULL AS route_3,
|
||||
NULL AS route_4,
|
||||
NULL AS route_5,
|
||||
NULL AS route_6,
|
||||
NULL::hstore AS route_1,
|
||||
NULL::hstore AS route_2,
|
||||
NULL::hstore AS route_3,
|
||||
NULL::hstore AS route_4,
|
||||
NULL::hstore AS route_5,
|
||||
NULL::hstore AS route_6,
|
||||
min(z_order) AS z_order,
|
||||
NULL::int AS route_rank
|
||||
FROM (
|
||||
@@ -226,12 +239,12 @@ FROM (
|
||||
layer,
|
||||
NULL AS indoor,
|
||||
NULL AS network_type,
|
||||
NULL AS route_1,
|
||||
NULL AS route_2,
|
||||
NULL AS route_3,
|
||||
NULL AS route_4,
|
||||
NULL AS route_5,
|
||||
NULL AS route_6,
|
||||
NULL::hstore AS route_1,
|
||||
NULL::hstore AS route_2,
|
||||
NULL::hstore AS route_3,
|
||||
NULL::hstore AS route_4,
|
||||
NULL::hstore AS route_5,
|
||||
NULL::hstore AS route_6,
|
||||
min(z_order) AS z_order,
|
||||
NULL::int AS route_rank
|
||||
FROM (
|
||||
@@ -267,19 +280,19 @@ CREATE INDEX IF NOT EXISTS osm_transportation_name_linestring_geometry_idx
|
||||
-- Create table for simplified LineStrings
|
||||
CREATE TABLE IF NOT EXISTS osm_transportation_name_linestring_gen1 (
|
||||
id integer,
|
||||
geometry geometry('LineString'),
|
||||
geometry geometry,
|
||||
tags hstore,
|
||||
ref text,
|
||||
highway varchar,
|
||||
subclass text,
|
||||
brunnel text,
|
||||
network route_network_type,
|
||||
route_1 text,
|
||||
route_2 text,
|
||||
route_3 text,
|
||||
route_4 text,
|
||||
route_5 text,
|
||||
route_6 text,
|
||||
route_1 hstore,
|
||||
route_2 hstore,
|
||||
route_3 hstore,
|
||||
route_4 hstore,
|
||||
route_5 hstore,
|
||||
route_6 hstore,
|
||||
z_order integer
|
||||
);
|
||||
|
||||
@@ -424,25 +437,35 @@ BEGIN
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring -> osm_transportation_name_linestring_gen1
|
||||
INSERT INTO osm_transportation_name_linestring_gen1 (id, geometry, tags, ref, highway, subclass, brunnel, network,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6, z_order)
|
||||
SELECT id, ST_Simplify(geometry, 50) AS geometry, tags, ref, highway, subclass, brunnel, network, route_1, route_2,
|
||||
route_3, route_4, route_5, route_6, z_order
|
||||
FROM osm_transportation_name_linestring
|
||||
route_1, route_2, route_3, route_4, route_5, route_6)
|
||||
SELECT MIN(id) as id,
|
||||
ST_Simplify(ST_LineMerge(ST_Collect(geometry)), 50) AS geometry,
|
||||
tags, ref, highway, subclass, brunnel, network,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6
|
||||
FROM (
|
||||
SELECT id,
|
||||
geometry,
|
||||
tags, ref, highway, subclass,
|
||||
visible_text(geometry, brunnel, 9) AS brunnel,
|
||||
network, route_1, route_2, route_3, route_4, route_5, route_6
|
||||
FROM osm_transportation_name_linestring
|
||||
) osm_transportation_name_linestring_gen1_pre_merge
|
||||
WHERE (
|
||||
full_update IS TRUE OR EXISTS (
|
||||
SELECT NULL
|
||||
FROM transportation_name.name_changes_gen
|
||||
WHERE transportation_name.name_changes_gen.is_old IS FALSE AND
|
||||
transportation_name.name_changes_gen.id = osm_transportation_name_linestring.id
|
||||
transportation_name.name_changes_gen.id = osm_transportation_name_linestring_gen1_pre_merge.id
|
||||
)
|
||||
) AND (
|
||||
(highway IN ('motorway', 'trunk') OR highway = 'construction' AND subclass IN ('motorway', 'trunk')) AND
|
||||
ST_Length(geometry) > 8000
|
||||
) ON CONFLICT (id) DO UPDATE SET geometry = excluded.geometry, tags = excluded.tags, ref = excluded.ref,
|
||||
(highway IN ('motorway', 'trunk') OR highway = 'construction' AND subclass IN ('motorway', 'trunk'))
|
||||
)
|
||||
GROUP BY tags, ref, highway, subclass, brunnel, network, route_1, route_2, route_3, route_4, route_5, route_6
|
||||
ON CONFLICT (id) DO UPDATE SET geometry = excluded.geometry, tags = excluded.tags, ref = excluded.ref,
|
||||
highway = excluded.highway, subclass = excluded.subclass,
|
||||
brunnel = excluded.brunnel, network = excluded.network, route_1 = excluded.route_1,
|
||||
route_2 = excluded.route_2, route_3 = excluded.route_3, route_4 = excluded.route_4,
|
||||
route_5 = excluded.route_5, route_6 = excluded.route_6, z_order = excluded.z_order;
|
||||
route_5 = excluded.route_5, route_6 = excluded.route_6;
|
||||
|
||||
-- Analyze source table
|
||||
ANALYZE osm_transportation_name_linestring_gen1;
|
||||
@@ -457,25 +480,35 @@ BEGIN
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring_gen1 -> osm_transportation_name_linestring_gen2
|
||||
INSERT INTO osm_transportation_name_linestring_gen2 (id, geometry, tags, ref, highway, subclass, brunnel, network,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6, z_order)
|
||||
SELECT id, ST_Simplify(geometry, 120) AS geometry, tags, ref, highway, subclass, brunnel, network, route_1, route_2,
|
||||
route_3, route_4, route_5, route_6, z_order
|
||||
FROM osm_transportation_name_linestring_gen1
|
||||
route_1, route_2, route_3, route_4, route_5, route_6)
|
||||
SELECT MIN(id) as id,
|
||||
ST_Simplify(ST_LineMerge(ST_Collect(geometry)), 120) AS geometry,
|
||||
tags, ref, highway, subclass, brunnel, network,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6
|
||||
FROM (
|
||||
SELECT id,
|
||||
(ST_Dump(geometry)).geom AS geometry,
|
||||
tags, ref, highway, subclass,
|
||||
visible_text(geometry, brunnel, 8) AS brunnel,
|
||||
network, route_1, route_2, route_3, route_4, route_5, route_6
|
||||
FROM osm_transportation_name_linestring_gen1
|
||||
) osm_transportation_name_linestring_gen2_pre_merge
|
||||
WHERE (
|
||||
full_update IS TRUE OR EXISTS (
|
||||
SELECT NULL
|
||||
FROM transportation_name.name_changes_gen
|
||||
WHERE transportation_name.name_changes_gen.is_old IS FALSE AND
|
||||
transportation_name.name_changes_gen.id = osm_transportation_name_linestring_gen1.id
|
||||
transportation_name.name_changes_gen.id = osm_transportation_name_linestring_gen2_pre_merge.id
|
||||
)
|
||||
) AND (
|
||||
(highway IN ('motorway', 'trunk') OR highway = 'construction' AND subclass IN ('motorway', 'trunk')) AND
|
||||
ST_Length(geometry) > 14000
|
||||
) ON CONFLICT (id) DO UPDATE SET geometry = excluded.geometry, tags = excluded.tags, ref = excluded.ref,
|
||||
(highway IN ('motorway', 'trunk') OR highway = 'construction' AND subclass IN ('motorway', 'trunk'))
|
||||
)
|
||||
GROUP BY tags, ref, highway, subclass, brunnel, network, route_1, route_2, route_3, route_4, route_5, route_6
|
||||
ON CONFLICT (id) DO UPDATE SET geometry = excluded.geometry, tags = excluded.tags, ref = excluded.ref,
|
||||
highway = excluded.highway, subclass = excluded.subclass,
|
||||
brunnel = excluded.brunnel, network = excluded.network, route_1 = excluded.route_1,
|
||||
route_2 = excluded.route_2, route_3 = excluded.route_3, route_4 = excluded.route_4,
|
||||
route_5 = excluded.route_5, route_6 = excluded.route_6, z_order = excluded.z_order;
|
||||
route_5 = excluded.route_5, route_6 = excluded.route_6;
|
||||
|
||||
-- Analyze source table
|
||||
ANALYZE osm_transportation_name_linestring_gen2;
|
||||
@@ -490,25 +523,35 @@ BEGIN
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring_gen2 -> osm_transportation_name_linestring_gen3
|
||||
INSERT INTO osm_transportation_name_linestring_gen3 (id, geometry, tags, ref, highway, subclass, brunnel, network,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6, z_order)
|
||||
SELECT id, ST_Simplify(geometry, 200) AS geometry, tags, ref, highway, subclass, brunnel, network, route_1, route_2,
|
||||
route_3, route_4, route_5, route_6, z_order
|
||||
FROM osm_transportation_name_linestring_gen2
|
||||
route_1, route_2, route_3, route_4, route_5, route_6)
|
||||
SELECT MIN(id) as id,
|
||||
ST_Simplify(ST_LineMerge(ST_Collect(geometry)), 200) AS geometry,
|
||||
tags, ref, highway, subclass, brunnel, network,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6
|
||||
FROM (
|
||||
SELECT id,
|
||||
(ST_Dump(geometry)).geom AS geometry,
|
||||
tags, ref, highway, subclass,
|
||||
visible_text(geometry, brunnel, 7) AS brunnel,
|
||||
network, route_1, route_2, route_3, route_4, route_5, route_6
|
||||
FROM osm_transportation_name_linestring_gen2
|
||||
) osm_transportation_name_linestring_gen3_pre_merge
|
||||
WHERE (
|
||||
full_update IS TRUE OR EXISTS (
|
||||
SELECT NULL
|
||||
FROM transportation_name.name_changes_gen
|
||||
WHERE transportation_name.name_changes_gen.is_old IS FALSE AND
|
||||
transportation_name.name_changes_gen.id = osm_transportation_name_linestring_gen2.id
|
||||
transportation_name.name_changes_gen.id = osm_transportation_name_linestring_gen3_pre_merge.id
|
||||
)
|
||||
) AND (
|
||||
(highway = 'motorway' OR highway = 'construction' AND subclass = 'motorway') AND
|
||||
ST_Length(geometry) > 20000
|
||||
) ON CONFLICT (id) DO UPDATE SET geometry = excluded.geometry, tags = excluded.tags, ref = excluded.ref,
|
||||
(highway = 'motorway' OR highway = 'construction' AND subclass = 'motorway')
|
||||
)
|
||||
GROUP BY tags, ref, highway, subclass, brunnel, network, route_1, route_2, route_3, route_4, route_5, route_6
|
||||
ON CONFLICT (id) DO UPDATE SET geometry = excluded.geometry, tags = excluded.tags, ref = excluded.ref,
|
||||
highway = excluded.highway, subclass = excluded.subclass,
|
||||
brunnel = excluded.brunnel, network = excluded.network, route_1 = excluded.route_1,
|
||||
route_2 = excluded.route_2, route_3 = excluded.route_3, route_4 = excluded.route_4,
|
||||
route_5 = excluded.route_5, route_6 = excluded.route_6, z_order = excluded.z_order;
|
||||
route_5 = excluded.route_5, route_6 = excluded.route_6;
|
||||
|
||||
-- Analyze source table
|
||||
ANALYZE osm_transportation_name_linestring_gen3;
|
||||
@@ -523,25 +566,36 @@ BEGIN
|
||||
|
||||
-- etldoc: osm_transportation_name_linestring_gen3 -> osm_transportation_name_linestring_gen4
|
||||
INSERT INTO osm_transportation_name_linestring_gen4 (id, geometry, tags, ref, highway, subclass, brunnel, network,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6, z_order)
|
||||
SELECT id, ST_Simplify(geometry, 500) AS geometry, tags, ref, highway, subclass, brunnel, network, route_1, route_2,
|
||||
route_3, route_4, route_5, route_6, z_order
|
||||
FROM osm_transportation_name_linestring_gen3
|
||||
route_1, route_2, route_3, route_4, route_5, route_6)
|
||||
SELECT MIN(id) as id,
|
||||
ST_Simplify(ST_LineMerge(ST_Collect(geometry)), 500) AS geometry,
|
||||
tags, ref, highway, subclass, brunnel, network,
|
||||
route_1, route_2, route_3, route_4, route_5, route_6
|
||||
FROM (
|
||||
SELECT id,
|
||||
(ST_Dump(geometry)).geom AS geometry,
|
||||
tags, ref, highway, subclass,
|
||||
visible_text(geometry, brunnel, 6) AS brunnel,
|
||||
network, route_1, route_2, route_3, route_4, route_5, route_6
|
||||
FROM osm_transportation_name_linestring_gen3
|
||||
) osm_transportation_name_linestring_gen4_pre_merge
|
||||
WHERE (
|
||||
full_update IS TRUE OR EXISTS (
|
||||
SELECT NULL
|
||||
FROM transportation_name.name_changes_gen
|
||||
WHERE transportation_name.name_changes_gen.is_old IS FALSE AND
|
||||
transportation_name.name_changes_gen.id = osm_transportation_name_linestring_gen3.id
|
||||
transportation_name.name_changes_gen.id = osm_transportation_name_linestring_gen4_pre_merge.id
|
||||
)
|
||||
) AND (
|
||||
(highway = 'motorway' OR highway = 'construction' AND subclass = 'motorway') AND
|
||||
ST_Length(geometry) > 20000
|
||||
) ON CONFLICT (id) DO UPDATE SET geometry = excluded.geometry, tags = excluded.tags, ref = excluded.ref,
|
||||
ST_Length(geometry) > 20000 AND
|
||||
(highway = 'motorway' OR highway = 'construction' AND subclass = 'motorway')
|
||||
)
|
||||
GROUP BY tags, ref, highway, subclass, brunnel, network, route_1, route_2, route_3, route_4, route_5, route_6
|
||||
ON CONFLICT (id) DO UPDATE SET geometry = excluded.geometry, tags = excluded.tags, ref = excluded.ref,
|
||||
highway = excluded.highway, subclass = excluded.subclass,
|
||||
brunnel = excluded.brunnel, network = excluded.network, route_1 = excluded.route_1,
|
||||
route_2 = excluded.route_2, route_3 = excluded.route_3, route_4 = excluded.route_4,
|
||||
route_5 = excluded.route_5, route_6 = excluded.route_6, z_order = excluded.z_order;
|
||||
route_5 = excluded.route_5, route_6 = excluded.route_6;
|
||||
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM transportation_name.name_changes_gen;
|
||||
@@ -720,13 +774,13 @@ BEGIN
|
||||
CASE WHEN highway IN ('footway', 'steps') THEN layer END AS layer,
|
||||
CASE WHEN highway IN ('footway', 'steps') THEN level END AS level,
|
||||
CASE WHEN highway IN ('footway', 'steps') THEN indoor END AS indoor,
|
||||
NULLIF(rm1.network, '') || '=' || COALESCE(rm1.ref, '') AS route_1,
|
||||
NULLIF(rm2.network, '') || '=' || COALESCE(rm2.ref, '') AS route_2,
|
||||
NULLIF(rm3.network, '') || '=' || COALESCE(rm3.ref, '') AS route_3,
|
||||
NULLIF(rm4.network, '') || '=' || COALESCE(rm4.ref, '') AS route_4,
|
||||
NULLIF(rm5.network, '') || '=' || COALESCE(rm5.ref, '') AS route_5,
|
||||
NULLIF(rm6.network, '') || '=' || COALESCE(rm6.ref, '') AS route_6,
|
||||
hl.z_order,
|
||||
create_route_hstore(rm1.network, rm1.ref, rm1.name, rm1.colour, rm1.ref_colour) AS route_1,
|
||||
create_route_hstore(rm2.network, rm2.ref, rm2.name, rm2.colour, rm2.ref_colour) AS route_2,
|
||||
create_route_hstore(rm3.network, rm3.ref, rm3.name, rm3.colour, rm3.ref_colour) AS route_3,
|
||||
create_route_hstore(rm4.network, rm4.ref, rm4.name, rm4.colour, rm4.ref_colour) AS route_4,
|
||||
create_route_hstore(rm5.network, rm5.ref, rm5.name, rm5.colour, rm5.ref_colour) AS route_5,
|
||||
create_route_hstore(rm6.network, rm6.ref, rm6.name, rm6.colour, rm6.ref_colour) AS route_6,
|
||||
hl.z_order,
|
||||
LEAST(rm1.rank, rm2.rank, rm3.rank, rm4.rank, rm5.rank, rm6.rank) AS route_rank
|
||||
FROM osm_highway_linestring hl
|
||||
JOIN transportation_name.network_changes AS c ON
|
||||
@@ -787,6 +841,12 @@ EXECUTE PROCEDURE transportation_name.refresh_network();
|
||||
-- osm_transportation_name_linestring -> osm_transportation_name_linestring_gen3
|
||||
-- osm_transportation_name_linestring -> osm_transportation_name_linestring_gen4
|
||||
|
||||
CREATE OR REPLACE AGGREGATE array_cat_agg(anycompatiblearray) (
|
||||
SFUNC=array_cat,
|
||||
STYPE=anycompatiblearray,
|
||||
INITCOND = '{}'
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS transportation_name.name_changes
|
||||
(
|
||||
is_old boolean,
|
||||
@@ -974,8 +1034,8 @@ BEGIN
|
||||
-- Create a table containing all LineStrings which should be merged
|
||||
CREATE TEMPORARY TABLE linestrings_to_merge AS
|
||||
-- Add all Source-LineStrings affected by this update
|
||||
SELECT osm_id, NULL::INTEGER AS id, geometry, tags, ref, highway, subclass, brunnel, sac_scale, level, layer,
|
||||
indoor, network_type, route_1, route_2, route_3, route_4, route_5, route_6,
|
||||
SELECT osm_id, NULL::INTEGER AS id, NULL::BIGINT[] AS source_ids, geometry, tags, ref, highway, subclass, brunnel,
|
||||
sac_scale, level, layer, indoor, network_type, route_1, route_2, route_3, route_4, route_5, route_6,
|
||||
z_order, route_rank
|
||||
FROM (
|
||||
-- Get Source-LineString-IDs of deleted or updated elements
|
||||
@@ -987,27 +1047,30 @@ BEGIN
|
||||
ORDER BY source_id
|
||||
) affected_source_linestrings
|
||||
JOIN osm_transportation_name_network ON (
|
||||
affected_source_linestrings.source_id = osm_transportation_name_network.osm_id AND
|
||||
coalesce(tags->'name', '') <> '' OR coalesce(ref, '') <> ''
|
||||
);
|
||||
affected_source_linestrings.source_id = osm_transportation_name_network.osm_id
|
||||
)
|
||||
WHERE coalesce(tags->'name', '') <> '' OR coalesce(ref, '') <> '';
|
||||
|
||||
-- Drop temporary tables early to save resources
|
||||
DROP TABLE affected_merged_linestrings;
|
||||
|
||||
-- Create index on geometry column and analyze the created table to speed up subsequent queries
|
||||
CREATE INDEX ON linestrings_to_merge USING GIST (geometry);
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
|
||||
-- Add all Merged-LineStrings intersecting with Source-LineStrings affected by this update
|
||||
INSERT INTO linestrings_to_merge
|
||||
SELECT s.source_id AS osm_id, m.id, geometry, tags, ref, highway, subclass, brunnel, sac_scale, level,
|
||||
layer, indoor, network AS network_type, route_1, route_2, route_3, route_4, route_5, route_6, z_order,
|
||||
route_rank
|
||||
FROM osm_transportation_name_linestring m
|
||||
JOIN osm_transportation_name_linestring_source_ids s ON (s.source = 0 AND m.id = s.id)
|
||||
WHERE EXISTS(
|
||||
SELECT NULL FROM linestrings_to_merge WHERE ST_Intersects(linestrings_to_merge.geometry, m.geometry)
|
||||
);
|
||||
SELECT NULL::BIGINT AS osm_id, m.id,
|
||||
ARRAY(
|
||||
SELECT s.source_id
|
||||
FROM osm_transportation_name_linestring_source_ids s
|
||||
WHERE s.source = 0 AND m.id = s.id
|
||||
)::BIGINT[] AS source_ids,
|
||||
m.geometry, m.tags, m.ref, m.highway, m.subclass, m.brunnel, m.sac_scale,
|
||||
m.level, m.layer, m.indoor, m.network AS network_type, m.route_1, m.route_2, m.route_3,
|
||||
m.route_4, m.route_5, m.route_6, m.z_order, m.route_rank
|
||||
FROM linestrings_to_merge
|
||||
JOIN osm_transportation_name_linestring m ON (ST_Intersects(linestrings_to_merge.geometry, m.geometry))
|
||||
WHERE m.source = 0;
|
||||
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
@@ -1050,16 +1113,13 @@ BEGIN
|
||||
CREATE INDEX ON clustered_linestrings_to_merge (cluster_group, cluster);
|
||||
ANALYZE clustered_linestrings_to_merge;
|
||||
|
||||
-- Create temporary Merged-LineString to Source-LineStrings-ID column to store relations before they have been
|
||||
-- intersected
|
||||
ALTER TABLE osm_transportation_name_linestring ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
|
||||
|
||||
WITH inserted_linestrings AS (
|
||||
-- Merge LineStrings of each cluster and insert them
|
||||
INSERT INTO osm_transportation_name_linestring(source, geometry, source_ids, tags, ref, highway, subclass,
|
||||
brunnel, sac_scale, "level", layer, indoor, network, route_1,
|
||||
route_2, route_3, route_4, route_5, route_6,z_order, route_rank)
|
||||
INSERT INTO osm_transportation_name_linestring(source, geometry, new_source_ids, old_source_ids, tags, ref,
|
||||
highway, subclass, brunnel, sac_scale, "level", layer, indoor,
|
||||
network, route_1, route_2, route_3, route_4, route_5, route_6,
|
||||
z_order, route_rank)
|
||||
SELECT 0 AS source, (ST_Dump(ST_LineMerge(ST_Union(geometry)))).geom AS geometry,
|
||||
-- We use St_Union instead of St_Collect to ensure no overlapping points exist within the geometries
|
||||
-- to merge. https://postgis.net/docs/ST_Union.html
|
||||
@@ -1068,13 +1128,15 @@ BEGIN
|
||||
-- https://postgis.net/docs/ST_LineMerge.html
|
||||
-- In order to not end up with a mixture of LineStrings and MultiLineStrings we dump eventual
|
||||
-- MultiLineStrings via ST_Dump. https://postgis.net/docs/ST_Dump.html
|
||||
array_agg(osm_id) AS source_ids, tags, ref, highway, subclass, brunnel, sac_scale, level, layer,
|
||||
indoor, network_type, route_1, route_2, route_3, route_4, route_5, route_6, min(z_order) AS z_order,
|
||||
min(route_rank) AS route_rank
|
||||
coalesce( array_agg(osm_id) FILTER (WHERE osm_id IS NOT NULL), '{}' )::BIGINT[] AS new_source_ids,
|
||||
array_cat_agg(source_ids)::BIGINT[] as old_source_ids,
|
||||
tags, ref, highway, subclass, brunnel, sac_scale, level, layer,
|
||||
indoor, network_type, route_1, route_2, route_3, route_4, route_5, route_6,
|
||||
min(z_order) AS z_order, min(route_rank) AS route_rank
|
||||
FROM clustered_linestrings_to_merge
|
||||
GROUP BY cluster_group, cluster, tags, ref, highway, subclass, brunnel, level, layer, sac_scale, indoor,
|
||||
network_type, route_1, route_2, route_3, route_4, route_5, route_6
|
||||
RETURNING source, id, source_ids, geometry
|
||||
RETURNING source, id, new_source_ids, old_source_ids, geometry
|
||||
)
|
||||
-- Store OSM-IDs of Source-LineStrings by intersecting Merged-LineStrings with their sources.
|
||||
-- This is required because ST_LineMerge only merges across singular intersections and groups its output into a
|
||||
@@ -1082,8 +1144,14 @@ BEGIN
|
||||
INSERT INTO osm_transportation_name_linestring_source_ids (source, id, source_id)
|
||||
SELECT m.source, m.id, source_id
|
||||
FROM (
|
||||
SELECT source, id, unnest(source_ids) AS source_id, geometry
|
||||
SELECT source, id, source_id, geometry
|
||||
FROM inserted_linestrings
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT DISTINCT all_source_ids.source_id
|
||||
FROM unnest(
|
||||
array_cat(inserted_linestrings.new_source_ids, inserted_linestrings.old_source_ids)
|
||||
) AS all_source_ids(source_id)
|
||||
) source_ids
|
||||
) m
|
||||
JOIN osm_transportation_name_network s ON (m.source_id = s.osm_id)
|
||||
WHERE ST_Intersects(s.geometry, m.geometry)
|
||||
@@ -1092,8 +1160,9 @@ BEGIN
|
||||
-- Cleanup remaining table
|
||||
DROP TABLE clustered_linestrings_to_merge;
|
||||
|
||||
-- Drop temporary Merged-LineString to Source-LineStrings-ID column
|
||||
ALTER TABLE osm_transportation_name_linestring DROP COLUMN IF EXISTS source_ids;
|
||||
-- Restore temporary Merged-LineString to Source-LineStrings-ID columns
|
||||
UPDATE osm_transportation_name_linestring SET new_source_ids = NULL WHERE new_source_ids IS NOT NULL;
|
||||
UPDATE osm_transportation_name_linestring SET old_source_ids = NULL WHERE old_source_ids IS NOT NULL;
|
||||
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM transportation_name.name_changes;
|
||||
@@ -1119,7 +1188,7 @@ BEGIN
|
||||
-- REFRESH osm_transportation_name_linestring from osm_shipway_linestring
|
||||
|
||||
-- Analyze tracking and source tables before performing update
|
||||
ANALYZE transportation_name.name_changes;
|
||||
ANALYZE transportation_name.shipway_changes;
|
||||
ANALYZE osm_shipway_linestring;
|
||||
|
||||
-- Fetch updated and deleted Merged-LineString from relation-table filtering for each Merged-LineString which
|
||||
@@ -1155,7 +1224,7 @@ BEGIN
|
||||
-- Create a table containing all LineStrings which should be merged
|
||||
CREATE TEMPORARY TABLE linestrings_to_merge AS
|
||||
-- Add all Source-LineStrings affected by this update
|
||||
SELECT osm_id, NULL::INTEGER AS id, geometry,
|
||||
SELECT osm_id, NULL::INTEGER AS id, NULL::BIGINT[] AS source_ids, geometry,
|
||||
transportation_name_tags(
|
||||
NULL::geometry, tags, name, name_en, name_de
|
||||
) AS tags, shipway AS subclass, layer, z_order
|
||||
@@ -1169,25 +1238,28 @@ BEGIN
|
||||
ORDER BY source_id
|
||||
) affected_source_linestrings
|
||||
JOIN osm_shipway_linestring ON (
|
||||
affected_source_linestrings.source_id = osm_shipway_linestring.osm_id AND
|
||||
name <> ''
|
||||
);
|
||||
affected_source_linestrings.source_id = osm_shipway_linestring.osm_id
|
||||
)
|
||||
WHERE name <> '';
|
||||
|
||||
-- Drop temporary tables early to save resources
|
||||
DROP TABLE affected_merged_linestrings;
|
||||
|
||||
-- Create index on geometry column and analyze the created table to speed up subsequent queries
|
||||
CREATE INDEX ON linestrings_to_merge USING GIST (geometry);
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
|
||||
-- Add all Merged-LineStrings intersecting with Source-LineStrings affected by this update
|
||||
INSERT INTO linestrings_to_merge
|
||||
SELECT s.source_id AS osm_id, m.id, geometry, tags, subclass, layer, z_order
|
||||
FROM osm_transportation_name_linestring m
|
||||
JOIN osm_transportation_name_linestring_source_ids s ON (s.source = 1 AND m.id = s.id)
|
||||
WHERE EXISTS(
|
||||
SELECT NULL FROM linestrings_to_merge WHERE ST_Intersects(linestrings_to_merge.geometry, m.geometry)
|
||||
);
|
||||
SELECT NULL::BIGINT AS osm_id, m.id,
|
||||
ARRAY(
|
||||
SELECT s.source_id
|
||||
FROM osm_transportation_name_linestring_source_ids s
|
||||
WHERE s.source = 1 AND m.id = s.id
|
||||
)::BIGINT[] AS source_ids,
|
||||
m.geometry, m.tags, m.subclass, m.layer, m.z_order
|
||||
FROM linestrings_to_merge
|
||||
JOIN osm_transportation_name_linestring m ON (ST_Intersects(linestrings_to_merge.geometry, m.geometry))
|
||||
WHERE m.source = 1;
|
||||
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
@@ -1224,14 +1296,11 @@ BEGIN
|
||||
CREATE INDEX ON clustered_linestrings_to_merge (cluster_group, cluster);
|
||||
ANALYZE clustered_linestrings_to_merge;
|
||||
|
||||
-- Create temporary Merged-LineString to Source-LineStrings-ID column to store relations before they have been
|
||||
-- intersected
|
||||
ALTER TABLE osm_transportation_name_linestring ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
|
||||
WITH inserted_linestrings AS (
|
||||
-- Merge LineStrings of each cluster and insert them
|
||||
INSERT INTO osm_transportation_name_linestring(source, geometry, source_ids, tags, highway, subclass,
|
||||
z_order)
|
||||
INSERT INTO osm_transportation_name_linestring(source, geometry, new_source_ids, old_source_ids, tags, highway,
|
||||
subclass, z_order)
|
||||
SELECT 1 AS source, (ST_Dump(ST_LineMerge(ST_Union(geometry)))).geom AS geometry,
|
||||
-- We use St_Union instead of St_Collect to ensure no overlapping points exist within the geometries
|
||||
-- to merge. https://postgis.net/docs/ST_Union.html
|
||||
@@ -1240,10 +1309,12 @@ BEGIN
|
||||
-- https://postgis.net/docs/ST_LineMerge.html
|
||||
-- In order to not end up with a mixture of LineStrings and MultiLineStrings we dump eventual
|
||||
-- MultiLineStrings via ST_Dump. https://postgis.net/docs/ST_Dump.html
|
||||
array_agg(osm_id) AS source_ids, tags, 'shipway' AS highway, subclass, min(z_order) AS z_order
|
||||
coalesce( array_agg(osm_id) FILTER (WHERE osm_id IS NOT NULL), '{}' )::BIGINT[] AS new_source_ids,
|
||||
array_cat_agg(source_ids)::BIGINT[] as old_source_ids,
|
||||
tags, 'shipway' AS highway, subclass, min(z_order) AS z_order
|
||||
FROM clustered_linestrings_to_merge
|
||||
GROUP BY cluster_group, cluster, tags, subclass, layer
|
||||
RETURNING source, id, source_ids, geometry
|
||||
RETURNING source, id, new_source_ids, old_source_ids, geometry
|
||||
)
|
||||
-- Store OSM-IDs of Source-LineStrings by intersecting Merged-LineStrings with their sources.
|
||||
-- This is required because ST_LineMerge only merges across singular intersections and groups its output into a
|
||||
@@ -1251,8 +1322,14 @@ BEGIN
|
||||
INSERT INTO osm_transportation_name_linestring_source_ids (source, id, source_id)
|
||||
SELECT m.source, m.id, source_id
|
||||
FROM (
|
||||
SELECT source, id, unnest(source_ids) AS source_id, geometry
|
||||
SELECT source, id, source_id, geometry
|
||||
FROM inserted_linestrings
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT DISTINCT all_source_ids.source_id
|
||||
FROM unnest(
|
||||
array_cat(inserted_linestrings.new_source_ids, inserted_linestrings.old_source_ids)
|
||||
) AS all_source_ids(source_id)
|
||||
) source_ids
|
||||
) m
|
||||
JOIN osm_shipway_linestring s ON (m.source_id = s.osm_id)
|
||||
WHERE ST_Intersects(s.geometry, m.geometry)
|
||||
@@ -1261,8 +1338,9 @@ BEGIN
|
||||
-- Cleanup remaining table
|
||||
DROP TABLE clustered_linestrings_to_merge;
|
||||
|
||||
-- Drop temporary Merged-LineString to Source-LineStrings-ID column
|
||||
ALTER TABLE osm_transportation_name_linestring DROP COLUMN IF EXISTS source_ids;
|
||||
-- Restore temporary Merged-LineString to Source-LineStrings-ID columns
|
||||
UPDATE osm_transportation_name_linestring SET new_source_ids = NULL WHERE new_source_ids IS NOT NULL;
|
||||
UPDATE osm_transportation_name_linestring SET old_source_ids = NULL WHERE old_source_ids IS NOT NULL;
|
||||
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM transportation_name.shipway_changes;
|
||||
@@ -1288,7 +1366,7 @@ BEGIN
|
||||
-- REFRESH osm_transportation_name_linestring from osm_aerialway_linestring
|
||||
|
||||
-- Analyze tracking and source tables before performing update
|
||||
ANALYZE transportation_name.name_changes;
|
||||
ANALYZE transportation_name.aerialway_changes;
|
||||
ANALYZE osm_aerialway_linestring;
|
||||
|
||||
-- Fetch updated and deleted Merged-LineString from relation-table filtering for each Merged-LineString which
|
||||
@@ -1324,7 +1402,7 @@ BEGIN
|
||||
-- Create a table containing all LineStrings which should be merged
|
||||
CREATE TEMPORARY TABLE linestrings_to_merge AS
|
||||
-- Add all Source-LineStrings affected by this update
|
||||
SELECT osm_id, NULL::INTEGER AS id, geometry,
|
||||
SELECT osm_id, NULL::INTEGER AS id, NULL::BIGINT[] AS source_ids, geometry,
|
||||
transportation_name_tags(
|
||||
NULL::geometry, tags, name, name_en, name_de
|
||||
) AS tags, aerialway AS subclass, layer, z_order
|
||||
@@ -1338,25 +1416,28 @@ BEGIN
|
||||
ORDER BY source_id
|
||||
) affected_source_linestrings
|
||||
JOIN osm_aerialway_linestring ON (
|
||||
affected_source_linestrings.source_id = osm_aerialway_linestring.osm_id AND
|
||||
name <> ''
|
||||
);
|
||||
affected_source_linestrings.source_id = osm_aerialway_linestring.osm_id
|
||||
)
|
||||
WHERE name <> '';
|
||||
|
||||
-- Drop temporary tables early to save resources
|
||||
DROP TABLE affected_merged_linestrings;
|
||||
|
||||
-- Create index on geometry column and analyze the created table to speed up subsequent queries
|
||||
CREATE INDEX ON linestrings_to_merge USING GIST (geometry);
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
|
||||
-- Add all Merged-LineStrings intersecting with Source-LineStrings affected by this update
|
||||
INSERT INTO linestrings_to_merge
|
||||
SELECT s.source_id AS osm_id, m.id, geometry, tags, subclass, layer, z_order
|
||||
FROM osm_transportation_name_linestring m
|
||||
JOIN osm_transportation_name_linestring_source_ids s ON (s.source = 2 AND m.id = s.id)
|
||||
WHERE EXISTS(
|
||||
SELECT NULL FROM linestrings_to_merge WHERE ST_Intersects(linestrings_to_merge.geometry, m.geometry)
|
||||
);
|
||||
SELECT NULL::BIGINT AS osm_id, m.id,
|
||||
ARRAY(
|
||||
SELECT s.source_id
|
||||
FROM osm_transportation_name_linestring_source_ids s
|
||||
WHERE s.source = 2 AND m.id = s.id
|
||||
)::BIGINT[] AS source_ids,
|
||||
m.geometry, m.tags, m.subclass, m.layer, m.z_order
|
||||
FROM linestrings_to_merge
|
||||
JOIN osm_transportation_name_linestring m ON (ST_Intersects(linestrings_to_merge.geometry, m.geometry))
|
||||
WHERE m.source = 2;
|
||||
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
@@ -1393,14 +1474,11 @@ BEGIN
|
||||
CREATE INDEX ON clustered_linestrings_to_merge (cluster_group, cluster);
|
||||
ANALYZE clustered_linestrings_to_merge;
|
||||
|
||||
-- Create temporary Merged-LineString to Source-LineStrings-ID column to store relations before they have been
|
||||
-- intersected
|
||||
ALTER TABLE osm_transportation_name_linestring ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
|
||||
WITH inserted_linestrings AS (
|
||||
-- Merge LineStrings of each cluster and insert them
|
||||
INSERT INTO osm_transportation_name_linestring(source, geometry, source_ids, tags, highway, subclass,
|
||||
z_order)
|
||||
INSERT INTO osm_transportation_name_linestring(source, geometry, new_source_ids, old_source_ids, tags, highway,
|
||||
subclass, z_order)
|
||||
SELECT 2 AS source, (ST_Dump(ST_LineMerge(ST_Union(geometry)))).geom AS geometry,
|
||||
-- We use St_Union instead of St_Collect to ensure no overlapping points exist within the geometries
|
||||
-- to merge. https://postgis.net/docs/ST_Union.html
|
||||
@@ -1409,10 +1487,12 @@ BEGIN
|
||||
-- https://postgis.net/docs/ST_LineMerge.html
|
||||
-- In order to not end up with a mixture of LineStrings and MultiLineStrings we dump eventual
|
||||
-- MultiLineStrings via ST_Dump. https://postgis.net/docs/ST_Dump.html
|
||||
array_agg(osm_id) AS source_ids, tags, 'aerialway' AS highway, subclass, min(z_order) AS z_order
|
||||
coalesce( array_agg(osm_id) FILTER (WHERE osm_id IS NOT NULL), '{}' )::BIGINT[] AS new_source_ids,
|
||||
array_cat_agg(source_ids)::BIGINT[] as old_source_ids,
|
||||
tags, 'aerialway' AS highway, subclass, min(z_order) AS z_order
|
||||
FROM clustered_linestrings_to_merge
|
||||
GROUP BY cluster_group, cluster, tags, subclass, layer
|
||||
RETURNING source, id, source_ids, geometry
|
||||
RETURNING source, id, new_source_ids, old_source_ids, geometry
|
||||
)
|
||||
-- Store OSM-IDs of Source-LineStrings by intersecting Merged-LineStrings with their sources.
|
||||
-- This is required because ST_LineMerge only merges across singular intersections and groups its output into a
|
||||
@@ -1420,8 +1500,14 @@ BEGIN
|
||||
INSERT INTO osm_transportation_name_linestring_source_ids (source, id, source_id)
|
||||
SELECT m.source, m.id, source_id
|
||||
FROM (
|
||||
SELECT source, id, unnest(source_ids) AS source_id, geometry
|
||||
SELECT source, id, source_id, geometry
|
||||
FROM inserted_linestrings
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT DISTINCT all_source_ids.source_id
|
||||
FROM unnest(
|
||||
array_cat(inserted_linestrings.new_source_ids, inserted_linestrings.old_source_ids)
|
||||
) AS all_source_ids(source_id)
|
||||
) source_ids
|
||||
) m
|
||||
JOIN osm_aerialway_linestring s ON (m.source_id = s.osm_id)
|
||||
WHERE ST_Intersects(s.geometry, m.geometry)
|
||||
@@ -1430,8 +1516,9 @@ BEGIN
|
||||
-- Cleanup remaining table
|
||||
DROP TABLE clustered_linestrings_to_merge;
|
||||
|
||||
-- Drop temporary Merged-LineString to Source-LineStrings-ID column
|
||||
ALTER TABLE osm_transportation_name_linestring DROP COLUMN IF EXISTS source_ids;
|
||||
-- Restore temporary Merged-LineString to Source-LineStrings-ID columns
|
||||
UPDATE osm_transportation_name_linestring SET new_source_ids = NULL WHERE new_source_ids IS NOT NULL;
|
||||
UPDATE osm_transportation_name_linestring SET old_source_ids = NULL WHERE old_source_ids IS NOT NULL;
|
||||
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM transportation_name.aerialway_changes;
|
||||
|
||||
@@ -40,7 +40,7 @@ layer:
|
||||
river:
|
||||
water: ['river', 'stream', 'canal', 'ditch', 'drain']
|
||||
pond:
|
||||
water: ['pond', 'basin', 'wastewater']
|
||||
water: ['pond', 'basin', 'wastewater', 'salt_pond']
|
||||
lake:
|
||||
ocean:
|
||||
swimming_pool:
|
||||
|
||||
@@ -18,8 +18,11 @@ $$
|
||||
SELECT osm.osm_id, ne.scalerank
|
||||
FROM osm_marine_point AS osm
|
||||
LEFT JOIN ne_10m_geography_marine_polys AS ne ON
|
||||
lower(trim(regexp_replace(ne.name, '\\s+', ' ', 'g'))) IN (lower(osm.name), lower(osm.tags->'name:en'), lower(osm.tags->'name:es'))
|
||||
OR substring(lower(trim(regexp_replace(ne.name, '\\s+', ' ', 'g'))) FROM 1 FOR length(lower(osm.name))) = lower(osm.name)
|
||||
(
|
||||
lower(trim(regexp_replace(ne.name, '\\s+', ' ', 'g'))) IN (lower(osm.name), lower(osm.tags->'name:en'), lower(osm.tags->'name:es'))
|
||||
OR substring(lower(trim(regexp_replace(ne.name, '\\s+', ' ', 'g'))) FROM 1 FOR length(lower(osm.name))) = lower(osm.name)
|
||||
)
|
||||
AND ST_DWithin(ne.geometry, osm.geometry, 50000)
|
||||
)
|
||||
UPDATE osm_marine_point AS osm
|
||||
SET "rank" = scalerank
|
||||
@@ -90,12 +93,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_marine_point
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE water_name_marine.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE
|
||||
ON osm_marine_point
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE water_name_marine.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -197,12 +197,14 @@ CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON osm_water_polygon
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE water_name.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON osm_water_polygon
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE water_name.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -9,9 +9,9 @@ layer:
|
||||
This is based of the [osm-lakelines](https://github.com/openmaptiles/osm-lakelines) project
|
||||
which derives nice centerlines from OSM water bodies. Only the most important lakes contain labels.
|
||||
fields:
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the water body.
|
||||
name_en: English name `name:en` if available, otherwise `name`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
||||
name: The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the water body. Language-specific values are in `name:xx`.
|
||||
name_en: English name `name:en` if available, otherwise `name`. This is deprecated and will be removed in a future release in favor of `name:en`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`. This is deprecated and will be removed in a future release in favor of `name:de`.
|
||||
class:
|
||||
description: |
|
||||
Distinguish between `lake`, `ocean`, `bay`, `strait`, and `sea`.
|
||||
|
||||
@@ -21,18 +21,33 @@ CREATE TABLE IF NOT EXISTS osm_important_waterway_linestring (
|
||||
id SERIAL,
|
||||
geometry geometry('LineString'),
|
||||
source_ids bigint[],
|
||||
new_source_ids bigint[],
|
||||
old_source_ids bigint[],
|
||||
name varchar,
|
||||
name_en varchar,
|
||||
name_de varchar,
|
||||
tags hstore
|
||||
);
|
||||
|
||||
ALTER TABLE osm_important_waterway_linestring ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
-- Create temporary Merged-LineString to Source-LineStrings-ID columns to store relations before they have been
|
||||
-- intersected
|
||||
ALTER TABLE osm_important_waterway_linestring ADD COLUMN IF NOT EXISTS new_source_ids BIGINT[];
|
||||
ALTER TABLE osm_important_waterway_linestring ADD COLUMN IF NOT EXISTS old_source_ids BIGINT[];
|
||||
|
||||
CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_n_source_ids_not_null_idx
|
||||
ON osm_important_waterway_linestring ((new_source_ids IS NOT NULL));
|
||||
CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_o_source_ids_not_null_idx
|
||||
ON osm_important_waterway_linestring ((old_source_ids IS NOT NULL));
|
||||
|
||||
-- Create osm_important_waterway_linestring_gen_z11 as a copy of osm_important_waterway_linestring but drop the
|
||||
-- "source_ids" column. This can be done because z10 and z9 tables are only simplified and not merged, therefore
|
||||
-- relations to sources are direct via the id column.
|
||||
CREATE TABLE IF NOT EXISTS osm_important_waterway_linestring_gen_z11
|
||||
(LIKE osm_important_waterway_linestring);
|
||||
ALTER TABLE osm_important_waterway_linestring_gen_z11 DROP COLUMN IF EXISTS source_ids;
|
||||
ALTER TABLE osm_important_waterway_linestring_gen_z11 DROP COLUMN IF EXISTS new_source_ids;
|
||||
ALTER TABLE osm_important_waterway_linestring_gen_z11 DROP COLUMN IF EXISTS old_source_ids;
|
||||
|
||||
-- Create osm_important_waterway_linestring_gen_z10 as a copy of osm_important_waterway_linestring_gen_z11
|
||||
CREATE TABLE IF NOT EXISTS osm_important_waterway_linestring_gen_z10
|
||||
@@ -304,6 +319,12 @@ CREATE INDEX IF NOT EXISTS osm_important_waterway_linestring_gen_z9_geometry_idx
|
||||
-- -- osm_important_waterway_linestring -> osm_important_waterway_linestring_gen_z10
|
||||
-- -- osm_important_waterway_linestring -> osm_important_waterway_linestring_gen_z9
|
||||
|
||||
CREATE OR REPLACE AGGREGATE array_cat_agg(anycompatiblearray) (
|
||||
SFUNC=array_cat,
|
||||
STYPE=anycompatiblearray,
|
||||
INITCOND = '{}'
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS waterway_important.changes
|
||||
(
|
||||
osm_id bigint,
|
||||
@@ -403,7 +424,8 @@ BEGIN
|
||||
-- Create a table containing all LineStrings which should be merged
|
||||
CREATE TEMPORARY TABLE linestrings_to_merge AS
|
||||
-- Add all Source-LineStrings affected by this update
|
||||
SELECT osm_id, NULL::INTEGER AS id, geometry, name, name_en, name_de, slice_language_tags(tags) as tags
|
||||
SELECT osm_id, NULL::INTEGER AS id, NULL::BIGINT[] AS source_ids, geometry, name, name_en, name_de,
|
||||
slice_language_tags(tags) as tags
|
||||
-- Table containing the IDs of all Source-LineStrings affected by this update
|
||||
FROM (
|
||||
-- Get Source-LineString-IDs of deleted or updated elements
|
||||
@@ -414,23 +436,25 @@ BEGIN
|
||||
ORDER BY source_id
|
||||
) affected_source_linestrings
|
||||
JOIN osm_waterway_linestring ON (
|
||||
affected_source_linestrings.source_id = osm_waterway_linestring.osm_id AND
|
||||
name <> '' AND waterway = 'river' AND ST_IsValid(geometry)
|
||||
);
|
||||
affected_source_linestrings.source_id = osm_waterway_linestring.osm_id
|
||||
)
|
||||
WHERE name <> '' AND waterway = 'river' AND ST_IsValid(geometry);
|
||||
|
||||
-- Drop temporary tables early to save resources
|
||||
DROP TABLE affected_merged_linestrings;
|
||||
|
||||
-- Create index on geometry column and analyze the created table to speed up subsequent queries
|
||||
CREATE INDEX ON linestrings_to_merge USING GIST (geometry);
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
|
||||
-- Add all Merged-LineStrings intersecting with Source-LineStrings affected by this update
|
||||
INSERT INTO linestrings_to_merge
|
||||
SELECT s.source_id AS osm_id, m.id, geometry, name, name_en, name_de, tags
|
||||
FROM osm_important_waterway_linestring m
|
||||
JOIN osm_important_waterway_linestring_source_ids s ON (m.id = s.id)
|
||||
WHERE EXISTS(SELECT NULL FROM linestrings_to_merge WHERE ST_Intersects(linestrings_to_merge.geometry, m.geometry));
|
||||
SELECT NULL::BIGINT AS osm_id, m.id,
|
||||
ARRAY(
|
||||
SELECT s.source_id FROM osm_important_waterway_linestring_source_ids s WHERE s.id = m.id
|
||||
)::BIGINT[] AS source_ids,
|
||||
m.geometry, m.name, m.name_en, m.name_de, m.tags
|
||||
FROM linestrings_to_merge
|
||||
JOIN osm_important_waterway_linestring m ON (ST_Intersects(linestrings_to_merge.geometry, m.geometry));
|
||||
|
||||
-- Analyze the created table to speed up subsequent queries
|
||||
ANALYZE linestrings_to_merge;
|
||||
@@ -467,13 +491,11 @@ BEGIN
|
||||
CREATE INDEX ON clustered_linestrings_to_merge (cluster_group, cluster);
|
||||
ANALYZE clustered_linestrings_to_merge;
|
||||
|
||||
-- Create temporary Merged-LineString to Source-LineStrings-ID column to store relations before they have been
|
||||
-- intersected
|
||||
ALTER TABLE osm_important_waterway_linestring ADD COLUMN IF NOT EXISTS source_ids bigint[];
|
||||
|
||||
WITH inserted_linestrings AS (
|
||||
-- Merge LineStrings of each cluster and insert them
|
||||
INSERT INTO osm_important_waterway_linestring (geometry, source_ids, name, name_en, name_de, tags)
|
||||
INSERT INTO osm_important_waterway_linestring (geometry, new_source_ids, old_source_ids, name, name_en, name_de,
|
||||
tags)
|
||||
SELECT (ST_Dump(ST_LineMerge(ST_Union(geometry)))).geom AS geometry,
|
||||
-- We use St_Union instead of St_Collect to ensure no overlapping points exist within the geometries
|
||||
-- to merge. https://postgis.net/docs/ST_Union.html
|
||||
@@ -482,14 +504,15 @@ BEGIN
|
||||
-- https://postgis.net/docs/ST_LineMerge.html
|
||||
-- In order to not end up with a mixture of LineStrings and MultiLineStrings we dump eventual
|
||||
-- MultiLineStrings via ST_Dump. https://postgis.net/docs/ST_Dump.html
|
||||
array_agg(osm_id) as source_ids,
|
||||
coalesce( array_agg(osm_id) FILTER (WHERE osm_id IS NOT NULL), '{}' )::BIGINT[] AS new_source_ids,
|
||||
array_cat_agg(source_ids)::BIGINT[] as old_source_ids,
|
||||
name,
|
||||
name_en,
|
||||
name_de,
|
||||
tags
|
||||
FROM clustered_linestrings_to_merge
|
||||
GROUP BY cluster_group, cluster, name, name_en, name_de, tags
|
||||
RETURNING id, source_ids, geometry
|
||||
RETURNING id, new_source_ids, old_source_ids, geometry
|
||||
)
|
||||
-- Store OSM-IDs of Source-LineStrings by intersecting Merged-LineStrings with their sources.
|
||||
-- This is required because ST_LineMerge only merges across singular intersections and groups its output into a
|
||||
@@ -497,8 +520,14 @@ BEGIN
|
||||
INSERT INTO osm_important_waterway_linestring_source_ids (id, source_id)
|
||||
SELECT m.id, source_id
|
||||
FROM (
|
||||
SELECT id, unnest(source_ids) AS source_id, geometry
|
||||
SELECT id, source_id, geometry
|
||||
FROM inserted_linestrings
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT DISTINCT all_source_ids.source_id
|
||||
FROM unnest(
|
||||
array_cat(inserted_linestrings.new_source_ids, inserted_linestrings.old_source_ids)
|
||||
) AS all_source_ids(source_id)
|
||||
) source_ids
|
||||
) m
|
||||
JOIN osm_waterway_linestring s ON (m.source_id = s.osm_id)
|
||||
WHERE ST_Intersects(s.geometry, m.geometry)
|
||||
@@ -507,8 +536,9 @@ BEGIN
|
||||
-- Cleanup remaining table
|
||||
DROP TABLE clustered_linestrings_to_merge;
|
||||
|
||||
-- Drop temporary Merged-LineString to Source-LineStrings-ID column
|
||||
ALTER TABLE osm_important_waterway_linestring DROP COLUMN IF EXISTS source_ids;
|
||||
-- Restore temporary Merged-LineString to Source-LineStrings-ID columns
|
||||
UPDATE osm_important_waterway_linestring SET new_source_ids = NULL WHERE new_source_ids IS NOT NULL;
|
||||
UPDATE osm_important_waterway_linestring SET old_source_ids = NULL WHERE old_source_ids IS NOT NULL;
|
||||
|
||||
-- noinspection SqlWithoutWhere
|
||||
DELETE FROM waterway_important.changes;
|
||||
@@ -528,18 +558,21 @@ CREATE TRIGGER trigger_important_waterway_linestring_store
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON osm_important_waterway_linestring
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE waterway_important.important_waterway_linestring_store();
|
||||
|
||||
CREATE TRIGGER trigger_store
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON osm_waterway_linestring
|
||||
FOR EACH ROW
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE waterway_important.store();
|
||||
|
||||
CREATE TRIGGER trigger_flag
|
||||
AFTER INSERT OR UPDATE OR DELETE
|
||||
ON osm_waterway_linestring
|
||||
FOR EACH STATEMENT
|
||||
WHEN (pg_trigger_depth() < 1)
|
||||
EXECUTE PROCEDURE waterway_important.flag();
|
||||
|
||||
CREATE CONSTRAINT TRIGGER trigger_refresh
|
||||
|
||||
@@ -18,10 +18,10 @@ layer:
|
||||
buffer_size: 4
|
||||
fields:
|
||||
name: |
|
||||
The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the waterway.
|
||||
The OSM [`name`](http://wiki.openstreetmap.org/wiki/Key:name) value of the waterway. Language-specific values are in `name:xx`.
|
||||
The `name` field may be empty for NaturalEarth data or at lower zoom levels.
|
||||
name_en: English name `name:en` if available, otherwise `name`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
|
||||
name_en: English name `name:en` if available, otherwise `name`. This is deprecated and will be removed in a future release in favor of `name:en`.
|
||||
name_de: German name `name:de` if available, otherwise `name` or `name:en`. This is deprecated and will be removed in a future release in favor of `name:de`.
|
||||
class:
|
||||
description: |
|
||||
The original value of the [`waterway`](http://wiki.openstreetmap.org/wiki/Key:waterway) tag.
|
||||
|
||||