Merge branch 'master' of https://github.com/openmaptiles/openmaptiles into merge-github

# Conflicts:
#	Makefile
#	QUICKSTART.md
#	docker-compose.yml
#	layers/boundary/mapping.yaml
#	layers/landuse/landuse.sql
#	layers/landuse/landuse.yaml
#	layers/landuse/mapping.yaml
#	layers/poi/mapping.yaml
#	layers/poi/poi.sql
#	layers/poi/poi.yaml
This commit is contained in:
2023-04-09 20:39:41 +02:00
465 changed files with 23727 additions and 2256 deletions

View File

@@ -1,11 +1,11 @@
-- etldoc: layer_aerodrome_label[shape=record fillcolor=lightpink, style="rounded,filled", label="layer_aerodrome_label | <z10_> z10+" ] ;
-- etldoc: layer_aerodrome_label[shape=record fillcolor=lightpink, style="rounded,filled", label="layer_aerodrome_label | <z8> z8 | <z9> z9 | <z10_> z10+" ] ;
CREATE OR REPLACE FUNCTION layer_aerodrome_label(bbox geometry,
zoom_level integer)
RETURNS TABLE
(
osm_id bigint,
id bigint,
geometry geometry,
name text,
name_en text,
@@ -20,17 +20,36 @@ CREATE OR REPLACE FUNCTION layer_aerodrome_label(bbox geometry,
AS
$$
SELECT
-- etldoc: osm_aerodrome_label_point -> layer_aerodrome_label:z10_
osm_id,
-- etldoc: osm_aerodrome_label_point -> layer_aerodrome_label:z8
-- etldoc: osm_aerodrome_label_point -> layer_aerodrome_label:z9
ABS(osm_id) AS id, -- mvt feature IDs can't be negative
geometry,
name,
COALESCE(NULLIF(name_en, ''), name) AS name_en,
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
tags,
CASE
%%FIELD_MAPPING: class %%
ELSE 'other'
END AS class,
aerodrome_type AS class,
NULLIF(iata, '') AS iata,
NULLIF(icao, '') AS icao,
substring(ele FROM E'^(-?\\d+)(\\D|$)')::int AS ele,
round(substring(ele FROM E'^(-?\\d+)(\\D|$)')::int * 3.2808399)::int AS ele_ft
FROM osm_aerodrome_label_point
WHERE geometry && bbox
AND aerodrome_type = 'international'
AND iata <> ''
AND zoom_level BETWEEN 8 AND 9
UNION ALL
SELECT
-- etldoc: osm_aerodrome_label_point -> layer_aerodrome_label:z10_
ABS(osm_id) AS id, -- mvt feature IDs can't be negative
geometry,
name,
COALESCE(NULLIF(name_en, ''), name) AS name_en,
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
tags,
aerodrome_type AS class,
NULLIF(iata, '') AS iata,
NULLIF(icao, '') AS icao,
substring(ele FROM E'^(-?\\d+)(\\D|$)')::int AS ele,

View File

@@ -1,5 +1,5 @@
layer:
id: "aerodrome_label"
id: aerodrome_label
description: |
[Aerodrome labels](http://wiki.openstreetmap.org/wiki/Tag:aeroway%3Daerodrome)
buffer_size: 64
@@ -38,10 +38,10 @@ layer:
ele_ft: Elevation (`ele`) in feets.
datasource:
geometry_field: geometry
key_field: osm_id
key_field: id
key_field_as_attribute: no
srid: 900913
query: (SELECT osm_id, geometry, name, name_en, name_de, {name_languages}, class, iata, icao, ele, ele_ft FROM layer_aerodrome_label(!bbox!, z(!scale_denominator!))) AS t
query: (SELECT id, geometry, name, name_en, name_de, {name_languages}, class, iata, icao, ele, ele_ft FROM layer_aerodrome_label(!bbox!, z(!scale_denominator!))) AS t
schema:
- ./update_aerodrome_label_point.sql
- ./aerodrome_label.sql

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,69 @@
{
"layers": [
{
"id": "airport-label-major",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "aerodrome_label",
"minzoom": 8,
"maxzoom": 17,
"layout": {
"icon-size": 1,
"text-font": [
"Noto Sans Italic"
],
"text-size": {
"stops": [
[
8,
10
],
[
14,
12
]
]
},
"icon-image": "aerodrome.12",
"text-field": {
"stops": [
[
8,
" "
],
[
11,
"{name:latin}\n{name:nonlatin}"
]
]
},
"visibility": "visible",
"text-anchor": "top",
"text-offset": [
0,
0.6
],
"text-padding": 2,
"text-optional": true,
"symbol-z-order": "auto",
"text-max-width": 9,
"icon-allow-overlap": false,
"text-allow-overlap": false
},
"paint": {
"text-color": "#5e3b9e",
"text-halo-blur": 0.5,
"text-halo-color": "rgba(255, 255, 255, 0.8)",
"text-halo-width": 1
},
"filter": [
"all",
[
"has",
"iata"
]
],
"order": 190
}
]
}

View File

@@ -2,11 +2,17 @@ DROP TRIGGER IF EXISTS trigger_flag ON osm_aerodrome_label_point;
DROP TRIGGER IF EXISTS trigger_store ON osm_aerodrome_label_point;
DROP TRIGGER IF EXISTS trigger_refresh ON aerodrome_label.updates;
-- Partial index for zoom 8/9 queries
CREATE INDEX IF NOT EXISTS osm_aerodrome_label_point_type_partial_idx
ON osm_aerodrome_label_point USING gist (geometry)
WHERE aerodrome_type = 'international'
AND iata <> '';
CREATE SCHEMA IF NOT EXISTS aerodrome_label;
CREATE TABLE IF NOT EXISTS aerodrome_label.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
-- etldoc: osm_aerodrome_label_point -> osm_aerodrome_label_point
@@ -22,6 +28,17 @@ $$
WHERE (full_update OR osm_id IN (SELECT osm_id FROM aerodrome_label.osm_ids))
AND COALESCE(tags->'name:latin', tags->'name:nonlatin', tags->'name_int') IS NULL
AND tags != update_tags(tags, geometry);
UPDATE osm_aerodrome_label_point
SET aerodrome_type=
CASE
%%FIELD_MAPPING: class %%
ELSE 'other' END
WHERE (full_update OR osm_id IN (SELECT osm_id FROM aerodrome_label.osm_ids))
AND aerodrome_type !=
CASE
%%FIELD_MAPPING: class %%
ELSE 'other' END;
$$ LANGUAGE SQL;
SELECT update_aerodrome_label_point(true);
@@ -31,11 +48,7 @@ SELECT update_aerodrome_label_point(true);
CREATE OR REPLACE FUNCTION aerodrome_label.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO aerodrome_label.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO aerodrome_label.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO aerodrome_label.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -60,6 +73,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh aerodrome_label';
-- Analyze tracking and source tables before performing update
ANALYZE aerodrome_label.osm_ids;
ANALYZE osm_aerodrome_label_point;
PERFORM update_aerodrome_label_point(false);
-- noinspection SqlWithoutWhere
DELETE FROM aerodrome_label.osm_ids;
@@ -72,13 +90,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_aerodrome_label_point
FOR EACH ROW
EXECUTE PROCEDURE aerodrome_label.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_aerodrome_label_point
FOR EACH STATEMENT
EXECUTE PROCEDURE aerodrome_label.flag();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

203
layers/aeroway/style.json Normal file
View File

@@ -0,0 +1,203 @@
{
"layers": [
{
"id": "aeroway_fill",
"type": "fill",
"source": "openmaptiles",
"source-layer": "aeroway",
"minzoom": 11,
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": {
"stops": [
[
6,
"rgba(223, 223, 228, 1)"
],
[
12,
"rgba(232, 231, 223, 1)"
]
]
},
"fill-opacity": 1
},
"metadata": {},
"filter": [
"==",
"$type",
"Polygon"
],
"order": 3
},
{
"id": "aeroway_runway",
"type": "line",
"source": "openmaptiles",
"source-layer": "aeroway",
"minzoom": 11,
"layout": {
"visibility": "visible"
},
"paint": {
"line-color": "rgba(178, 181, 209, 1)",
"line-width": {
"base": 1.2,
"stops": [
[
11,
3
],
[
20,
48
]
]
},
"line-opacity": 1
},
"metadata": {},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"==",
"class",
"runway"
]
],
"order": 22
},
{
"id": "aeroway_taxiway",
"type": "line",
"source": "openmaptiles",
"source-layer": "aeroway",
"minzoom": 11,
"layout": {
"visibility": "visible"
},
"paint": {
"line-color": "rgba(178, 181, 209, 1)",
"line-width": {
"base": 1.2,
"stops": [
[
11,
1
],
[
20,
24
]
]
},
"line-opacity": 1
},
"metadata": {},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"==",
"class",
"taxiway"
]
],
"order": 23
},
{
"id": "airport_label",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "aeroway",
"minzoom": 14,
"layout": {
"text-font": [
"Noto Sans Italic",
"Noto Sans Regular"
],
"text-size": {
"stops": [
[
15,
9
],
[
19,
15
]
]
},
"text-field": "{ref}",
"visibility": "visible",
"symbol-placement": "line"
},
"paint": {
"text-color": "#333333",
"text-halo-color": "rgba(255, 255, 255, 0.8)",
"text-halo-width": 1
},
"filter": [
"all",
[
"in",
"class",
"runway",
"taxiway"
]
],
"order": 191
},
{
"id": "airport_gate",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "aeroway",
"minzoom": 16.5,
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"stops": [
[
17,
9
],
[
19,
15
]
]
},
"text-field": "{ref}",
"visibility": "visible"
},
"paint": {
"text-color": "rgba(135, 135, 135, 1)",
"text-halo-color": "rgba(255, 255, 255, 1)",
"text-halo-width": 1
},
"filter": [
"all",
[
"==",
"class",
"gate"
]
],
"order": 192
}
]
}

View File

@@ -1,207 +1,187 @@
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z13 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
-- etldoc: osm_border_linestring -> osm_border_linestring_gen_z13
-- etldoc: osm_border_linestring_adm -> osm_border_linestring_gen_z13
-- etldoc: osm_border_disp_linestring -> osm_border_linestring_gen_z13
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z13 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z13 AS
(
SELECT ST_Simplify(geometry, ZRes(14)) AS geometry, NULL::text AS adm0_l, NULL::text AS adm0_r, admin_level, disputed, maritime
FROM osm_border_linestring
WHERE admin_level BETWEEN 3 AND 10
UNION ALL
SELECT ST_Simplify(geometry, ZRes(14)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
FROM osm_border_linestring_adm
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z13_idx ON osm_border_linestring_gen_z13 USING gist (geometry);
SELECT ST_Simplify(ST_Collect(geometry), ZRes(14)) AS geometry,
MAX(adm0_l) AS adm0_l,
MAX(adm0_r) AS adm0_r,
MIN(admin_level) AS admin_level,
BOOL_OR(disputed) AS disputed,
MAX(name) AS name,
MAX(claimed_by) AS claimed_by,
BOOL_OR(maritime) AS maritime
FROM (
-- All admin 3-10 boundaries
SELECT osm_id,
geometry,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
MIN(admin_level) AS admin_level,
BOOL_OR(disputed)
OR BOOL_OR(dispute)
OR BOOL_OR(border_status = 'disputed')
OR BOOL_OR(disputed_by <> '') AS disputed,
NULLIF(name, '') AS name,
NULLIF(claimed_by, '') AS claimed_by,
BOOL_OR(maritime) AS maritime
FROM osm_border_linestring
WHERE admin_level BETWEEN 3 AND 10
AND type = 1 -- ways only
GROUP BY osm_id, geometry, name, claimed_by
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z12 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
UNION ALL
-- All non-disputed admin 2 boundaries
SELECT osm_id,
geometry,
adm0_l,
adm0_r,
admin_level,
FALSE AS disputed,
NULL::text AS name,
NULL::text AS claimed_by,
maritime
FROM osm_border_linestring_adm
UNION ALL
-- All disputed admin 2 boundaries
SELECT osm_id,
geometry,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
2::int AS admin_level,
TRUE AS disputed,
NULLIF(name, '') AS name,
NULLIF(claimed_by, '') AS claimed_by,
maritime
FROM osm_border_disp_linestring
GROUP BY osm_id, geometry, name, claimed_by, maritime
) AS merged_boundary
GROUP by osm_id
)/* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z13_idx ON osm_border_linestring_gen_z13 USING gist (geometry);
-- etldoc: osm_border_linestring_gen_z13 -> osm_border_linestring_gen_z12
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z12 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z12 AS
(
SELECT ST_Simplify(geometry, ZRes(13)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
SELECT ST_Simplify(geometry, ZRes(13)) AS geometry, adm0_l, adm0_r, admin_level, disputed, name, claimed_by, maritime
FROM osm_border_linestring_gen_z13
WHERE admin_level BETWEEN 2 AND 10
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z12_idx ON osm_border_linestring_gen_z12 USING gist (geometry);
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z11 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
-- etldoc: osm_border_linestring_gen_z12 -> osm_border_linestring_gen_z11
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z11 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z11 AS
(
SELECT ST_Simplify(geometry, ZRes(12)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
SELECT ST_Simplify(geometry, ZRes(12)) AS geometry, adm0_l, adm0_r, admin_level, disputed, name, claimed_by, maritime
FROM osm_border_linestring_gen_z12
WHERE admin_level BETWEEN 2 AND 8
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z11_idx ON osm_border_linestring_gen_z11 USING gist (geometry);
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z10 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
-- etldoc: osm_border_linestring_gen_z11 -> osm_border_linestring_gen_z10
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z10 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z10 AS
(
SELECT ST_Simplify(geometry, ZRes(11)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
SELECT ST_Simplify(geometry, ZRes(11)) AS geometry, adm0_l, adm0_r, admin_level, disputed, name, claimed_by, maritime
FROM osm_border_linestring_gen_z11
WHERE admin_level BETWEEN 2 AND 6
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z10_idx ON osm_border_linestring_gen_z10 USING gist (geometry);
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z9 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
-- etldoc: osm_border_linestring_gen_z10 -> osm_border_linestring_gen_z9
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z9 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z9 AS
(
SELECT ST_Simplify(geometry, ZRes(10)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
SELECT ST_Simplify(geometry, ZRes(10)) AS geometry, adm0_l, adm0_r, admin_level, disputed, name, claimed_by, maritime
FROM osm_border_linestring_gen_z10
WHERE admin_level BETWEEN 2 AND 6
-- WHERE admin_level BETWEEN 2 AND 6
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z9_idx ON osm_border_linestring_gen_z9 USING gist (geometry);
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z8 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
-- etldoc: osm_border_linestring_gen_z9 -> osm_border_linestring_gen_z8
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z8 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z8 AS
(
SELECT ST_Simplify(geometry, ZRes(9)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
SELECT ST_Simplify(geometry, ZRes(9)) AS geometry, adm0_l, adm0_r, admin_level, disputed, name, claimed_by, maritime
FROM osm_border_linestring_gen_z9
WHERE admin_level BETWEEN 2 AND 4
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z8_idx ON osm_border_linestring_gen_z8 USING gist (geometry);
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z7 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
-- etldoc: osm_border_linestring_gen_z8 -> osm_border_linestring_gen_z7
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z7 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z7 AS
(
SELECT ST_Simplify(geometry, ZRes(8)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
SELECT ST_Simplify(geometry, ZRes(8)) AS geometry, adm0_l, adm0_r, admin_level, disputed, name, claimed_by, maritime
FROM osm_border_linestring_gen_z8
WHERE admin_level BETWEEN 2 AND 4
-- WHERE admin_level BETWEEN 2 AND 4
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z7_idx ON osm_border_linestring_gen_z7 USING gist (geometry);
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z6 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
-- etldoc: osm_border_linestring_gen_z7 -> osm_border_linestring_gen_z6
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z6 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z6 AS
(
SELECT ST_Simplify(geometry, ZRes(7)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
SELECT ST_Simplify(geometry, ZRes(7)) AS geometry, adm0_l, adm0_r, admin_level, disputed, name, claimed_by, maritime
FROM osm_border_linestring_gen_z7
WHERE admin_level BETWEEN 2 AND 4
-- WHERE admin_level BETWEEN 2 AND 4
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z6_idx ON osm_border_linestring_gen_z6 USING gist (geometry);
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z5 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
-- etldoc: osm_border_linestring_gen_z6 -> osm_border_linestring_gen_z5
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z5 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z5 AS
(
SELECT ST_Simplify(geometry, ZRes(6)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
SELECT ST_Simplify(geometry, ZRes(6)) AS geometry, adm0_l, adm0_r, admin_level, disputed, name, claimed_by, maritime
FROM osm_border_linestring_gen_z6
WHERE admin_level BETWEEN 2 AND 4
-- WHERE admin_level BETWEEN 2 AND 4
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS osm_border_linestring_gen_z5_idx ON osm_border_linestring_gen_z5 USING gist (geometry);
-- This statement can be deleted after the border importer image stops creating this object as a table
DO
$$
BEGIN
DROP TABLE IF EXISTS osm_border_linestring_gen_z4 CASCADE;
EXCEPTION
WHEN wrong_object_type THEN
END;
$$ LANGUAGE plpgsql;
-- etldoc: osm_border_linestring_gen_z5 -> osm_border_linestring_gen_z4
DROP MATERIALIZED VIEW IF EXISTS osm_border_linestring_gen_z4 CASCADE;
CREATE MATERIALIZED VIEW osm_border_linestring_gen_z4 AS
(
SELECT ST_Simplify(geometry, ZRes(5)) AS geometry, adm0_l, adm0_r, admin_level, disputed, maritime
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
WHERE admin_level = 2 AND (maritime OR disputed)
) /* 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;
@@ -228,9 +208,10 @@ SELECT ST_Simplify(geometry, ZRes(6)) as geometry,
FALSE AS disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
FALSE AS maritime
FALSE AS maritime,
min_zoom
FROM ne_10m_admin_1_states_provinces_lines
WHERE min_zoom <= 7
WHERE min_zoom <= 7.7
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS ne_10m_admin_1_states_provinces_lines_gen_z4_idx ON ne_10m_admin_1_states_provinces_lines_gen_z4 USING gist (geometry);
@@ -246,6 +227,7 @@ SELECT ST_Simplify(geometry, ZRes(5)) as geometry,
claimed_by,
maritime
FROM ne_10m_admin_1_states_provinces_lines_gen_z4
WHERE min_zoom <= 7
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS ne_10m_admin_1_states_provinces_lines_gen_z3_idx ON ne_10m_admin_1_states_provinces_lines_gen_z3 USING gist (geometry);
@@ -475,7 +457,6 @@ FROM osm_border_disp_linestring_gen_z3
-- 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
-- etldoc: osm_border_disp_linestring_gen_z4 -> boundary_z4
CREATE OR REPLACE VIEW boundary_z4 AS
(
SELECT geometry,
@@ -503,26 +484,13 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
maritime
FROM osm_border_linestring_gen_z4
WHERE maritime = TRUE
AND admin_level <= 2
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z4
FROM osm_border_linestring_gen_z4
);
-- etldoc: osm_border_linestring_gen_z5 -> boundary_z5
-- etldoc: osm_border_disp_linestring_gen_z5 -> boundary_z5
CREATE OR REPLACE VIEW boundary_z5 AS
(
SELECT geometry,
@@ -530,27 +498,14 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_linestring_gen_z5
WHERE admin_level <= 4
-- already not included in osm_border_linestring_adm
-- AND osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring_gen_z5)
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z5
);
-- etldoc: osm_border_linestring_gen_z6 -> boundary_z6
-- etldoc: osm_border_disp_linestring_gen_z6 -> boundary_z6
CREATE OR REPLACE VIEW boundary_z6 AS
(
SELECT geometry,
@@ -558,26 +513,14 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_linestring_gen_z6
WHERE admin_level <= 4
-- AND osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring_gen_z6)
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z6
);
-- etldoc: osm_border_linestring_gen_z7 -> boundary_z7
-- etldoc: osm_border_disp_linestring_gen_z7 -> boundary_z7
CREATE OR REPLACE VIEW boundary_z7 AS
(
SELECT geometry,
@@ -585,26 +528,14 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_linestring_gen_z7
WHERE admin_level <= 6
-- AND osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring_gen_z7)
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z7
);
-- etldoc: osm_border_linestring_gen_z8 -> boundary_z8
-- etldoc: osm_border_disp_linestring_gen_z8 -> boundary_z8
CREATE OR REPLACE VIEW boundary_z8 AS
(
SELECT geometry,
@@ -612,26 +543,14 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_linestring_gen_z8
WHERE admin_level <= 6
-- AND osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring_gen_z8)
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z8
);
-- etldoc: osm_border_linestring_gen_z9 -> boundary_z9
-- etldoc: osm_border_disp_linestring_gen_z9 -> boundary_z9
CREATE OR REPLACE VIEW boundary_z9 AS
(
SELECT geometry,
@@ -639,26 +558,14 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_linestring_gen_z9
WHERE admin_level <= 6
-- AND osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring_gen_z9)
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z9
);
-- etldoc: osm_border_linestring_gen_z10 -> boundary_z10
-- etldoc: osm_border_disp_linestring_gen_z10 -> boundary_z10
CREATE OR REPLACE VIEW boundary_z10 AS
(
SELECT geometry,
@@ -666,26 +573,14 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_linestring_gen_z10
WHERE admin_level <= 6
-- AND osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring_gen_z10)
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z10
);
-- etldoc: osm_border_linestring_gen_z11 -> boundary_z11
-- etldoc: osm_border_disp_linestring_gen_z11 -> boundary_z11
CREATE OR REPLACE VIEW boundary_z11 AS
(
SELECT geometry,
@@ -693,26 +588,14 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_linestring_gen_z11
WHERE admin_level <= 8
-- AND osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring_gen_z11)
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z11
);
-- etldoc: osm_border_linestring_gen_z12 -> boundary_z12
-- etldoc: osm_border_disp_linestring_gen_z12 -> boundary_z12
CREATE OR REPLACE VIEW boundary_z12 AS
(
SELECT geometry,
@@ -720,25 +603,13 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
maritime
FROM osm_border_linestring_gen_z12
--WHERE osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring_gen_z12)
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z12
FROM osm_border_linestring_gen_z12
);
-- etldoc: osm_border_linestring_gen_z13 -> boundary_z13
-- etldoc: osm_border_disp_linestring_gen_z13 -> boundary_z13
CREATE OR REPLACE VIEW boundary_z13 AS
(
SELECT geometry,
@@ -746,21 +617,10 @@ SELECT geometry,
adm0_l,
adm0_r,
disputed,
NULL::text AS disputed_name,
NULL::text AS claimed_by,
maritime
FROM osm_border_linestring_gen_z13
--WHERE osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring_gen_z13)
UNION ALL
SELECT geometry,
admin_level,
NULL::text AS adm0_l,
NULL::text AS adm0_r,
TRUE AS disputed,
edit_name(name) AS disputed_name,
CASE WHEN disputed THEN edit_name(name) END AS disputed_name,
claimed_by,
maritime
FROM osm_border_disp_linestring_gen_z13
FROM osm_border_linestring_gen_z13
);
-- etldoc: layer_boundary[shape=record fillcolor=lightpink, style="rounded,filled",

View File

@@ -1,5 +1,13 @@
layer:
id: "boundary"
requires:
tables:
- osm_border_linestring
- ne_10m_admin_0_countries
- ne_10m_admin_0_boundary_lines_land
- ne_10m_admin_1_states_provinces_lines
- ne_50m_admin_0_boundary_lines_land
- ne_110m_admin_0_boundary_lines_land
description: |
Contains administrative boundaries as linestrings.
Until z4 [Natural Earth data](http://www.naturalearthdata.com/downloads/) is used after which

View File

@@ -1,23 +1,25 @@
DROP TABLE IF EXISTS osm_border_linestring_adm CASCADE;
-- etldoc: osm_border_linestring -> osm_border_linestring_adm
-- etldoc: osm_border_disp_linestring -> osm_border_linestring_adm
-- etldoc: ne_10m_admin_0_countries -> osm_border_linestring_adm
CREATE TABLE IF NOT EXISTS osm_border_linestring_adm AS (
WITH
-- Prepare lines from osm to be merged
multiline AS (
SELECT ST_Node(ST_Collect(geometry)) AS geometry,
maritime,
disputed
SELECT osm_id,
ST_Node(ST_Collect(geometry)) AS geometry,
BOOL_OR(maritime) AS maritime,
FALSE AS disputed
FROM osm_border_linestring
WHERE admin_level = 2
WHERE admin_level = 2 AND ST_Dimension(geometry) = 1
AND osm_id NOT IN (SELECT DISTINCT osm_id FROM osm_border_disp_linestring)
GROUP BY maritime,
disputed
GROUP BY osm_id
),
mergedline AS (
SELECT (ST_Dump(
ST_LineMerge(geometry))).geom AS geometry,
SELECT osm_id,
(ST_Dump(ST_LineMerge(geometry))).geom AS geometry,
maritime,
disputed
FROM multiline
@@ -32,7 +34,7 @@ CREATE TABLE IF NOT EXISTS osm_border_linestring_adm AS (
FROM (SELECT ST_Node(
ST_Collect(geometry)) AS geometry
FROM osm_border_linestring
WHERE admin_level = 2
WHERE admin_level = 2 AND ST_Dimension(geometry) = 1
) nodes
) linemerge
),
@@ -55,12 +57,14 @@ CREATE TABLE IF NOT EXISTS osm_border_linestring_adm AS (
),
rights AS (
SELECT adm0_r,
SELECT osm_id,
adm0_r,
geometry,
maritime,
disputed
FROM (
SELECT b.adm0_a3 AS adm0_r,
SELECT a.osm_id AS osm_id,
b.adm0_a3 AS adm0_r,
a.geometry,
a.maritime,
a.disputed
@@ -73,14 +77,16 @@ CREATE TABLE IF NOT EXISTS osm_border_linestring_adm AS (
) line_rights
)
SELECT adm0_l,
SELECT osm_id,
adm0_l,
adm0_r,
geometry,
maritime,
2::integer AS admin_level,
disputed
FROM (
SELECT b.adm0_a3 AS adm0_l,
SELECT r.osm_id AS osm_id,
b.adm0_a3 AS adm0_l,
r.adm0_r AS adm0_r,
r.geometry,
r.maritime,
@@ -96,4 +102,4 @@ CREATE TABLE IF NOT EXISTS osm_border_linestring_adm AS (
CREATE INDEX IF NOT EXISTS osm_border_linestring_adm_geom_idx
ON osm_border_linestring_adm
USING GIST (geometry);
USING GIST (geometry);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 KiB

After

Width:  |  Height:  |  Size: 552 KiB

View File

@@ -1,107 +1,34 @@
generalized_tables:
# etldoc: osm_border_disp_linestring_gen_z2 -> osm_border_disp_linestring_gen_z1
border_disp_linestring_gen_z1:
source: border_disp_linestring_gen_z2
sql_filter: admin_level = 2
tolerance: ZRES2
# etldoc: osm_border_disp_linestring_gen_z3 -> osm_border_disp_linestring_gen_z2
border_disp_linestring_gen_z2:
source: border_disp_linestring_gen_z3
sql_filter: admin_level = 2
tolerance: ZRES3
# etldoc: osm_border_disp_linestring_gen_z4 -> osm_border_disp_linestring_gen_z3
border_disp_linestring_gen_z3:
source: border_disp_linestring_gen_z4
sql_filter: admin_level = 2
tolerance: ZRES4
# etldoc: osm_border_disp_linestring_gen_z5 -> osm_border_disp_linestring_gen_z4
border_disp_linestring_gen_z4:
source: border_disp_linestring_gen_z5
sql_filter: admin_level = 2
tolerance: ZRES5
# etldoc: osm_border_disp_linestring_gen_z6 -> osm_border_disp_linestring_gen_z5
border_disp_linestring_gen_z5:
source: border_disp_linestring_gen_z6
sql_filter: admin_level = 2
tolerance: ZRES6
# etldoc: osm_border_disp_linestring_gen_z7 -> osm_border_disp_linestring_gen_z6
border_disp_linestring_gen_z6:
source: border_disp_linestring_gen_z7
sql_filter: admin_level = 2
tolerance: ZRES7
# etldoc: osm_border_disp_linestring_gen_z8 -> osm_border_disp_linestring_gen_z7
border_disp_linestring_gen_z7:
source: border_disp_linestring_gen_z8
sql_filter: admin_level = 2
tolerance: ZRES8
# etldoc: osm_border_disp_linestring_gen_z9 -> osm_border_disp_linestring_gen_z8
border_disp_linestring_gen_z8:
source: border_disp_linestring_gen_z9
sql_filter: admin_level = 2
tolerance: ZRES9
# etldoc: osm_border_disp_linestring_gen_z10 -> osm_border_disp_linestring_gen_z9
border_disp_linestring_gen_z9:
source: border_disp_linestring_gen_z10
sql_filter: admin_level = 2
tolerance: ZRES10
# etldoc: osm_border_disp_linestring_gen_z11 -> osm_border_disp_linestring_gen_z10
border_disp_linestring_gen_z10:
source: border_disp_linestring_gen_z11
sql_filter: admin_level = 2
tolerance: ZRES11
# etldoc: osm_border_disp_linestring_gen_z12 -> osm_border_disp_linestring_gen_z11
border_disp_linestring_gen_z11:
source: border_disp_linestring_gen_z12
sql_filter: admin_level = 2
tolerance: ZRES12
# etldoc: osm_border_disp_linestring_gen_z13 -> osm_border_disp_linestring_gen_z12
border_disp_linestring_gen_z12:
source: border_disp_linestring_gen_z13
sql_filter: admin_level = 2
tolerance: ZRES13
# etldoc: osm_border_disp_linestring -> osm_border_disp_linestring_gen_z13
border_disp_linestring_gen_z13:
source: border_disp_linestring
sql_filter: admin_level = 2
tolerance: ZRES14
# etldoc: osm_border_disp_relation -> osm_border_disp_linestring
# etldoc: osm_border_linestring -> osm_border_disp_linestring
border_disp_linestring:
source: border_disp_relation
sql_filter: ST_GeometryType(geometry) = 'ST_LineString'
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
tables:
# etldoc: imposm3 -> osm_border_disp_relation
border_disp_relation:
# etldoc: imposm3 -> osm_border_linestring
border_linestring:
type: relation_member
filters:
require:
admin_level: [__any__]
boundary: [administrative]
columns:
- name: relation_id
type: id
- name: osm_id
type: id
from_member: true
- name: member
type: member_id
- name: type
type: member_type
- name: geometry
type: geometry
- key: name
name: name
type: string
- key: boundary
name: boundary
type: string
# Used for disputed boundary, e.g. "Line of actual control"
from_member: true
- key: admin_level
name: admin_level
type: integer
@@ -111,6 +38,19 @@ tables:
- key: disputed_by
name: disputed_by
type: string
from_member: true
- key: dispute
name: dispute
type: bool
from_member: true
- key: disputed
name: disputed
type: bool
from_member: true
- key: border_status
name: border_status
type: string
from_member: true
- key: maritime
name: maritime
type: bool
@@ -121,16 +61,24 @@ tables:
type: member_role
- name: type
type: member_type
- key: boundary_type
name: boundary_type
type: string
from_member: true
- key: natural
name: natural
type: string
from_member: true
relation_types: [boundary]
mapping:
type: [boundary]
filters:
require:
#admin_level: ['2'] # this used to be specified, re-enable if bugs show up with country borders
admin_level: [__any__]
boundary: ['administrative'] # Filters out boundary administrative_fraction and religious_administration
boundary:
- administrative
border_status:
- dispute
boundary_type:
- maritime
# FOr NUTS in linestring version
# FOr NUTS in linestring version
administrative_relation:
type: relation
columns:
@@ -208,34 +156,4 @@ tables:
boundary: [ 'administrative' ]
filters:
require:
admin_level: [ __any__ ]
# not currently used
# # etldoc: imposm3 -> osm_adm_boundary_relation
# adm_boundary_relation:
# type: relation
# columns:
# - name: relation_id
# type: id
# - key: name
# name: name
# type: string
# - key: admin_level
# name: admin_level
# type: integer
# - key: border_type
# name: border_type
# type: string
# - key: default_language
# name: default_language
# type: string
# - key: website
# name: website
# type: string
# mapping:
# type: [boundary]
# filters:
# require:
# boundary: ['administrative']
# admin_level: [__any__]
admin_level: [ __any__ ]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 14 KiB

287
layers/boundary/style.json Normal file
View File

@@ -0,0 +1,287 @@
{
"layers": [
{
"id": "boundary_3",
"type": "line",
"source": "openmaptiles",
"source-layer": "boundary",
"minzoom": 3,
"layout": {
"line-join": "round",
"visibility": "visible"
},
"paint": {
"line-color": "#845283",
"line-width": {
"base": 1,
"stops": [
[
4,
0.4
],
[
5,
0.7
],
[
12,
1.6
]
]
},
"line-opacity": {
"stops": [
[
3,
0.5
],
[
10,
1
]
]
},
"line-dasharray": [
5,
3
]
},
"metadata": {},
"filter": [
"all",
[
"in",
"admin_level",
3,
4
],
[
"==",
"maritime",
0
]
],
"order": 146
},
{
"id": "boundary_2",
"type": "line",
"source": "openmaptiles",
"source-layer": "boundary",
"minzoom": 0,
"layout": {
"line-cap": "round",
"line-join": "round",
"visibility": "visible"
},
"paint": {
"line-color": "#a37da1",
"line-width": {
"base": 1,
"stops": [
[
3,
0.5
],
[
5,
1.2
],
[
12,
3
]
]
},
"line-opacity": 1
},
"metadata": {},
"filter": [
"all",
[
"==",
"admin_level",
2
],
[
"==",
"maritime",
0
],
[
"==",
"disputed",
0
]
],
"order": 147
},
{
"id": "boundary_2_disputed",
"type": "line",
"source": "openmaptiles",
"source-layer": "boundary",
"minzoom": 0,
"layout": {
"line-cap": "round",
"line-join": "round",
"visibility": "visible"
},
"paint": {
"line-color": "#a37da1",
"line-width": {
"base": 1,
"stops": [
[
3,
0.3
],
[
5,
1.2
],
[
12,
3
]
]
},
"line-opacity": 1,
"line-dasharray": [
4,
3
]
},
"metadata": {},
"filter": [
"all",
[
"==",
"admin_level",
2
],
[
"==",
"disputed",
1
],
[
"==",
"maritime",
0
]
],
"order": 148
},
{
"id": "boundary_2_disputed_maritime",
"type": "line",
"source": "openmaptiles",
"source-layer": "boundary",
"minzoom": 0,
"layout": {
"line-cap": "round",
"line-join": "round",
"visibility": "visible"
},
"paint": {
"line-color": "rgba(129, 125, 163, 1)",
"line-width": {
"base": 1,
"stops": [
[
3,
0.5
],
[
5,
1.2
],
[
12,
3
]
]
},
"line-opacity": 1,
"line-dasharray": [
4,
3
]
},
"metadata": {},
"filter": [
"all",
[
"==",
"admin_level",
2
],
[
"==",
"disputed",
1
],
[
"==",
"maritime",
1
]
],
"order": 149
},
{
"id": "boundary_2_maritime",
"type": "line",
"source": "openmaptiles",
"source-layer": "boundary",
"minzoom": 4,
"layout": {
"line-cap": "round",
"line-join": "round",
"visibility": "visible"
},
"paint": {
"line-color": "#a37da1",
"line-width": {
"base": 1,
"stops": [
[
3,
0.5
],
[
5,
1.2
],
[
12,
3
]
]
},
"line-opacity": 1
},
"metadata": {},
"filter": [
"all",
[
"==",
"admin_level",
2
],
[
"==",
"disputed",
0
],
[
"==",
"maritime",
1
]
],
"order": 150
}
]
}

View File

@@ -1,8 +1,8 @@
layer:
id: "building"
description: |
All [OSM Buildings](http://wiki.openstreetmap.org/wiki/Buildings). All building tags are imported ([`building=*`](http://wiki.openstreetmap.org/wiki/Key:building)). The buildings are not yet ready for 3D rendering support and any help to improve
this is welcomed.
All [OSM Buildings](http://wiki.openstreetmap.org/wiki/Buildings). All building tags are imported ([`building=*`](http://wiki.openstreetmap.org/wiki/Key:building)).
Only buildings with tag location:underground are excluded.
buffer_size: 4
datasource:
geometry_field: geometry
@@ -12,9 +12,9 @@ layer:
query: (SELECT osm_id, geometry, render_height, render_min_height, colour, hide_3d FROM layer_building(!bbox!, z(!scale_denominator!))) AS t
fields:
render_height: |
An approximated height from levels and height of the building or building:part after the method of Paul Norman in [OSM Clear](https://github.com/ClearTables/osm-clear). For future 3D rendering of buildings.
An approximated height from levels and height of the building or building:part.
render_min_height: |
An approximated height from levels and height of the bottom of the building or building:part after the method of Paul Norman in [OSM Clear](https://github.com/ClearTables/osm-clear). For future 3D rendering of buildings.
An approximated height from minimum levels or minimum height of the bottom of the building or building:part.
colour: |
Colour
hide_3d: |

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -60,11 +60,14 @@ tables:
aeroway:
- terminal
- hangar
location:
- underground
filters:
reject:
building: ["no","none","No"]
building:part: ["no","none","No"]
man_made: ["bridge"]
location: ["underground"]
type: polygon
# etldoc: imposm3 -> osm_building_relation
@@ -157,4 +160,4 @@ tables:
type: member_type
mapping:
type: [building]
type: relation_member
type: relation_member

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,44 @@
{
"layers": [
{
"id": "building",
"type": "fill",
"source": "openmaptiles",
"source-layer": "building",
"minzoom": 12,
"maxzoom": 24,
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": {
"stops": [
[
13,
"rgba(222, 213, 207, 1)"
],
[
16,
"#d9d0c9"
]
]
},
"fill-outline-color": {
"base": 1,
"stops": [
[
13,
"#9A918A"
],
[
16,
"rgba(166, 157, 150, 1)"
]
]
}
},
"metadata": {},
"order": 19
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -15,9 +15,19 @@ SELECT
osm_id,
geometry,
housenumber
FROM osm_housenumber_point
WHERE zoom_level >= 14
AND geometry && bbox;
FROM (
SELECT
osm_id,
geometry,
housenumber,
row_number() OVER(PARTITION BY concat(street, block_number, housenumber) ORDER BY has_name ASC) as rn
FROM osm_housenumber_point
WHERE 1=1
AND zoom_level >= 14
AND geometry && bbox
) t
WHERE rn = 1;
$$ LANGUAGE SQL STABLE
-- STRICT
PARALLEL SAFE;

View File

@@ -3,6 +3,7 @@ layer:
description: |
Everything in OpenStreetMap which contains a `addr:housenumber` tag useful for labelling housenumbers on a map.
This adds significant size to *z14*. For buildings the centroid of the building is used as housenumber.
Duplicates within a tile are dropped if they have the same street/block_number (records without name tag are prioritized for preservation).
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:

View File

@@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS housenumber;
CREATE TABLE IF NOT EXISTS housenumber.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
-- etldoc: osm_housenumber_point -> osm_housenumber_point
@@ -22,6 +22,16 @@ $$
WHERE (full_update OR osm_id IN (SELECT osm_id FROM housenumber.osm_ids))
AND ST_GeometryType(geometry) <> 'ST_Point'
AND ST_IsValid(geometry);
-- we don't need exact name just to know if it's present
UPDATE osm_housenumber_point
SET has_name =
CASE
WHEN has_name = '' THEN '0'
ELSE '1'
END
WHERE (full_update OR osm_id IN (SELECT osm_id FROM housenumber.osm_ids));
$$ LANGUAGE SQL;
SELECT convert_housenumber_point(true);
@@ -31,11 +41,7 @@ SELECT convert_housenumber_point(true);
CREATE OR REPLACE FUNCTION housenumber.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO housenumber.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO housenumber.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO housenumber.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -60,6 +66,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh housenumber';
-- Analyze tracking and source tables before performing update
ANALYZE housenumber.osm_ids;
ANALYZE osm_housenumber_point;
PERFORM convert_housenumber_point(false);
-- noinspection SqlWithoutWhere
DELETE FROM housenumber.osm_ids;
@@ -72,13 +83,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_housenumber_point
FOR EACH ROW
EXECUTE PROCEDURE housenumber.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_housenumber_point
FOR EACH STATEMENT
EXECUTE PROCEDURE housenumber.flag();

View File

@@ -12,6 +12,15 @@ tables:
- name: housenumber
key: addr:housenumber
type: string
- name: street
key: addr:street
type: string
- name: block_number
key: addr:block_number
type: string
- name: has_name
key: name
type: string
type_mappings:
points:
addr:housenumber:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -0,0 +1,40 @@
{
"layers": [
{
"id": "housenumber",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "housenumber",
"minzoom": 17,
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"stops": [
[
17,
9
],
[
22,
11
]
]
},
"text-field": "{housenumber}",
"text-padding": 3,
"text-line-height": -0.15,
"symbol-avoid-edges": false,
"text-allow-overlap": false,
"text-ignore-placement": false
},
"paint": {
"text-color": "rgba(102, 102, 102, 1)",
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 1
},
"order": 154
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 KiB

After

Width:  |  Height:  |  Size: 415 KiB

View File

@@ -13,7 +13,7 @@ DROP TABLE IF EXISTS simplify_vw_z11 CASCADE;
DROP TABLE IF EXISTS simplify_vw_z12 CASCADE;
DROP TABLE IF EXISTS simplify_vw_z13 CASCADE;
-- etldoc: osm_landcover_polygon -> osm_landcover_gen_z13
-- etldoc: osm_landcover_polygon -> simplify_vw_z13
CREATE TABLE simplify_vw_z13 AS
(
SELECT subclass,
@@ -22,32 +22,19 @@ CREATE TABLE simplify_vw_z13 AS
ST_SimplifyVW(geometry, power(zres(13),2)),
0.001)) AS geometry
FROM osm_landcover_polygon
WHERE ST_Area(geometry) > power(zres(10),2)
WHERE ST_Area(geometry) > power(zres(12),2)
);
CREATE INDEX ON simplify_vw_z13 USING GIST (geometry);
-- etldoc: simplify_vw_z13 -> osm_landcover_gen_z13
CREATE TABLE osm_landcover_gen_z13 AS
(
SELECT subclass,
ST_MakeValid(
(ST_dump(
ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z13
WHERE ST_NPoints(geometry) < 50
AND subclass IN ('wood', 'forest')) union_geom50
GROUP BY subclass,
cid
UNION ALL
SELECT subclass, ST_MakeValid((ST_dump(ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z13
WHERE ST_NPoints(geometry) >= 50
AND ST_NPoints(geometry) < 300
WHERE ST_NPoints(geometry) < 300
AND subclass IN ('wood', 'forest')) union_geom300
GROUP BY subclass,
cid
@@ -62,7 +49,7 @@ SELECT subclass,
CREATE INDEX ON osm_landcover_gen_z13 USING GIST (geometry);
-- etldoc: osm_landcover_gen_z13 -> osm_landcover_gen_z12
-- etldoc: simplify_vw_z13 -> simplify_vw_z12
CREATE TABLE simplify_vw_z12 AS
(
SELECT subclass,
@@ -71,32 +58,19 @@ CREATE TABLE simplify_vw_z12 AS
ST_SimplifyVW(geometry, power(zres(12),2)),
0.001)) AS geometry
FROM simplify_vw_z13
WHERE ST_Area(geometry) > power(zres(9),2)
WHERE ST_Area(geometry) > power(zres(11),2)
);
CREATE INDEX ON simplify_vw_z12 USING GIST (geometry);
-- etldoc: simplify_vw_z12 -> osm_landcover_gen_z12
CREATE TABLE osm_landcover_gen_z12 AS
(
SELECT subclass,
ST_MakeValid(
(ST_dump(
ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z12
WHERE ST_NPoints(geometry) < 50
AND subclass IN ('wood', 'forest')) union_geom50
GROUP BY subclass,
cid
UNION ALL
SELECT subclass, ST_MakeValid((ST_dump(ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z12
WHERE ST_NPoints(geometry) >= 50
AND ST_NPoints(geometry) < 300
WHERE ST_NPoints(geometry) < 300
AND subclass IN ('wood', 'forest')) union_geom300
GROUP BY subclass,
cid
@@ -111,7 +85,7 @@ SELECT subclass,
CREATE INDEX ON osm_landcover_gen_z12 USING GIST (geometry);
-- etldoc: osm_landcover_gen_z12 -> osm_landcover_gen_z11
-- etldoc: simplify_vw_z12 -> simplify_vw_z11
CREATE TABLE simplify_vw_z11 AS
(
SELECT subclass,
@@ -120,32 +94,19 @@ CREATE TABLE simplify_vw_z11 AS
ST_SimplifyVW(geometry, power(zres(11),2)),
0.001)) AS geometry
FROM simplify_vw_z12
WHERE ST_Area(geometry) > power(zres(8),2)
WHERE ST_Area(geometry) > power(zres(10),2)
);
CREATE INDEX ON simplify_vw_z11 USING GIST (geometry);
-- etldoc: simplify_vw_z11 -> osm_landcover_gen_z11
CREATE TABLE osm_landcover_gen_z11 AS
(
SELECT subclass,
ST_MakeValid(
(ST_dump(
ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z11
WHERE ST_NPoints(geometry) < 50
AND subclass IN ('wood', 'forest')) union_geom50
GROUP BY subclass,
cid
UNION ALL
SELECT subclass, ST_MakeValid((ST_dump(ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z11
WHERE ST_NPoints(geometry) >= 50
AND ST_NPoints(geometry) < 300
WHERE ST_NPoints(geometry) < 300
AND subclass IN ('wood', 'forest')) union_geom300
GROUP BY subclass,
cid
@@ -160,7 +121,7 @@ SELECT subclass,
CREATE INDEX ON osm_landcover_gen_z11 USING GIST (geometry);
-- etldoc: osm_landcover_gen_z11 -> osm_landcover_gen_z10
-- etldoc: simplify_vw_z11 -> simplify_vw_z10
CREATE TABLE simplify_vw_z10 AS
(
SELECT subclass,
@@ -169,32 +130,19 @@ CREATE TABLE simplify_vw_z10 AS
ST_SimplifyVW(geometry, power(zres(10),2)),
0.001)) AS geometry
FROM simplify_vw_z11
WHERE ST_Area(geometry) > power(zres(8),2)
WHERE ST_Area(geometry) > power(zres(9),2)
);
CREATE INDEX ON simplify_vw_z10 USING GIST (geometry);
-- etldoc: simplify_vw_z10 -> osm_landcover_gen_z10
CREATE TABLE osm_landcover_gen_z10 AS
(
SELECT subclass,
ST_MakeValid(
(ST_dump(
ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z10
WHERE ST_NPoints(geometry) < 50
AND subclass IN ('wood', 'forest')) union_geom50
GROUP BY subclass,
cid
UNION ALL
SELECT subclass, ST_MakeValid((ST_dump(ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z10
WHERE ST_NPoints(geometry) >= 50
AND ST_NPoints(geometry) < 300
WHERE ST_NPoints(geometry) < 300
AND subclass IN ('wood', 'forest')) union_geom300
GROUP BY subclass,
cid
@@ -209,7 +157,7 @@ SELECT subclass,
CREATE INDEX ON osm_landcover_gen_z10 USING GIST (geometry);
-- etldoc: osm_landcover_gen_z10 -> osm_landcover_gen_z9
-- etldoc: simplify_vw_z10 -> simplify_vw_z9
CREATE TABLE simplify_vw_z9 AS
(
SELECT subclass,
@@ -218,32 +166,19 @@ CREATE TABLE simplify_vw_z9 AS
ST_SimplifyVW(geometry, power(zres(9),2)),
0.001)) AS geometry
FROM simplify_vw_z10
WHERE ST_Area(geometry) > power(zres(7),2)
WHERE ST_Area(geometry) > power(zres(8),2)
);
CREATE INDEX ON simplify_vw_z9 USING GIST (geometry);
-- etldoc: simplify_vw_z9 -> osm_landcover_gen_z9
CREATE TABLE osm_landcover_gen_z9 AS
(
SELECT subclass,
ST_MakeValid(
(ST_dump(
ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z9
WHERE ST_NPoints(geometry) < 50
AND subclass IN ('wood', 'forest')) union_geom50
GROUP BY subclass,
cid
UNION ALL
SELECT subclass, ST_MakeValid((ST_dump(ST_Union(geometry))).geom) AS geometry
FROM (
SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) over () AS cid, geometry
FROM simplify_vw_z9
WHERE ST_NPoints(geometry) >= 50
AND ST_NPoints(geometry) < 300
WHERE ST_NPoints(geometry) < 300
AND subclass IN ('wood', 'forest')) union_geom300
GROUP BY subclass,
cid
@@ -270,7 +205,7 @@ SELECT subclass,
CREATE INDEX ON osm_landcover_gen_z9 USING GIST (geometry);
-- etldoc: osm_landcover_gen_z9 -> osm_landcover_gen_z8
-- etldoc: simplify_vw_z9 -> simplify_vw_z8
CREATE TABLE simplify_vw_z8 AS
(
SELECT subclass,
@@ -279,10 +214,11 @@ CREATE TABLE simplify_vw_z8 AS
ST_SimplifyVW(geometry, power(zres(8),2)),
0.001)) AS geometry
FROM simplify_vw_z9
WHERE ST_Area(geometry) > power(zres(6),2)
WHERE ST_Area(geometry) > power(zres(7),2)
);
CREATE INDEX ON simplify_vw_z8 USING GIST (geometry);
-- etldoc: simplify_vw_z8 -> osm_landcover_gen_z8
CREATE TABLE osm_landcover_gen_z8 AS
(
SELECT subclass,
@@ -295,6 +231,7 @@ SELECT subclass,
ST_ClusterDBSCAN(geometry, eps := 0, minpoints := 1) OVER () AS cid,
geometry
FROM simplify_vw_z8
WHERE subclass IN ('wood', 'forest')
) union_geom
GROUP BY subclass,
cid
@@ -308,7 +245,7 @@ SELECT subclass,
CREATE INDEX ON osm_landcover_gen_z8 USING GIST (geometry);
-- etldoc: osm_landcover_gen_z8 -> osm_landcover_gen_z7
-- etldoc: simplify_vw_z8 -> simplify_vw_z7
CREATE TABLE simplify_vw_z7 AS
(
SELECT subclass,
@@ -317,10 +254,11 @@ CREATE TABLE simplify_vw_z7 AS
ST_SimplifyVW(geometry, power(zres(7),2)),
0.001)) AS geometry
FROM simplify_vw_z8
WHERE ST_Area(geometry) > power(zres(5),2)
WHERE ST_Area(geometry) > power(zres(6),2)
);
CREATE INDEX ON simplify_vw_z7 USING GIST (geometry);
-- etldoc: simplify_vw_z7 -> osm_landcover_gen_z7
CREATE TABLE osm_landcover_gen_z7 AS
(
SELECT subclass,

View File

@@ -1,5 +1,12 @@
layer:
id: "landcover"
requires:
tables:
- ne_10m_antarctic_ice_shelves_polys
- ne_10m_glaciated_areas
- ne_50m_antarctic_ice_shelves_polys
- ne_50m_glaciated_areas
- ne_110m_glaciated_areas
description: |
Landcover is used to describe the physical material at the surface of the earth. At lower zoom levels this is
from Natural Earth data for glaciers and ice shelves and at higher zoom levels the landcover is [implied by OSM tags](http://wiki.openstreetmap.org/wiki/Landcover). The most common use case for this layer
@@ -19,7 +26,7 @@ layer:
rock:
subclass: ['bare_rock', 'scree']
grass:
subclass: ['fell', 'grassland', 'heath', 'scrub', 'tundra', 'grass', 'meadow', 'allotments', 'park', 'village_green', 'recreation_ground', 'garden', 'golf_course']
subclass: ['fell', '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:
@@ -39,6 +46,7 @@ layer:
- bog
- dune
- scrub
- shrubbery
- farm
- farmland
- fell

View File

@@ -26,8 +26,6 @@ tables:
- forest
- village_green
- recreation_ground
# There are 600 parks tagged with landuse=park instead of leisure=park
- park
natural:
- wood
- wetland
@@ -35,6 +33,7 @@ tables:
- grassland
- heath
- scrub
- shrubbery
- tundra
- glacier
- bare_rock

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 67 KiB

476
layers/landcover/style.json Normal file
View File

@@ -0,0 +1,476 @@
{
"layers": [
{
"id": "landcover_classes",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landcover",
"maxzoom": 13,
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": [
"match",
[
"get",
"class"
],
"farmland",
"#eef0d5",
"wood",
"#add19e",
"rock",
"#eee5dc",
"grass",
"#cdebb0",
"sand",
"#f5e9c6",
"wetland",
"#add19e",
"#000"
],
"fill-opacity": {
"stops": [
[
7,
0.5
],
[
10,
1
]
]
},
"fill-antialias": false
},
"metadata": {},
"filter": [
"all",
[
"in",
"class",
"farmland",
"wood",
"rock",
"grass",
"wetland",
"sand"
]
],
"order": 4
},
{
"id": "landcover_class_outline",
"type": "line",
"source": "openmaptiles",
"source-layer": "landcover",
"layout": {
"visibility": "visible"
},
"paint": {
"line-color": "#c7c9ae",
"line-width": 0.5
},
"filter": [
"all",
[
"in",
"class",
"farmland"
]
],
"order": 5
},
{
"id": "landcover_park",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landcover",
"minzoom": 13,
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": "#c8facc",
"fill-antialias": true
},
"filter": [
"all",
[
"==",
"subclass",
"park"
]
],
"order": 6
},
{
"id": "landcover_subclasses",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landcover",
"minzoom": 13,
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": [
"match",
[
"get",
"subclass"
],
"allotments",
"#c9e1bf",
"bare_rock",
"#eee5dc",
"beach",
"#fff1ba",
"bog",
"#d6d99f",
"dune",
"#f5e9c6",
"scrub",
"#c8d7ab",
"farm",
"#f5dcba",
"farmland",
"#eef0d5",
"forest",
"#add19e",
"grass",
"#cdebb0",
"grassland",
"#cdebb0",
"golf_course",
"#def6c0",
"heath",
"#d6d99f",
"mangrove",
"#c8d7ab",
"meadow",
"#cdebb0",
"orchard",
"#aedfa3",
"park",
"#c8facc",
"garden",
"#cdebb0",
"plant_nursery",
"#aedfa3",
"recreation_ground",
"#d5ffd9",
"reedbed",
"#cdebb0",
"saltmarsh",
"#cdebb0",
"sand",
"#f5e9c6",
"scree",
"#eee5dc",
"swamp",
"#add19e",
"tidalflat",
"#DED6CF",
"village_green",
"#cdebb0",
"vineyard",
"#aedfa3",
"wet_meadow",
"#cdebb0",
"wetland",
"#add19e",
"wood",
"#add19e",
"marsh",
"#ff0",
"#FFFFFF"
],
"fill-antialias": true
},
"filter": [
"all",
[
"in",
"subclass",
"allotments",
"bare_rock",
"beach",
"dune",
"scrub",
"farm",
"farmland",
"forest",
"garden",
"grass",
"grassland",
"golf_course",
"heath",
"meadow",
"orchard",
"plant_nursery",
"recreation_ground",
"reedbed",
"saltmarsh",
"sand",
"scree",
"swamp",
"tidalflat",
"tundra",
"village_green",
"vineyard",
"wet_meadow",
"wetland",
"wood"
]
],
"order": 7
},
{
"id": "landcover_subclass_patterns",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landcover",
"minzoom": 13,
"layout": {
"visibility": "visible"
},
"paint": {
"fill-opacity": [
"match",
[
"get",
"subclass"
],
"beach",
0.4,
"forest",
0.4,
"bare_rock",
0.3,
"scrub",
0.6,
"garden",
0.6,
"scree",
0.3,
"wood",
0.4,
1
],
"fill-pattern": [
"match",
[
"get",
"subclass"
],
"allotments",
"allotments",
"bare_rock",
"rock_overlay",
"beach",
"beach",
"bog",
"wetland_bog",
"scrub",
"scrub",
"forest",
"leaftype_unknown",
"garden",
"plant_nursery",
"mangrove",
"wetland_mangrove",
"marsh",
"wetland_marsh",
"orchard",
"orchard",
"plant_nursery",
"plant_nursery",
"reedbed",
"wetland_reed",
"saltmarsh",
"wetland_marsh",
"scree",
"scree_overlay",
"swamp",
"wetland_swamp",
"vineyard",
"vineyard",
"wet_meadow",
"wetland_marsh",
"wetland",
"wetland",
"wood",
"leaftype_unknown",
""
]
},
"metadata": {},
"filter": [
"all",
[
"in",
"subclass",
"allotments",
"bare_rock",
"beach",
"bog",
"dune",
"scrub",
"farm",
"farmland",
"forest",
"garden",
"grass",
"grassland",
"golf_course",
"heath",
"mangrove",
"marsh",
"meadow",
"orchard",
"park",
"plant_nursery",
"recreation_ground",
"reedbed",
"saltern",
"saltmarsh",
"sand",
"scree",
"swamp",
"village_green",
"vineyard",
"wet_meadow",
"wetland",
"wood"
]
],
"order": 8
},
{
"id": "landcover_subclass_outline",
"type": "line",
"source": "openmaptiles",
"source-layer": "landcover",
"minzoom": 15,
"layout": {
"visibility": "visible"
},
"paint": {
"line-color": [
"match",
[
"get",
"subclass"
],
"allotments",
"#B1C6A8",
"farm",
"#d1b48c",
"farmland",
"#c7c9ae",
"recreation_ground",
"#3c6640",
"#000"
],
"line-width": [
"match",
[
"get",
"subclass"
],
"recreation_ground",
0.3,
0.5
],
"line-opacity": 1
},
"filter": [
"all",
[
"in",
"subclass",
"allotments",
"farm",
"farmland",
"recreation_ground"
]
],
"order": 9
},
{
"id": "landcover_ice",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landcover",
"minzoom": 5,
"paint": {
"fill-color": "#ddecec",
"fill-antialias": false
},
"metadata": {},
"filter": [
"all",
[
"in",
"class",
"ice"
]
],
"order": 10
},
{
"id": "landcover_ice_outline",
"type": "line",
"source": "openmaptiles",
"source-layer": "landcover",
"minzoom": 5,
"layout": {
"visibility": "visible"
},
"paint": {
"line-color": "#9cf",
"line-width": {
"stops": [
[
5,
1
],
[
10,
1.5
]
]
},
"line-dasharray": {
"stops": [
[
5,
[
1,
0
]
],
[
10,
[
4,
2
]
]
]
}
},
"filter": [
"all",
[
"in",
"class",
"ice"
]
],
"order": 11
}
]
}

10
layers/landuse/class.sql Normal file
View File

@@ -0,0 +1,10 @@
-- Unify class names that represent the same type of feature
CREATE OR REPLACE FUNCTION landuse_unify(class text) RETURNS text LANGUAGE plpgsql
AS
$$
BEGIN
RETURN CASE
WHEN class='grave_yard' THEN 'cemetery'
ELSE class END;
END;
$$;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 333 KiB

View File

@@ -37,6 +37,188 @@ WHERE scalerank <= 2
) /* DELAY_MATERIALIZED_VIEW_CREATION */ ;
CREATE INDEX IF NOT EXISTS ne_50m_urban_areas_gen_z4_idx ON ne_50m_urban_areas_gen_z4 USING gist (geometry);
-- etldoc: osm_landuse_polygon_gen_z6 -> osm_landuse_polygon_gen_z6_union
-- etldoc: osm_residential_gen_z6 -> osm_landuse_polygon_gen_z6_union
CREATE OR REPLACE VIEW osm_landuse_polygon_gen_z6_union AS
(
SELECT osm_id,
geometry,
landuse,
amenity,
leisure,
tourism,
place,
waterway
FROM osm_landuse_polygon_gen_z6
WHERE landuse <> 'residential'
UNION ALL
SELECT NULL::bigint AS osm_id,
geometry,
'residential' AS landuse,
'' AS amenity,
'' AS leisure,
'' AS tourism,
'' AS place,
'' AS waterway
FROM osm_residential_gen_z6
);
-- etldoc: osm_landuse_polygon_gen_z7 -> osm_landuse_polygon_gen_z7_union
-- etldoc: osm_residential_gen_z7 -> osm_landuse_polygon_gen_z7_union
CREATE OR REPLACE VIEW osm_landuse_polygon_gen_z7_union AS
(
SELECT osm_id,
geometry,
landuse,
amenity,
leisure,
tourism,
place,
waterway
FROM osm_landuse_polygon_gen_z7
WHERE landuse <> 'residential'
UNION ALL
SELECT NULL::bigint AS osm_id,
geometry,
'residential' AS landuse,
'' AS amenity,
'' AS leisure,
'' AS tourism,
'' AS place,
'' AS waterway
FROM osm_residential_gen_z7
);
-- etldoc: osm_landuse_polygon_gen_z8 -> osm_landuse_polygon_gen_z8_union
-- etldoc: osm_residential_gen_z8 -> osm_landuse_polygon_gen_z8_union
CREATE OR REPLACE VIEW osm_landuse_polygon_gen_z8_union AS
(
SELECT osm_id,
geometry,
landuse,
amenity,
leisure,
tourism,
place,
waterway
FROM osm_landuse_polygon_gen_z8
WHERE landuse <> 'residential'
UNION ALL
SELECT NULL::bigint AS osm_id,
geometry,
'residential' AS landuse,
'' AS amenity,
'' AS leisure,
'' AS tourism,
'' AS place,
'' AS waterway
FROM osm_residential_gen_z8
);
-- etldoc: osm_landuse_polygon_gen_z9 -> osm_landuse_polygon_gen_z9_union
-- etldoc: osm_residential_gen_z9 -> osm_landuse_polygon_gen_z9_union
CREATE OR REPLACE VIEW osm_landuse_polygon_gen_z9_union AS
(
SELECT osm_id,
geometry,
landuse,
amenity,
leisure,
tourism,
place,
waterway
FROM osm_landuse_polygon_gen_z9
WHERE landuse <> 'residential'
UNION ALL
SELECT NULL::bigint AS osm_id,
geometry,
'residential' AS landuse,
'' AS amenity,
'' AS leisure,
'' AS tourism,
'' AS place,
'' AS waterway
FROM osm_residential_gen_z9
);
-- etldoc: osm_landuse_polygon_gen_z10 -> osm_landuse_polygon_gen_z10_union
-- etldoc: osm_residential_gen_z10 -> osm_landuse_polygon_gen_z10_union
CREATE OR REPLACE VIEW osm_landuse_polygon_gen_z10_union AS
(
SELECT osm_id,
geometry,
landuse,
amenity,
leisure,
tourism,
place,
waterway
FROM osm_landuse_polygon_gen_z10
WHERE landuse <> 'residential'
UNION ALL
SELECT NULL::bigint AS osm_id,
geometry,
'residential' AS landuse,
'' AS amenity,
'' AS leisure,
'' AS tourism,
'' AS place,
'' AS waterway
FROM osm_residential_gen_z10
);
-- etldoc: osm_landuse_polygon_gen_z11 -> osm_landuse_polygon_gen_z11_union
-- etldoc: osm_residential_gen_z11 -> osm_landuse_polygon_gen_z11_union
CREATE OR REPLACE VIEW osm_landuse_polygon_gen_z11_union AS
(
SELECT osm_id,
geometry,
landuse,
amenity,
leisure,
tourism,
place,
waterway
FROM osm_landuse_polygon_gen_z11
WHERE landuse <> 'residential'
UNION ALL
SELECT NULL::bigint AS osm_id,
geometry,
'residential' AS landuse,
'' AS amenity,
'' AS leisure,
'' AS tourism,
'' AS place,
'' AS waterway
FROM osm_residential_gen_z11
);
-- etldoc: osm_landuse_polygon_gen_z12 -> osm_landuse_polygon_gen_z12_union
-- etldoc: osm_residential_gen_z12 -> osm_landuse_polygon_gen_z12_union
CREATE OR REPLACE VIEW osm_landuse_polygon_gen_z12_union AS
(
SELECT osm_id,
geometry,
landuse,
amenity,
leisure,
tourism,
place,
waterway
FROM osm_landuse_polygon_gen_z12
WHERE landuse <> 'residential'
UNION ALL
SELECT NULL::bigint AS osm_id,
geometry,
'residential' AS landuse,
'' AS amenity,
'' AS leisure,
'' AS tourism,
'' AS place,
'' AS waterway
FROM osm_residential_gen_z12
);
-- etldoc: layer_landuse[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_landuse |<z4> z4|<z5> z5|<z6> z6|<z7> z7|<z8> z8|<z9> z9|<z10> z10|<z11> z11|<z12> z12|<z13> z13|<z14> z14+" ] ;
@@ -51,7 +233,8 @@ AS
$$
SELECT osm_id,
geometry,
COALESCE(
landuse_unify(
COALESCE(
NULLIF(landuse, ''),
NULLIF(amenity, ''),
NULLIF(leisure, ''),
@@ -59,7 +242,7 @@ SELECT osm_id,
NULLIF(place, ''),
NULLIF(waterway, ''),
NULLIF(man_made, '')
) AS class
)) AS class
FROM (
-- etldoc: ne_50m_urban_areas_gen_z4 -> layer_landuse:z4
SELECT osm_id,
@@ -87,7 +270,7 @@ FROM (
FROM ne_50m_urban_areas_gen_z5
WHERE zoom_level = 5
UNION ALL
-- etldoc: osm_landuse_polygon_gen_z6 -> layer_landuse:z6
-- etldoc: osm_landuse_polygon_gen_z6_union -> layer_landuse:z6
SELECT osm_id,
geometry,
landuse,
@@ -97,10 +280,10 @@ FROM (
place,
waterway,
man_made
FROM osm_landuse_polygon_gen_z6
FROM osm_landuse_polygon_gen_z6_union
WHERE zoom_level = 6
UNION ALL
-- etldoc: osm_landuse_polygon_gen_z7 -> layer_landuse:z7
-- etldoc: osm_landuse_polygon_gen_z7_union -> layer_landuse:z7
SELECT osm_id,
geometry,
landuse,
@@ -110,10 +293,10 @@ FROM (
place,
waterway,
man_made
FROM osm_landuse_polygon_gen_z7
FROM osm_landuse_polygon_gen_z7_union
WHERE zoom_level = 7
UNION ALL
-- etldoc: osm_landuse_polygon_gen_z8 -> layer_landuse:z8
-- etldoc: osm_landuse_polygon_gen_z8_union -> layer_landuse:z8
SELECT osm_id,
geometry,
landuse,
@@ -123,10 +306,10 @@ FROM (
place,
waterway,
man_made
FROM osm_landuse_polygon_gen_z8
FROM osm_landuse_polygon_gen_z8_union
WHERE zoom_level = 8
UNION ALL
-- etldoc: osm_landuse_polygon_gen_z9 -> layer_landuse:z9
-- etldoc: osm_landuse_polygon_gen_z9_union -> layer_landuse:z9
SELECT osm_id,
geometry,
landuse,
@@ -136,10 +319,10 @@ FROM (
place,
waterway,
man_made
FROM osm_landuse_polygon_gen_z9
FROM osm_landuse_polygon_gen_z9_union
WHERE zoom_level = 9
UNION ALL
-- etldoc: osm_landuse_polygon_gen_z10 -> layer_landuse:z10
-- etldoc: osm_landuse_polygon_gen_z10_union -> layer_landuse:z10
SELECT osm_id,
geometry,
landuse,
@@ -149,10 +332,10 @@ FROM (
place,
waterway,
man_made
FROM osm_landuse_polygon_gen_z10
FROM osm_landuse_polygon_gen_z10_union
WHERE zoom_level = 10
UNION ALL
-- etldoc: osm_landuse_polygon_gen_z11 -> layer_landuse:z11
-- etldoc: osm_landuse_polygon_gen_z11_union -> layer_landuse:z11
SELECT osm_id,
geometry,
landuse,
@@ -162,10 +345,10 @@ FROM (
place,
waterway,
man_made
FROM osm_landuse_polygon_gen_z11
FROM osm_landuse_polygon_gen_z11_union
WHERE zoom_level = 11
UNION ALL
-- etldoc: osm_landuse_polygon_gen_z12 -> layer_landuse:z12
-- etldoc: osm_landuse_polygon_gen_z12_union -> layer_landuse:z12
SELECT osm_id,
geometry,
landuse,
@@ -175,7 +358,7 @@ FROM (
place,
waterway,
man_made
FROM osm_landuse_polygon_gen_z12
FROM osm_landuse_polygon_gen_z12_union
WHERE zoom_level = 12
UNION ALL
-- etldoc: osm_landuse_polygon_gen_z13 -> layer_landuse:z13

View File

@@ -1,5 +1,8 @@
layer:
id: "landuse"
requires:
tables:
- ne_50m_urban_areas
description: |
Landuse is used to describe use of land by humans. At lower zoom levels this is
from Natural Earth data for residential (urban) areas and at higher zoom levels mostly OSM `landuse` tags.
@@ -49,10 +52,13 @@ layer:
- prison
- wastewater_plant
- water_works
- quarry
datasource:
geometry_field: geometry
query: (SELECT geometry, class FROM layer_landuse(!bbox!, z(!scale_denominator!))) AS t
schema:
- ./class.sql
- ./prep_landuse.sql
- ./landuse.sql
datasources:
- type: imposm3

View File

@@ -77,6 +77,7 @@ tables:
- railway
- cemetery
- military
- quarry
# zoning
- residential
- commercial
@@ -98,6 +99,7 @@ tables:
- motorcycle_parking
- bicycle_parking
- animal_training
- grave_yard
leisure:
- stadium
- pitch

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

@@ -0,0 +1,176 @@
DROP TABLE IF EXISTS cluster_zres14;
CREATE TABLE cluster_zres14 AS
(
WITH single_geom AS (
SELECT (ST_Dump(geometry)).geom AS geometry
FROM osm_landuse_polygon
WHERE landuse='residential'
)
SELECT ST_ClusterDBSCAN(geometry, eps := zres(14), minpoints := 1) over () AS cid,
geometry
FROM single_geom
);
CREATE INDEX ON cluster_zres14 USING gist(geometry);
DROP TABLE IF EXISTS cluster_zres14_union;
CREATE TABLE cluster_zres14_union AS (
SELECT ST_Buffer(
ST_Union(
ST_Buffer(
ST_SnapToGrid(geometry, 0.01)
, zres(14), 'join=mitre'
)
),-zres(14), 'join=mitre'
) AS geometry
FROM cluster_zres14
GROUP BY cid
);
CREATE INDEX ON cluster_zres14_union USING gist(geometry);
DROP TABLE IF EXISTS cluster_zres12;
CREATE TABLE cluster_zres12 AS
(
WITH single_geom AS (
SELECT (ST_Dump(geometry)).geom AS geometry
FROM osm_landuse_polygon
WHERE landuse='residential'
)
SELECT ST_ClusterDBSCAN(geometry, eps := zres(12), minpoints := 1) over () AS cid,
geometry
FROM single_geom
);
CREATE INDEX ON cluster_zres12 USING gist(geometry);
DROP TABLE IF EXISTS cluster_zres12_union;
CREATE TABLE cluster_zres12_union AS
(
SELECT ST_Buffer(
ST_Union(
ST_Buffer(
ST_SnapToGrid(geometry, 1)
, zres(12), 'join=mitre'
)
), -zres(12), 'join=mitre'
) AS geometry
FROM cluster_zres12
GROUP BY cid
);
CREATE INDEX ON cluster_zres12_union USING gist(geometry);
DROP TABLE IF EXISTS cluster_zres9;
CREATE TABLE cluster_zres9 AS
(
WITH single_geom AS (
SELECT (ST_Dump(geometry)).geom AS geometry
FROM osm_landuse_polygon
WHERE landuse='residential'
)
SELECT ST_ClusterDBSCAN(geometry, eps := zres(9), minpoints := 1) over () AS cid,
geometry
FROM single_geom
);
CREATE INDEX ON cluster_zres9 USING gist(geometry);
DROP TABLE IF EXISTS cluster_zres9_union;
CREATE TABLE cluster_zres9_union AS
(
SELECT ST_Buffer(
ST_Union(
ST_Buffer(
ST_SnapToGrid(geometry, 1)
, zres(9), 'join=mitre'
)
), -zres(9), 'join=mitre'
) AS geometry
FROM cluster_zres9
GROUP BY cid
);
CREATE INDEX ON cluster_zres9_union USING gist(geometry);
-- For z6
-- etldoc: osm_landuse_polygon -> osm_residential_gen_z6
DROP TABLE IF EXISTS osm_residential_gen_z6 CASCADE;
CREATE TABLE osm_residential_gen_z6 AS
(
SELECT ST_SimplifyVW(geometry, power(zres(6), 2)) AS geometry
FROM cluster_zres9_union
WHERE ST_Area(geometry) > power(zres(6), 2)
);
CREATE INDEX ON osm_residential_gen_z6 USING gist(geometry);
-- For z7
-- etldoc: osm_landuse_polygon -> osm_residential_gen_z7
DROP TABLE IF EXISTS osm_residential_gen_z7 CASCADE;
CREATE TABLE osm_residential_gen_z7 AS
(
SELECT ST_SimplifyVW(geometry, power(zres(7), 2)) AS geometry
FROM cluster_zres12_union
WHERE ST_Area(geometry) > power(zres(6), 2)
);
CREATE INDEX ON osm_residential_gen_z7 USING gist(geometry);
-- For z8
-- etldoc: osm_landuse_polygon -> osm_residential_gen_z8
DROP TABLE IF EXISTS osm_residential_gen_z8 CASCADE;
CREATE TABLE osm_residential_gen_z8 AS
(
SELECT ST_SimplifyVW(geometry, power(zres(8), 2)) AS geometry
FROM cluster_zres12_union
WHERE ST_Area(geometry) > power(zres(7), 2)
);
CREATE INDEX ON osm_residential_gen_z8 USING gist(geometry);
-- For z9
-- etldoc: osm_landuse_polygon -> osm_residential_gen_z9
DROP TABLE IF EXISTS osm_residential_gen_z9 CASCADE;
CREATE TABLE osm_residential_gen_z9 AS
(
SELECT ST_SimplifyVW(geometry, power(zres(9), 2)) AS geometry
FROM cluster_zres12_union
WHERE ST_Area(geometry) > power(zres(9), 2)
);
CREATE INDEX ON osm_residential_gen_z9 USING gist(geometry);
-- For z10
-- etldoc: osm_landuse_polygon -> osm_residential_gen_z10
DROP TABLE IF EXISTS osm_residential_gen_z10 CASCADE;
CREATE TABLE osm_residential_gen_z10 AS
(
SELECT ST_SimplifyVW(geometry, power(zres(10), 2)) AS geometry
FROM cluster_zres14_union
WHERE ST_Area(geometry) > power(zres(10), 2)
);
CREATE INDEX ON osm_residential_gen_z10 USING gist(geometry);
-- For z11
-- etldoc: osm_landuse_polygon -> osm_residential_gen_z11
DROP TABLE IF EXISTS osm_residential_gen_z11 CASCADE;
CREATE TABLE osm_residential_gen_z11 AS
(
SELECT ST_SimplifyVW(geometry, power(zres(11), 2)) AS geometry
FROM cluster_zres14_union
WHERE ST_Area(geometry) > power(zres(11), 2)
);
CREATE INDEX ON osm_residential_gen_z11 USING gist(geometry);
-- For z12
-- etldoc: osm_landuse_polygon -> osm_residential_gen_z12
DROP TABLE IF EXISTS osm_residential_gen_z12 CASCADE;
CREATE TABLE osm_residential_gen_z12 AS
(
SELECT ST_SimplifyVW(geometry, power(zres(12), 2)) AS geometry
FROM cluster_zres14_union
WHERE ST_Area(geometry) > power(zres(12), 2)
);
CREATE INDEX ON osm_residential_gen_z12 USING gist(geometry);

369
layers/landuse/style.json Normal file
View File

@@ -0,0 +1,369 @@
{
"layers": [
{
"id": "landuse_classes",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landuse",
"minzoom": 7,
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": [
"match",
[
"get",
"class"
],
"railway",
"#ebdbe8",
"residential",
"#e0dfdf",
"cemetery",
"#aacbaf",
"military",
"#fceaea",
"commercial",
"#f2dad9",
"industrial",
"#ebdbe8",
"garages",
"#dfddce",
"retail",
"#ffd6d1",
"bus_station",
"#e9e7e2",
"school",
"#ffffe5",
"university",
"#ffffe5",
"kindergarten",
"#ffffe5",
"college",
"#ffffe5",
"hospital",
"#ffffe5",
"stadium",
"#d5ffd9",
"pitch",
"#aae0cb",
"playground",
"#d5ffd9",
"track",
"#aae0cb",
"dam",
"#adadad",
"#000"
],
"fill-opacity": 1
},
"metadata": {},
"filter": [
"all",
[
"in",
"class",
"railway",
"cemetery",
"military",
"residential",
"commercial",
"industrial",
"garages",
"retail",
"bus_station",
"school",
"university",
"kindergarten",
"college",
"hospital",
"stadium",
"pitch",
"playground",
"track",
"dam"
],
[
"==",
"$type",
"Polygon"
]
],
"order": 1
},
{
"id": "landuse_residential",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landuse",
"minzoom": 6,
"maxzoom": 24,
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": {
"stops": [
[
7,
"#d0d0d0"
],
[
11,
"#dddddd"
],
[
12,
"#e0dfdf"
]
]
}
},
"metadata": {},
"filter": [
"all",
[
"in",
"class",
"residential",
"suburbs",
"neighbourhood"
]
],
"order": 2
},
{
"id": "landuse_class_pattern",
"type": "fill",
"source": "openmaptiles",
"source-layer": "landuse",
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": "#000000",
"fill-opacity": 1,
"fill-pattern": [
"match",
[
"get",
"class"
],
"military",
"military_red_hatch",
"cemetery",
"grave_yard_generic",
""
]
},
"metadata": {},
"filter": [
"all",
[
"in",
"class",
"military",
"cemetery"
]
],
"order": 25
},
{
"id": "landuse_class_outline",
"type": "line",
"source": "openmaptiles",
"source-layer": "landuse",
"minzoom": 13,
"layout": {
"visibility": "visible"
},
"paint": {
"line-color": [
"match",
[
"get",
"class"
],
"railway",
"#c6b3c3",
"military",
"#ff5555",
"residential",
"#b9b9b9",
"commercial",
"#f2dad9",
"industrial",
"#c6b3c3",
"retail",
"#d99c95",
"school",
"#A6A68C",
"university",
"#A6A68C",
"kindergarten",
"#A6A68C",
"college",
"#A6A68C",
"hospital",
"#A6A68C",
"stadium",
"#7ca680",
"pitch",
"#7aaa97",
"playground",
"#3c6640",
"track",
"#7aaa96",
"theme_park",
"#660033",
"zoo",
"#660033",
"dam",
"#444444",
"#000"
],
"line-width": [
"match",
[
"get",
"class"
],
"railway",
0.7,
"military",
2,
"residential",
0.5,
"commercial",
0.5,
"industrial",
0.5,
"retail",
0.5,
"school",
0.3,
"university",
0.3,
"kindergarten",
0.3,
"college",
0.3,
"hospital",
0.3,
"stadium",
0.3,
"pitch",
0.5,
"playground",
0.3,
"track",
0.5,
"theme_park",
1,
"zoo",
1,
"dam",
2,
1
],
"line-offset": [
"match",
[
"get",
"class"
],
"military",
1,
0
],
"line-opacity": [
"match",
[
"get",
"class"
],
"military",
0.24,
1
]
},
"filter": [
"all",
[
"in",
"class",
"railway",
"military",
"residential",
"commercial",
"industrial",
"retail",
"school",
"university",
"kindergarten",
"college",
"hospital",
"stadium",
"pitch",
"playground",
"track",
"theme_park",
"zoo",
"dam"
]
],
"order": 26
},
{
"id": "landuse_class_themepark",
"type": "line",
"source": "openmaptiles",
"source-layer": "landuse",
"minzoom": 13,
"layout": {
"line-cap": "square",
"line-join": "round",
"visibility": "visible"
},
"paint": {
"line-color": "#660033",
"line-width": {
"stops": [
[
9,
3.5
],
[
14,
5.5
]
]
},
"line-offset": 2,
"line-opacity": {
"stops": [
[
9,
0.1
],
[
12,
0.3
]
]
}
},
"filter": [
"all",
[
"in",
"class",
"theme_park",
"zoo"
]
],
"order": 27
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -29,3 +29,32 @@ tables:
natural:
- peak
- volcano
- saddle
# etldoc: imposm3 -> osm_mountain_linestring
mountain_linestring:
type: linestring
columns:
- name: osm_id
type: id
- name: geometry
type: geometry
- name: name
key: name
type: string
- name: name_en
key: name:en
type: string
- name: name_de
key: name:de
type: string
- name: tags
type: hstore_tags
- name: wikipedia
key: wikipedia
type: string
mapping:
natural:
- ridge
- cliff
- arete

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -1,26 +1,46 @@
-- etldoc: osm_peak_point -> peak_point
-- etldoc: ne_10m_admin_0_countries -> peak_point
CREATE OR REPLACE VIEW peak_point AS
(
SELECT pp.osm_id,
pp.geometry,
pp.name,
pp.name_en,
pp.name_de,
pp.tags,
pp.ele,
ne.iso_a2,
pp.wikipedia
FROM osm_peak_point pp, ne_10m_admin_0_countries ne
WHERE ST_Intersects(pp.geometry, ne.geometry)
);
-- etldoc: layer_mountain_peak[shape=record fillcolor=lightpink,
-- etldoc: style="rounded,filled", label="layer_mountain_peak | <z7_> z7+" ] ;
-- etldoc: style="rounded,filled", label="layer_mountain_peak | <z7_> z7+ | <z13_> z13+" ] ;
CREATE OR REPLACE FUNCTION layer_mountain_peak(bbox geometry,
zoom_level integer,
pixel_width numeric)
RETURNS TABLE
(
osm_id bigint,
geometry geometry,
name text,
name_en text,
name_de text,
class text,
tags hstore,
ele int,
ele_ft int,
"rank" int
osm_id bigint,
geometry geometry,
name text,
name_en text,
name_de text,
class text,
tags hstore,
ele int,
ele_ft int,
customary_ft int,
"rank" int
)
AS
$$
SELECT
-- etldoc: osm_peak_point -> layer_mountain_peak:z7_
-- etldoc: peak_point -> layer_mountain_peak:z7_
osm_id,
geometry,
name,
@@ -30,6 +50,7 @@ SELECT
tags,
ele::int,
ele_ft::int,
customary_ft,
rank::int
FROM (
SELECT osm_id,
@@ -40,21 +61,56 @@ FROM (
tags,
substring(ele FROM E'^(-?\\d+)(\\D|$)')::int AS ele,
round(substring(ele FROM E'^(-?\\d+)(\\D|$)')::int * 3.2808399)::int AS ele_ft,
CASE WHEN iso_a2 = 'US' THEN 1 END AS customary_ft,
row_number() OVER (
PARTITION BY LabelGrid(geometry, 100 * pixel_width)
ORDER BY (
substring(ele FROM E'^(-?\\d+)(\\D|$)')::int +
(CASE WHEN NULLIF(wikipedia, '') IS NOT NULL THEN 10000 ELSE 0 END) +
(CASE WHEN NULLIF(name, '') IS NOT NULL THEN 10000 ELSE 0 END)
(CASE WHEN wikipedia <> '' THEN 10000 ELSE 0 END) +
(CASE WHEN name <> '' THEN 10000 ELSE 0 END)
) DESC
)::int AS "rank"
FROM osm_peak_point
FROM peak_point
WHERE geometry && bbox
AND ele IS NOT NULL
AND ele ~ E'^-?\\d{1,4}(\\D|$)'
) AS ranked_peaks
WHERE zoom_level >= 7
AND (rank <= 5 OR zoom_level >= 14)
UNION ALL
SELECT
-- etldoc: osm_mountain_linestring -> layer_mountain_peak:z13_
osm_id,
geometry,
name,
name_en,
name_de,
tags->'natural' AS class,
tags,
NULL AS ele,
NULL AS ele_ft,
NULL AS customary_ft,
rank::int
FROM (
SELECT osm_id,
geometry,
name,
COALESCE(NULLIF(name_en, ''), name) AS name_en,
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
tags,
row_number() OVER (
PARTITION BY LabelGrid(geometry, 100 * pixel_width)
ORDER BY (
(CASE WHEN wikipedia <> '' THEN 10000 ELSE 0 END) +
(CASE WHEN name <> '' THEN 10000 ELSE 0 END)
) DESC
)::int AS "rank"
FROM osm_mountain_linestring
WHERE geometry && bbox
) AS ranked_mountain_linestring
WHERE zoom_level >= 13
ORDER BY "rank" ASC;
$$ LANGUAGE SQL STABLE

View File

@@ -1,5 +1,8 @@
layer:
id: "mountain_peak"
requires:
tables:
- ne_10m_admin_0_countries
description: |
[Natural peaks](http://wiki.openstreetmap.org/wiki/Tag:natural%3Dpeak)
buffer_size: 64
@@ -10,21 +13,32 @@ layer:
name_de: German name `name:de` if available, otherwise `name` or `name:en`.
class:
description: |
Use the **class** to differentiate between mountain peak and volcano.
Use the **class** to differentiate between natural objects.
values:
- peak
- volcano
- saddle
- ridge
- cliff
- arete
ele: Elevation (`ele`) in meters.
ele_ft: Elevation (`ele`) in feets.
ele_ft: Elevation (`ele`) in feet.
customary_ft:
description: |
Value 1 for peaks in location where feet is used as customary unit (USA).
values:
- 1
- NULL
rank: Rank of the peak within one tile (starting at 1 that is the most important peak).
datasource:
geometry_field: geometry
key_field: osm_id
key_field_as_attribute: no
srid: 900913
query: (SELECT osm_id, geometry, name, name_en, name_de, {name_languages}, class, ele, ele_ft, rank FROM layer_mountain_peak(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t
query: (SELECT osm_id, geometry, name, name_en, name_de, {name_languages}, class, ele, ele_ft, customary_ft, rank FROM layer_mountain_peak(!bbox!, z(!scale_denominator!), !pixel_width!)) AS t
schema:
- ./update_peak_point.sql
- ./update_mountain_linestring.sql
- ./mountain_peak.sql
datasources:
- type: imposm3

View File

@@ -0,0 +1,52 @@
{
"layers": [
{
"id": "mountain_peak",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "mountain_peak",
"maxzoom": 16,
"layout": {
"text-size": 10,
"icon-image": "peak",
"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": "#6e441e",
"text-halo-color": "rgba(255, 255, 255, .8)",
"text-halo-width": 1
},
"filter": [
"all",
[
"!=",
"class",
"cliff"
]
],
"order": 197
}
]
}

View File

@@ -0,0 +1,87 @@
DROP TRIGGER IF EXISTS trigger_flag ON osm_mountain_linestring;
DROP TRIGGER IF EXISTS trigger_store ON osm_mountain_linestring;
DROP TRIGGER IF EXISTS trigger_refresh ON mountain_linestring.updates;
CREATE SCHEMA IF NOT EXISTS mountain_linestring;
CREATE TABLE IF NOT EXISTS mountain_linestring.osm_ids
(
osm_id bigint PRIMARY KEY
);
-- etldoc: osm_mountain_linestring -> osm_mountain_linestring
CREATE OR REPLACE FUNCTION update_osm_mountain_linestring(full_update boolean) RETURNS void AS
$$
UPDATE osm_mountain_linestring
SET tags = update_tags(tags, geometry)
WHERE (full_update OR osm_id IN (SELECT osm_id FROM mountain_linestring.osm_ids))
AND COALESCE(tags -> 'name:latin', tags -> 'name:nonlatin', tags -> 'name_int') IS NULL
AND tags != update_tags(tags, geometry)
$$ LANGUAGE SQL;
SELECT update_osm_mountain_linestring(true);
-- Handle updates
CREATE OR REPLACE FUNCTION mountain_linestring.store() RETURNS trigger AS
$$
BEGIN
INSERT INTO mountain_linestring.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE TABLE IF NOT EXISTS mountain_linestring.updates
(
id serial PRIMARY KEY,
t text,
UNIQUE (t)
);
CREATE OR REPLACE FUNCTION mountain_linestring.flag() RETURNS trigger AS
$$
BEGIN
INSERT INTO mountain_linestring.updates(t) VALUES ('y') ON CONFLICT(t) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION mountain_linestring.refresh() RETURNS trigger AS
$$
DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh mountain_linestring';
-- Analyze tracking and source tables before performing update
ANALYZE mountain_linestring.osm_ids;
ANALYZE osm_mountain_linestring;
PERFORM update_osm_mountain_linestring(false);
-- noinspection SqlWithoutWhere
DELETE FROM mountain_linestring.osm_ids;
-- noinspection SqlWithoutWhere
DELETE FROM mountain_linestring.updates;
RAISE LOG 'Refresh mountain_linestring done in %', age(clock_timestamp(), t);
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE
ON osm_mountain_linestring
FOR EACH ROW
EXECUTE PROCEDURE mountain_linestring.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE
ON osm_mountain_linestring
FOR EACH STATEMENT
EXECUTE PROCEDURE mountain_linestring.flag();
CREATE CONSTRAINT TRIGGER trigger_refresh
AFTER INSERT
ON mountain_linestring.updates
INITIALLY DEFERRED
FOR EACH ROW
EXECUTE PROCEDURE mountain_linestring.refresh();

View File

@@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS mountain_peak_point;
CREATE TABLE IF NOT EXISTS mountain_peak_point.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
-- etldoc: osm_peak_point -> osm_peak_point
@@ -26,11 +26,7 @@ SELECT update_osm_peak_point(true);
CREATE OR REPLACE FUNCTION mountain_peak_point.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO mountain_peak_point.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO mountain_peak_point.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO mountain_peak_point.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -55,6 +51,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh mountain_peak_point';
-- Analyze tracking and source tables before performing update
ANALYZE mountain_peak_point.osm_ids;
ANALYZE osm_peak_point;
PERFORM update_osm_peak_point(false);
-- noinspection SqlWithoutWhere
DELETE FROM mountain_peak_point.osm_ids;
@@ -67,13 +68,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_peak_point
FOR EACH ROW
EXECUTE PROCEDURE mountain_peak_point.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_peak_point
FOR EACH STATEMENT
EXECUTE PROCEDURE mountain_peak_point.flag();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 194 KiB

View File

@@ -1,33 +1,45 @@
generalized_tables:
# etldoc: osm_park_polygon_gen_z5 -> osm_park_polygon_gen_z4
park_polygon_gen_z4:
source: park_polygon_gen_z5
sql_filter: area>power(ZRES3,2)
tolerance: ZRES4
# etldoc: osm_park_polygon_gen_z6 -> osm_park_polygon_gen_z5
park_polygon_gen_z5:
source: park_polygon_gen_z6
sql_filter: area>power(ZRES4,2)
tolerance: ZRES5
# etldoc: osm_park_polygon_gen_z7 -> osm_park_polygon_gen_z6
park_polygon_gen_z6:
source: park_polygon_gen_z7
sql_filter: area>power(ZRES5,2)
tolerance: ZRES8
tolerance: ZRES6
# etldoc: osm_park_polygon_gen_z8 -> osm_park_polygon_gen_z7
park_polygon_gen_z7:
source: park_polygon_gen_z8
sql_filter: area>power(ZRES6,2)
tolerance: ZRES8
tolerance: ZRES7
# etldoc: osm_park_polygon_gen_z9 -> osm_park_polygon_gen_z8
park_polygon_gen_z8:
source: park_polygon_gen_z9
sql_filter: area>power(ZRES7,2)
tolerance: ZRES9
tolerance: ZRES8
# etldoc: osm_park_polygon_gen_z10 -> osm_park_polygon_gen_z9
park_polygon_gen_z9:
source: park_polygon_gen_z10
sql_filter: area>power(ZRES8,2)
tolerance: ZRES10
tolerance: ZRES9
# etldoc: osm_park_polygon_gen_z11 -> osm_park_polygon_gen_z10
park_polygon_gen_z10:
source: park_polygon_gen_z11
sql_filter: area>power(ZRES9,2)
tolerance: ZRES11
tolerance: ZRES10
# etldoc: osm_park_polygon_gen_z12 -> osm_park_polygon_gen_z11
park_polygon_gen_z11:
@@ -89,3 +101,4 @@ tables:
boundary:
- national_park
- protected_area
- aboriginal_lands

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,5 +1,5 @@
-- etldoc: layer_park[shape=record fillcolor=lightpink, style="rounded,filled",
-- etldoc: label="layer_park |<z6> z6 |<z7> z7 |<z8> z8 |<z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13|<z14> z14+" ] ;
-- etldoc: label="layer_park |<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_park(bbox geometry, zoom_level int, pixel_width numeric)
RETURNS TABLE
@@ -18,25 +18,54 @@ $$
SELECT osm_id,
geometry,
class,
name,
name_en,
name_de,
NULLIF(name, '') AS name,
NULLIF(name_en, '') AS name_en,
NULLIF(name_de, '') AS name_de,
tags,
rank
FROM (
SELECT osm_id,
geometry,
COALESCE(
LOWER(REPLACE(NULLIF(protection_title, ''), ' ', '_')),
NULLIF(boundary, ''),
NULLIF(leisure, '')
) AS class,
CASE WHEN boundary='aboriginal_lands' THEN 'aboriginal_lands'
ELSE COALESCE(
LOWER(REPLACE(NULLIF(protection_title, ''), ' ', '_')),
NULLIF(boundary, ''),
NULLIF(leisure, '')
) END AS class,
name,
name_en,
name_de,
tags,
NULL::int AS rank
FROM (
-- etldoc: osm_park_polygon_dissolve_z4 -> layer_park:z4
SELECT NULL::int AS osm_id,
geometry,
NULL AS name,
NULL AS name_en,
NULL AS name_de,
NULL AS tags,
NULL AS leisure,
CASE WHEN boundary='aboriginal_lands' THEN boundary END AS boundary,
NULL AS protection_title
FROM osm_park_polygon_dissolve_z4
WHERE zoom_level = 4
AND geometry && bbox
UNION ALL
-- etldoc: osm_park_polygon_gen_z5 -> layer_park:z5
SELECT osm_id,
geometry,
name,
name_en,
name_de,
tags,
leisure,
boundary,
protection_title
FROM osm_park_polygon_gen_z5
WHERE zoom_level = 5
AND geometry && bbox
UNION ALL
-- etldoc: osm_park_polygon_gen_z6 -> layer_park:z6
SELECT osm_id,
geometry,
@@ -184,6 +213,23 @@ FROM (
area DESC
)::int AS "rank"
FROM (
-- etldoc: osm_park_polygon_gen_z5 -> layer_park:z5
SELECT osm_id,
geometry_point,
name,
name_en,
name_de,
tags,
leisure,
boundary,
protection_title,
area
FROM osm_park_polygon_gen_z5
WHERE zoom_level = 5
AND geometry_point && bbox
AND area > 70000*2^(20-zoom_level)
UNION ALL
-- etldoc: osm_park_polygon_gen_z6 -> layer_park:z6
SELECT osm_id,
geometry_point,

View File

@@ -17,6 +17,7 @@ layer:
`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).

111
layers/park/style.json Normal file
View File

@@ -0,0 +1,111 @@
{
"layers": [
{
"id": "national_parks",
"type": "line",
"source": "openmaptiles",
"source-layer": "park",
"minzoom": 8,
"layout": {
"visibility": "visible"
},
"paint": {
"line-color": "rgba(154, 199, 136, 1)",
"line-width": {
"base": 1,
"stops": [
[
8,
1.2
],
[
9,
1.5
],
[
10,
3.6
],
[
24,
3.6
]
]
},
"line-offset": 1,
"line-opacity": 0.8
},
"order": 20
},
{
"id": "national_parks_thin",
"type": "line",
"source": "openmaptiles",
"source-layer": "park",
"minzoom": 10,
"layout": {
"visibility": "none"
},
"paint": {
"line-color": "rgba(93, 156, 76, 1)",
"line-width": 1.5
},
"order": 21
},
{
"id": "park-national",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "park",
"minzoom": 7,
"maxzoom": 12,
"layout": {
"text-font": [
"Noto Sans Italic"
],
"text-size": 12,
"text-field": "{name:latin}{name:nonlatin}",
"visibility": "visible",
"symbol-spacing": 150,
"text-allow-overlap": false
},
"paint": {
"text-color": {
"stops": [
[
7,
"rgba(70, 164, 70, 1)"
],
[
10,
"#008000"
]
]
},
"text-halo-blur": 0.1,
"text-halo-color": {
"stops": [
[
7,
"rgba(241, 255, 234, 1)"
],
[
10,
"rgba(208, 250, 200, 1)"
]
]
},
"text-halo-width": 0.3
},
"filter": [
"all",
[
"<=",
"rank",
2
]
],
"order": 195
}
]
}

View File

@@ -16,6 +16,26 @@ ALTER TABLE osm_park_polygon_gen_z7
ADD COLUMN IF NOT EXISTS geometry_point geometry;
ALTER TABLE osm_park_polygon_gen_z6
ADD COLUMN IF NOT EXISTS geometry_point geometry;
ALTER TABLE osm_park_polygon_gen_z5
ADD COLUMN IF NOT EXISTS geometry_point geometry;
-- etldoc: osm_park_polygon_gen_z4 -> osm_park_polygon_dissolve_z4
DROP MATERIALIZED VIEW IF EXISTS osm_park_polygon_dissolve_z4 CASCADE;
CREATE MATERIALIZED VIEW osm_park_polygon_dissolve_z4 AS
(
SELECT min(osm_id) AS osm_id,
ST_Union(geometry) AS geometry,
boundary
FROM (
SELECT ST_ClusterDBSCAN(geometry, 0, 1) OVER() AS cluster,
osm_id,
geometry,
boundary
FROM osm_park_polygon_gen_z4
) park_cluster
GROUP BY boundary, cluster
);
CREATE UNIQUE INDEX IF NOT EXISTS osm_park_polygon_dissolve_idx ON osm_park_polygon_dissolve_z4 (osm_id);
DROP TRIGGER IF EXISTS update_row ON osm_park_polygon;
DROP TRIGGER IF EXISTS update_row ON osm_park_polygon_gen_z13;
@@ -26,6 +46,10 @@ DROP TRIGGER IF EXISTS update_row ON osm_park_polygon_gen_z9;
DROP TRIGGER IF EXISTS update_row ON osm_park_polygon_gen_z8;
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;
-- etldoc: osm_park_polygon -> osm_park_polygon
-- etldoc: osm_park_polygon_gen_z13 -> osm_park_polygon_gen_z13
@@ -36,6 +60,8 @@ DROP TRIGGER IF EXISTS update_row ON osm_park_polygon_gen_z6;
-- etldoc: osm_park_polygon_gen_z8 -> osm_park_polygon_gen_z8
-- etldoc: osm_park_polygon_gen_z7 -> osm_park_polygon_gen_z7
-- etldoc: osm_park_polygon_gen_z6 -> osm_park_polygon_gen_z6
-- etldoc: osm_park_polygon_gen_z5 -> osm_park_polygon_gen_z5
-- etldoc: osm_park_polygon_gen_z4 -> osm_park_polygon_gen_z4
CREATE OR REPLACE FUNCTION update_osm_park_polygon() RETURNS void AS
$$
BEGIN
@@ -75,6 +101,11 @@ BEGIN
SET tags = update_tags(tags, geometry),
geometry_point = st_centroid(geometry);
UPDATE osm_park_polygon_gen_z5
SET tags = update_tags(tags, geometry),
geometry_point = st_centroid(geometry);
REFRESH MATERIALIZED VIEW CONCURRENTLY osm_park_polygon_dissolve_z4;
END;
$$ LANGUAGE plpgsql;
@@ -88,7 +119,45 @@ CREATE INDEX IF NOT EXISTS osm_park_polygon_gen_z9_point_geom_idx ON osm_park_po
CREATE INDEX IF NOT EXISTS osm_park_polygon_gen_z8_point_geom_idx ON osm_park_polygon_gen_z8 USING gist (geometry_point);
CREATE INDEX IF NOT EXISTS osm_park_polygon_gen_z7_point_geom_idx ON osm_park_polygon_gen_z7 USING gist (geometry_point);
CREATE INDEX IF NOT EXISTS osm_park_polygon_gen_z6_point_geom_idx ON osm_park_polygon_gen_z6 USING gist (geometry_point);
CREATE INDEX IF NOT EXISTS osm_park_polygon_gen_z5_point_geom_idx ON osm_park_polygon_gen_z5 USING gist (geometry_point);
CREATE INDEX IF NOT EXISTS osm_park_polygon_gen_z4_polygon_geom_idx ON osm_park_polygon_gen_z4 USING gist (geometry);
CREATE INDEX IF NOT EXISTS osm_park_polygon_dissolve_z4_polygon_geom_idx ON osm_park_polygon_dissolve_z4 USING gist (geometry);
CREATE SCHEMA IF NOT EXISTS park_polygon;
CREATE TABLE IF NOT EXISTS park_polygon.updates
(
id serial PRIMARY KEY,
t text,
UNIQUE (t)
);
CREATE OR REPLACE FUNCTION park_polygon.flag() RETURNS trigger AS
$$
BEGIN
INSERT INTO park_polygon.updates(t) VALUES ('y') ON CONFLICT(t) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION park_polygon.refresh() RETURNS trigger AS
$$
DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh park_polygon';
-- Analyze tracking and source tables before performing update
ANALYZE osm_park_polygon_gen_z4;
REFRESH MATERIALIZED VIEW osm_park_polygon_dissolve_z4;
-- noinspection SqlWithoutWhere
DELETE FROM park_polygon.updates;
RAISE LOG 'Refresh park_polygon done in %', age(clock_timestamp(), t);
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION update_osm_park_polygon_row()
RETURNS trigger
@@ -101,6 +170,16 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION update_osm_park_dissolved_polygon_row()
RETURNS trigger
AS
$$
BEGIN
NEW.tags = update_tags(NEW.tags, NEW.geometry);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER update_row
BEFORE INSERT OR UPDATE
ON osm_park_polygon
@@ -154,3 +233,28 @@ CREATE TRIGGER update_row
ON osm_park_polygon_gen_z6
FOR EACH ROW
EXECUTE PROCEDURE update_osm_park_polygon_row();
CREATE TRIGGER update_row
BEFORE INSERT OR UPDATE
ON osm_park_polygon_gen_z5
FOR EACH ROW
EXECUTE PROCEDURE update_osm_park_polygon_row();
CREATE TRIGGER update_row
BEFORE INSERT OR UPDATE
ON osm_park_polygon_gen_z4
FOR EACH ROW
EXECUTE PROCEDURE update_osm_park_dissolved_polygon_row();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
ON osm_park_polygon_gen_z4
FOR EACH STATEMENT
EXECUTE PROCEDURE park_polygon.flag();
CREATE CONSTRAINT TRIGGER trigger_refresh
AFTER INSERT
ON park_polygon.updates
INITIALLY DEFERRED
FOR EACH ROW
EXECUTE PROCEDURE park_polygon.refresh();

View File

@@ -2,8 +2,8 @@ CREATE OR REPLACE FUNCTION normalize_capital_level(capital text)
RETURNS int AS
$$
SELECT CASE
WHEN capital IN ('yes', '2') THEN 2
WHEN capital = '4' THEN 4
WHEN capital = 'yes' THEN 2
WHEN capital IN ('2', '3', '4', '5', '6') THEN capital::int
END;
$$ LANGUAGE SQL IMMUTABLE
STRICT

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 136 KiB

View File

@@ -124,6 +124,9 @@ tables:
- *name_de
- name: tags
type: hstore_tags
- name: place
key: place
type: string
- name: is_in_country
key: is_in:country
type: string
@@ -140,6 +143,7 @@ tables:
mapping:
place:
- state
- province
# etldoc: imposm3 -> osm_city_point
city_point:
@@ -173,6 +177,7 @@ tables:
- town
- village
- hamlet
- borough
- suburb
- quarter
- neighbourhood

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

@@ -70,7 +70,7 @@ FROM (
COALESCE(NULLIF(name_en, ''), name) AS name_en,
COALESCE(NULLIF(name_de, ''), name, name_en) AS name_de,
tags,
'state' AS class,
place::text AS class,
"rank",
NULL::int AS capital,
NULL::text AS iso_a2

View File

@@ -1,8 +1,14 @@
layer:
id: "place"
requires:
tables:
- ne_10m_admin_1_states_provinces
- ne_10m_admin_0_countries
- ne_10m_populated_places
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) and [cities](http://wiki.openstreetmap.org/wiki/Key:place).
[states](http://wiki.openstreetmap.org/wiki/Tag:place%3Dstate), [cities](http://wiki.openstreetmap.org/wiki/Key:place)
and [islands](https://wiki.openstreetmap.org/wiki/Tag:place%3Disland).
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:
@@ -14,12 +20,12 @@ layer:
The **capital** field marks the
[`admin_level`](http://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative#admin_level)
of the boundary the place is a capital of.
values: [2, 4]
values: [2, 3, 4, 5, 6]
class:
description: |
Original value of the
[`place`](http://wiki.openstreetmap.org/wiki/Key:place) tag.
Distinguish between continents, countries, states and
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.
@@ -27,14 +33,17 @@ layer:
- continent
- country
- state
- province
- city
- town
- village
- hamlet
- borough
- suburb
- quarter
- neighbourhood
- isolated_dwelling
- island
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`.
@@ -44,7 +53,7 @@ layer:
description: |
Countries, states and the most important cities all have a
**rank** to boost their importance on the map.
The **rank** field for counries and states ranges from
The **rank** field for countries and states ranges from
`1` to `6` while the **rank** field for cities ranges from
`1` to `10` for the most important cities
and continues from `10` serially based on the

662
layers/place/style.json Normal file
View File

@@ -0,0 +1,662 @@
{
"layers": [
{
"id": "place_other",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 8,
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"base": 1.2,
"stops": [
[
11,
10
],
[
14,
14
],
[
18,
16
]
]
},
"text-field": "{name:latin}\n{name:nonlatin}",
"visibility": "visible",
"symbol-spacing": 150,
"text-max-width": 10,
"text-transform": "none"
},
"paint": {
"text-color": {
"stops": [
[
12.5,
"#222222"
],
[
12.6,
"#777777"
]
]
},
"text-halo-blur": 0,
"text-halo-color": {
"stops": [
[
11,
"rgba(255,255,255,0.6)"
],
[
13,
"#ffffff"
]
]
},
"text-halo-width": {
"stops": [
[
8,
0.8
],
[
13,
1.5
]
]
}
},
"metadata": {},
"filter": [
"all",
[
"in",
"class",
"hamlet",
"island",
"islet",
"neighbourhood",
"suburb",
"borough"
]
],
"order": 193
},
{
"id": "place_village",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 8,
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"base": 1.2,
"stops": [
[
10,
10
],
[
15,
16
]
]
},
"text-field": "{name:latin}\n{name:nonlatin}",
"visibility": "visible",
"text-max-width": 8
},
"paint": {
"text-color": "#333",
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 1.2
},
"metadata": {},
"filter": [
"all",
[
"==",
"class",
"village"
]
],
"order": 198
},
{
"id": "place_town",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 6,
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"base": 1.2,
"stops": [
[
7,
10
],
[
11,
13
]
]
},
"text-field": "{name:latin}\n{name:nonlatin}",
"visibility": "visible",
"text-anchor": "bottom",
"text-offset": [
0,
0
],
"text-max-width": 8
},
"paint": {
"text-color": "#333",
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 1.2
},
"metadata": {},
"filter": [
"all",
[
"==",
"class",
"town"
]
],
"order": 199
},
{
"id": "place_state",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 4,
"maxzoom": 12,
"layout": {
"text-font": [
"Noto Sans Regular",
"Noto Sans Bold"
],
"text-size": {
"stops": [
[
3,
10
],
[
6,
14
]
]
},
"text-field": "{name:latin}",
"visibility": "visible",
"text-padding": 2,
"text-transform": "none",
"text-letter-spacing": 0
},
"paint": {
"text-color": "#7e587d",
"text-halo-color": "rgba(255,255,255,0.7)",
"text-halo-width": 0.8
},
"metadata": {},
"filter": [
"all",
[
"==",
"class",
"state"
],
[
"<",
"rank",
3
]
],
"order": 200
},
{
"id": "place_city",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 4,
"maxzoom": 14,
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"base": 1.2,
"stops": [
[
4,
12
],
[
15,
18
]
]
},
"icon-image": {
"stops": [
[
4,
"place-6"
],
[
7,
" "
]
]
},
"text-field": "{name:latin}\n{name:nonlatin}",
"visibility": "visible",
"icon-offset": [
0,
3
],
"text-anchor": "bottom",
"text-offset": [
0,
0
],
"icon-optional": false,
"text-max-width": 8,
"icon-allow-overlap": true
},
"paint": {
"text-color": {
"stops": [
[
6,
"rgba(88, 88, 88, 1)"
],
[
14,
"rgba(32, 32, 32, 1)"
]
]
},
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 1
},
"metadata": {},
"filter": [
"all",
[
"==",
"class",
"city"
],
[
"!=",
"rank",
1
]
],
"order": 201
},
{
"id": "place_capital",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 3,
"maxzoom": 15,
"layout": {
"icon-size": 1,
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"base": 1.2,
"stops": [
[
4,
11
],
[
12,
16
]
]
},
"icon-image": {
"stops": [
[
6,
"place-capital-8"
],
[
8,
""
]
]
},
"text-field": "{name:latin}\n{name:nonlatin}",
"visibility": "visible",
"icon-offset": [
0,
3
],
"text-anchor": "bottom",
"text-offset": [
0,
0
],
"icon-optional": false,
"text-max-width": 8,
"icon-allow-overlap": true
},
"paint": {
"text-color": {
"stops": [
[
6,
"rgba(73, 73, 73, 1)"
],
[
14,
"rgba(32, 32, 32, 1)"
]
]
},
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 1.2
},
"metadata": {},
"filter": [
"all",
[
"==",
"class",
"city"
],
[
"in",
"capital",
1,
2
]
],
"order": 202
},
{
"id": "country_other",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 4,
"maxzoom": 15,
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"stops": [
[
3,
11
],
[
5,
13
],
[
7,
20
]
]
},
"text-field": "{name:latin}",
"visibility": "visible",
"text-max-width": 6.25,
"text-transform": "none"
},
"paint": {
"text-color": "rgba(131, 81, 130, 1)",
"text-halo-blur": 1,
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 0.8
},
"metadata": {},
"filter": [
"all",
[
"==",
"class",
"country"
],
[
"!has",
"iso_a2"
]
],
"order": 203
},
{
"id": "country_3",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 5,
"maxzoom": 12,
"layout": {
"text-font": [
"Noto Sans Bold"
],
"text-size": {
"stops": [
[
3,
11
],
[
5,
13
],
[
7,
17
]
]
},
"text-field": "{name:latin}",
"visibility": "visible",
"text-max-width": 6.25,
"text-transform": "none"
},
"paint": {
"text-color": {
"stops": [
[
3,
"rgba(108, 78, 107, 1)"
],
[
10,
"rgba(57, 37, 73, 1)"
]
]
},
"text-halo-blur": 1,
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 0.8
},
"metadata": {},
"filter": [
"all",
[
">=",
"rank",
3
],
[
"==",
"class",
"country"
],
[
"has",
"iso_a2"
]
],
"order": 204
},
{
"id": "country_2",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 2,
"maxzoom": 12,
"layout": {
"text-font": [
"Noto Sans Bold"
],
"text-size": {
"stops": [
[
3,
11
],
[
5,
14
],
[
7,
19
]
]
},
"text-field": "{name:latin}",
"visibility": "visible",
"text-max-width": 6.25,
"text-transform": "none"
},
"paint": {
"text-color": {
"stops": [
[
3,
"rgba(108, 78, 107, 1)"
],
[
10,
"rgba(57, 37, 73, 1)"
]
]
},
"text-halo-blur": 1,
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 0.8
},
"metadata": {},
"filter": [
"all",
[
"==",
"rank",
2
],
[
"==",
"class",
"country"
],
[
"has",
"iso_a2"
]
],
"order": 205
},
{
"id": "country_1",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "place",
"minzoom": 2,
"maxzoom": 12,
"layout": {
"text-font": [
"Noto Sans Bold"
],
"text-size": {
"stops": [
[
3,
11
],
[
5,
14
],
[
7,
19
]
]
},
"text-field": "{name:latin}",
"visibility": "visible",
"text-max-width": 6.25,
"text-transform": "none"
},
"paint": {
"text-color": {
"stops": [
[
2,
"rgba(108, 78, 107, 1)"
],
[
10,
"rgba(57, 37, 73, 1)"
]
]
},
"text-halo-blur": 1,
"text-halo-color": "rgba(255,255,255,0.8)",
"text-halo-width": 0.8
},
"metadata": {},
"filter": [
"all",
[
"==",
"rank",
1
],
[
"==",
"class",
"country"
],
[
"has",
"iso_a2"
]
],
"order": 206
}
]
}

View File

@@ -1,9 +1,10 @@
DO
$$
BEGIN
IF NOT EXISTS(SELECT 1 FROM pg_type WHERE typname = 'city_place') THEN
CREATE TYPE city_place AS enum ('city', 'town', 'village', 'hamlet', 'suburb', 'quarter', 'neighbourhood', 'isolated_dwelling');
END IF;
PERFORM 'city_place'::regtype;
EXCEPTION
WHEN undefined_object THEN
CREATE TYPE city_place AS enum ('city', 'town', 'village', 'hamlet', 'borough', 'suburb', 'quarter', 'neighbourhood', 'isolated_dwelling');
END
$$;

View File

@@ -8,7 +8,7 @@ CREATE SCHEMA IF NOT EXISTS place_city;
CREATE TABLE IF NOT EXISTS place_city.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
CREATE OR REPLACE FUNCTION update_osm_city_point(full_update boolean) RETURNS void AS
@@ -23,8 +23,8 @@ $$
LEFT JOIN ne_10m_populated_places AS ne ON
(
(osm.tags ? 'wikidata' AND osm.tags->'wikidata' = ne.wikidataid) OR
lower(osm.name) IN (lower(ne.name), lower(ne.namealt), lower(ne.meganame), lower(ne.gn_ascii), lower(ne.nameascii)) OR
lower(osm.name_en) IN (lower(ne.name), lower(ne.namealt), lower(ne.meganame), lower(ne.gn_ascii), lower(ne.nameascii)) OR
lower(osm.name) IN (lower(ne.name), lower(ne.namealt), lower(ne.meganame), lower(ne.name_en), lower(ne.nameascii)) OR
lower(osm.name_en) IN (lower(ne.name), lower(ne.namealt), lower(ne.meganame), lower(ne.name_en), lower(ne.nameascii)) OR
ne.name = unaccent(osm.name)
)
AND osm.place IN ('city', 'town', 'village')
@@ -56,11 +56,7 @@ CREATE INDEX IF NOT EXISTS osm_city_point_rank_idx ON osm_city_point ("rank");
CREATE OR REPLACE FUNCTION place_city.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_city.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_city.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_city.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -85,6 +81,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh place_city rank';
-- Analyze tracking and source tables before performing update
ANALYZE place_city.osm_ids;
ANALYZE osm_city_point;
PERFORM update_osm_city_point(false);
-- noinspection SqlWithoutWhere
DELETE FROM place_city.osm_ids;
@@ -97,13 +98,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_city_point
FOR EACH ROW
EXECUTE PROCEDURE place_city.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_city_point
FOR EACH STATEMENT
EXECUTE PROCEDURE place_city.flag();

View File

@@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_continent_point;
CREATE TABLE IF NOT EXISTS place_continent_point.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
-- etldoc: osm_continent_point -> osm_continent_point
@@ -26,11 +26,7 @@ SELECT update_osm_continent_point(true);
CREATE OR REPLACE FUNCTION place_continent_point.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_continent_point.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_continent_point.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_continent_point.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -55,6 +51,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh place_continent_point';
-- Analyze tracking and source tables before performing update
ANALYZE place_continent_point.osm_ids;
ANALYZE osm_continent_point;
PERFORM update_osm_continent_point(false);
-- noinspection SqlWithoutWhere
DELETE FROM place_continent_point.osm_ids;
@@ -67,13 +68,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_continent_point
FOR EACH ROW
EXECUTE PROCEDURE place_continent_point.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_continent_point
FOR EACH STATEMENT
EXECUTE PROCEDURE place_continent_point.flag();

View File

@@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_country;
CREATE TABLE IF NOT EXISTS place_country.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
-- etldoc: ne_10m_admin_0_countries -> osm_country_point
@@ -105,11 +105,7 @@ CREATE INDEX IF NOT EXISTS osm_country_point_rank_idx ON osm_country_point ("ran
CREATE OR REPLACE FUNCTION place_country.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_country.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_country.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_country.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -134,6 +130,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh place_country rank';
-- Analyze tracking and source tables before performing update
ANALYZE place_country.osm_ids;
ANALYZE osm_country_point;
PERFORM update_osm_country_point(false);
-- noinspection SqlWithoutWhere
DELETE FROM place_country.osm_ids;
@@ -146,13 +147,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_country_point
FOR EACH ROW
EXECUTE PROCEDURE place_country.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_country_point
FOR EACH STATEMENT
EXECUTE PROCEDURE place_country.flag();

View File

@@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_island_point;
CREATE TABLE IF NOT EXISTS place_island_point.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
-- etldoc: osm_island_point -> osm_island_point
@@ -26,11 +26,7 @@ SELECT update_osm_island_point(true);
CREATE OR REPLACE FUNCTION place_island_point.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_island_point.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_island_point.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_island_point.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -55,6 +51,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh place_island_point';
-- Analyze tracking and source tables before performing update
ANALYZE place_island_point.osm_ids;
ANALYZE osm_island_point;
PERFORM update_osm_island_point(false);
-- noinspection SqlWithoutWhere
DELETE FROM place_island_point.osm_ids;
@@ -67,13 +68,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_island_point
FOR EACH ROW
EXECUTE PROCEDURE place_island_point.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_island_point
FOR EACH STATEMENT
EXECUTE PROCEDURE place_island_point.flag();

View File

@@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_island_polygon;
CREATE TABLE IF NOT EXISTS place_island_polygon.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
-- etldoc: osm_island_polygon -> osm_island_polygon
@@ -33,11 +33,7 @@ SELECT update_osm_island_polygon(true);
CREATE OR REPLACE FUNCTION place_island_polygon.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_island_polygon.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_island_polygon.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_island_polygon.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -62,6 +58,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh place_island_polygon';
-- Analyze tracking and source tables before performing update
ANALYZE place_island_polygon.osm_ids;
ANALYZE osm_island_polygon;
PERFORM update_osm_island_polygon(false);
-- noinspection SqlWithoutWhere
DELETE FROM place_island_polygon.osm_ids;
@@ -74,13 +75,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_island_polygon
FOR EACH ROW
EXECUTE PROCEDURE place_island_polygon.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_island_polygon
FOR EACH STATEMENT
EXECUTE PROCEDURE place_island_polygon.flag();

View File

@@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS place_state;
CREATE TABLE IF NOT EXISTS place_state.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
-- etldoc: ne_10m_admin_1_states_provinces -> osm_state_point
@@ -29,8 +29,8 @@ $$
-- because name matching is difficult
ST_Within(osm.geometry, ne.geometry)
-- We leave out leess important states
AND ne.scalerank <= 3
AND ne.labelrank <= 2
AND ne.scalerank <= 6
AND ne.labelrank <= 7
)
UPDATE osm_state_point AS osm
-- Normalize both scalerank and labelrank into a ranking system from 1 to 6.
@@ -67,11 +67,7 @@ CREATE INDEX IF NOT EXISTS osm_state_point_rank_idx ON osm_state_point ("rank");
CREATE OR REPLACE FUNCTION place_state.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO place_state.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO place_state.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO place_state.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -96,6 +92,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh place_state rank';
-- Analyze tracking and source tables before performing update
ANALYZE place_state.osm_ids;
ANALYZE osm_state_point;
PERFORM update_osm_state_point(false);
-- noinspection SqlWithoutWhere
DELETE FROM place_state.osm_ids;
@@ -108,13 +109,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_state_point
FOR EACH ROW
EXECUTE PROCEDURE place_state.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_state_point
FOR EACH STATEMENT
EXECUTE PROCEDURE place_state.flag();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

@@ -9,6 +9,7 @@ def_poi_mapping_aerialway: &poi_mapping_aerialway
# amenity values , see http://taginfo.openstreetmap.org/keys/amenity#values
def_poi_mapping_amenity: &poi_mapping_amenity
- arts_centre
- atm
- bank
- bar
- bbq
@@ -26,7 +27,6 @@ def_poi_mapping_amenity: &poi_mapping_amenity
- dentist
- doctors
- drinking_water
- embassy
- fast_food
- ferry_terminal
- fire_station
@@ -45,6 +45,7 @@ def_poi_mapping_amenity: &poi_mapping_amenity
- pharmacy
- place_of_worship
- police
- parcel_locker
- post_box
- post_office
- prison
@@ -121,6 +122,10 @@ def_poi_mapping_leisure: &poi_mapping_leisure
- water_park
- nature_reserve
# office values , see http://taginfo.openstreetmap.org/keys/office#values
def_poi_mapping_office: &poi_mapping_office
- diplomatic
# railway values , see http://taginfo.openstreetmap.org/keys/railway#values
def_poi_mapping_railway: &poi_mapping_railway
- halt
@@ -184,6 +189,7 @@ def_poi_mapping_shop: &poi_mapping_shop
- kiosk
- lamps
- laundry
- locksmith
- mall
- massage
- mobile_phone
@@ -345,6 +351,8 @@ def_poi_fields: &poi_fields
type: id
- name: geometry
type: geometry
- name: area
type: area
- name: name
key: name
type: string
@@ -372,6 +380,9 @@ def_poi_fields: &poi_fields
- name: uic_ref
key: uic_ref
type: string
- name: ref
key: ref
type: string
- name: religion
key: religion
type: string
@@ -393,6 +404,15 @@ def_poi_fields: &poi_fields
- name: source
key: "generator:source"
type: string
- name: operator
key: operator
type: string
- name: network
key: network
type: string
- name: brand
key: brand
type: string
def_poi_mapping: &poi_mapping
aerialway: *poi_mapping_aerialway
@@ -403,6 +423,7 @@ def_poi_mapping: &poi_mapping
historic: *poi_mapping_historic
landuse: *poi_mapping_landuse
leisure: *poi_mapping_leisure
office: *poi_mapping_office
railway: *poi_mapping_railway
shop: *poi_mapping_shop
sport: *poi_mapping_sport

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@@ -94,20 +94,20 @@ FROM (
-- etldoc: osm_poi_polygon -> layer_poi:z12
-- etldoc: osm_poi_polygon -> layer_poi:z13
SELECT *,
NULL::integer AS agg_stop,
CASE
WHEN osm_id < 0 THEN -osm_id * 10 + 4
ELSE osm_id * 10 + 1
END AS osm_id_hash
FROM osm_poi_polygon
WHERE geometry && bbox
AND zoom_level BETWEEN 12 AND 13
AND ((subclass = 'station' AND mapping_key = 'railway')
OR subclass IN ('halt', 'ferry_terminal'))
UNION ALL
-- OLD
-- SELECT *,
-- NULL::integer AS agg_stop,
-- CASE
-- WHEN osm_id < 0 THEN -osm_id * 10 + 4
-- ELSE osm_id * 10 + 1
-- END AS osm_id_hash
-- FROM osm_poi_polygon
-- WHERE geometry && bbox
-- AND zoom_level BETWEEN 12 AND 13
-- AND ((subclass = 'station' AND mapping_key = 'railway')
-- OR subclass IN ('halt', 'ferry_terminal'))
--
-- UNION ALL
-- etldoc: osm_poi_polygon -> layer_poi:z14_
SELECT *,
NULL::integer AS agg_stop,
@@ -116,8 +116,21 @@ FROM (
ELSE osm_id * 10 + 1
END AS osm_id_hash
FROM osm_poi_polygon
WHERE geometry && bbox
AND zoom_level >= 14
WHERE geometry && bbox AND
CASE
WHEN zoom_level >= 14 THEN TRUE
WHEN zoom_level >= 12 AND
((subclass = 'station' AND mapping_key = 'railway')
OR subclass IN ('halt', 'ferry_terminal')) THEN TRUE
WHEN zoom_level BETWEEN 10 AND 14 THEN
subclass IN ('university', 'college') AND
POWER(4,zoom_level)
-- Compute percentage of the earth's surface covered by this feature (approximately)
-- The constant below is 111,842^2 * 180 * 180, where 111,842 is the length of one degree of latitude at the equator in meters.
* area / (405279708033600 * COS(ST_Y(ST_Transform(geometry,4326))*PI()/180))
-- Match features that are at least 10% of a tile at this zoom
> 0.10
ELSE FALSE END
) AS poi_union_raw
WHERE NOT (mapping_key = 'building' AND (subclass = 'office' OR subclass = 'industrial') AND coalesce(name, name_en, '') = '')
) AS poi_union

View File

@@ -18,37 +18,39 @@ layer:
values:
shop:
subclass: ['accessories', 'antiques', 'beauty', 'bed', 'boutique', 'camera', 'carpet', 'charity', 'chemist',
'coffee', 'computer', 'convenience', 'copyshop', 'cosmetics',
'erotic', 'fabric', 'frozen_food', 'video_games', 'video', 'general', 'gift',
'hearing_aids', 'hifi', 'interior_decoration', 'kiosk', 'lamps', 'mall', 'massage','outdoor',
'perfumery', 'perfume', 'pet', 'photo', 'second_hand', 'sports', 'stationery', 'tailor', 'tattoo',
'ticket', 'tobacco', 'travel_agency', 'watches', 'weapons', 'wholesale']
'coffee', 'computer', 'convenience', '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',
'stationery', 'tailor', 'tattoo', 'ticket', 'tobacco', 'toys', 'travel_agency',
'watches', ''weapons', 'wholesale']
optician:
subclass: ['optician']
subclass: [ 'optician' ]
toys:
subclass: ['toys']
subclass: [ 'toys' ]
jewelry:
subclass: ['jewelry']
subclass: [ 'jewelry' ]
furniture:
subclass: ['furniture']
subclass: [ 'furniture' ]
newsagent:
subclass: ['newsagent']
subclass: [ 'newsagent' ]
paint:
subclass: ['paint']
subclass: [ 'paint' ]
beverages:
subclass: ['beverages']
subclass: [ 'beverages' ]
electronics:
subclass: ['electronics']
subclass: [ 'electronics' ]
garden_centre:
subclass: ['garden_centre']
subclass: [ 'garden_centre' ]
mobile_phone:
subclass: ['mobile_phone']
subclass: [ 'mobile_phone' ]
shoes:
subclass: ['shoes']
subclass: [ 'shoes' ]
hardware:
subclass: ['hardware', 'doityourself']
subclass: [ 'hardware', 'doityourself' ]
florist:
subclass: ['florist']
subclass: [ 'florist' ]
town_hall:
subclass: ['townhall', 'public_building', 'courthouse']
community_centre:
@@ -87,7 +89,7 @@ layer:
ice_cream:
subclass: ['chocolate', 'confectionery', 'ice_cream']
post:
subclass: ['post_box', 'post_office']
subclass: ['post_box', 'post_office', 'parcel_locker']
cafe:
subclass: ['cafe']
school:
@@ -126,25 +128,27 @@ layer:
subclass: ['swimming_area', 'swimming']
castle:
subclass: ['castle', 'ruins']
atm:
subclass: ['atm']
airport:
subclass: ['aerodrome']
subclass: [ 'aerodrome' ]
heliport:
subclass: ['helipad']
subclass: [ 'helipad' ]
wind_turbine:
__AND__:
subclass: ['generator']
subtype: ['wind']
mapping_key: ['power']
subclass: [ 'generator' ]
subtype: [ 'wind' ]
mapping_key: [ 'power' ]
communications_tower:
subclass: ['communications_tower']
subclass: [ 'communications_tower' ]
water_tower:
subclass: ['water_tower']
subclass: [ 'water_tower' ]
wind_mill:
subclass: ['wind_mill']
subclass: [ 'wind_mill' ]
power_tower:
subclass: ['tower']
subclass: [ 'tower' ]
industry:
subclass: ['industrial']
subclass: [ 'industrial' ]
subclass:
description: |
Original value of either the
@@ -162,7 +166,8 @@ layer:
[`tourism`](http://wiki.openstreetmap.org/wiki/Key:tourism),
[`aerialway`](http://wiki.openstreetmap.org/wiki/Key:aerialway),
[`building`](http://wiki.openstreetmap.org/wiki/Key:building),
[`highway`](http://wiki.openstreetmap.org/wiki/Key:highway)
[`highway`](http://wiki.openstreetmap.org/wiki/Key:highway),
[`office`](https://wiki.openstreetmap.org/wiki/Key:office)
or [`waterway`](http://wiki.openstreetmap.org/wiki/Key:waterway)
tag. Use this to do more precise styling.
rank: |

View File

@@ -1,3 +1,4 @@
-- etldoc: osm_poi_point -> osm_poi_stop_centroid
DROP MATERIALIZED VIEW IF EXISTS osm_poi_stop_centroid CASCADE;
CREATE MATERIALIZED VIEW osm_poi_stop_centroid AS
(
@@ -5,12 +6,14 @@ SELECT uic_ref,
count(*) AS count,
CASE WHEN count(*) > 2 THEN ST_Centroid(ST_UNION(geometry)) END AS centroid
FROM osm_poi_point
WHERE nullif(uic_ref, '') IS NOT NULL
WHERE uic_ref <> ''
AND subclass IN ('bus_stop', 'bus_station', 'tram_stop', 'subway')
GROUP BY uic_ref
HAVING count(*) > 1
) /* DELAY_MATERIALIZED_VIEW_CREATION */;
-- etldoc: osm_poi_stop_centroid -> osm_poi_stop_rank
-- etldoc: osm_poi_point -> osm_poi_stop_rank
DROP MATERIALIZED VIEW IF EXISTS osm_poi_stop_rank CASCADE;
CREATE MATERIALIZED VIEW osm_poi_stop_rank AS
(

View File

@@ -1,12 +1,11 @@
DO
$$
BEGIN
IF NOT EXISTS(SELECT 1
FROM pg_type
WHERE typname = 'public_transport_stop_type') THEN
PERFORM 'public_transport_stop_type'::regtype;
EXCEPTION
WHEN undefined_object THEN
CREATE TYPE public_transport_stop_type AS enum (
'subway', 'tram_stop', 'bus_station', 'bus_stop'
);
END IF;
END
$$;

1704
layers/poi/style.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,47 +1,99 @@
DROP TRIGGER IF EXISTS trigger_flag ON osm_poi_point;
DROP TRIGGER IF EXISTS trigger_refresh ON poi_point.updates;
DROP TRIGGER IF EXISTS trigger_store ON osm_poi_point;
CREATE SCHEMA IF NOT EXISTS poi_point;
CREATE TABLE IF NOT EXISTS poi_point.osm_ids
(
osm_id bigint PRIMARY KEY
);
-- etldoc: osm_poi_point -> osm_poi_point
CREATE OR REPLACE FUNCTION update_osm_poi_point() RETURNS void AS
CREATE OR REPLACE FUNCTION update_osm_poi_point(full_update bool) RETURNS void AS
$$
BEGIN
UPDATE osm_poi_point
SET subclass = 'subway'
WHERE station = 'subway'
WHERE (full_update OR osm_id IN (SELECT osm_id FROM poi_point.osm_ids))
AND station = 'subway'
AND subclass = 'station';
UPDATE osm_poi_point
SET subclass = 'halt'
WHERE funicular = 'yes'
WHERE (full_update OR osm_id IN (SELECT osm_id FROM poi_point.osm_ids))
AND funicular = 'yes'
AND subclass = 'station';
-- ATM without name
-- use either operator or network
-- (using name for ATM is discouraged, see osm wiki)
UPDATE osm_poi_point
SET (name, tags) = (
COALESCE(tags -> 'operator', tags -> 'network'),
tags || hstore('name', COALESCE(tags -> 'operator', tags -> 'network'))
)
WHERE (full_update OR osm_id IN (SELECT osm_id FROM poi_point.osm_ids))
AND subclass = 'atm'
AND name = ''
AND COALESCE(tags -> 'operator', tags -> 'network') IS NOT NULL;
-- Parcel locker 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_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')))
)
WHERE (full_update OR osm_id IN (SELECT osm_id FROM poi_point.osm_ids))
AND subclass = 'parcel_locker'
AND name = ''
AND COALESCE(tags -> 'brand', tags -> 'operator') IS NOT NULL;
UPDATE osm_poi_point
SET tags = update_tags(tags, geometry)
WHERE COALESCE(tags->'name:latin', tags->'name:nonlatin', tags->'name_int') IS NULL;
WHERE (full_update OR osm_id IN (SELECT osm_id FROM poi_point.osm_ids))
AND COALESCE(tags->'name:latin', tags->'name:nonlatin', tags->'name_int') IS NULL
AND tags != update_tags(tags, geometry);
END;
$$ LANGUAGE plpgsql;
SELECT update_osm_poi_point();
SELECT update_osm_poi_point(TRUE);
-- etldoc: osm_poi_stop_rank -> osm_poi_point
CREATE OR REPLACE FUNCTION update_osm_poi_point_agg() RETURNS void AS
$$
BEGIN
UPDATE osm_poi_point p
SET agg_stop = CASE
WHEN p.subclass IN ('bus_stop', 'bus_station', 'tram_stop', 'subway')
THEN 1
SET
agg_stop = CASE
WHEN p.subclass IN ('bus_stop', 'bus_station', 'tram_stop', 'subway')
THEN 1
END
WHERE
agg_stop IS DISTINCT FROM CASE
WHEN p.subclass IN ('bus_stop', 'bus_station', 'tram_stop', 'subway')
THEN 1
END;
UPDATE osm_poi_point p
SET agg_stop = (
SET
agg_stop = (
CASE
WHEN p.subclass IN ('bus_stop', 'bus_station', 'tram_stop', 'subway')
AND r.rk IS NULL OR r.rk = 1
AND (r.rk IS NULL OR r.rk = 1)
THEN 1
END)
END)
FROM osm_poi_stop_rank r
WHERE p.osm_id = r.osm_id;
WHERE p.osm_id = r.osm_id AND
agg_stop IS DISTINCT FROM (
CASE
WHEN p.subclass IN ('bus_stop', 'bus_station', 'tram_stop', 'subway')
AND (r.rk IS NULL OR r.rk = 1)
THEN 1
END);
END;
$$ LANGUAGE plpgsql;
@@ -52,7 +104,13 @@ SELECT update_osm_poi_point_agg();
-- Handle updates
CREATE SCHEMA IF NOT EXISTS poi_point;
CREATE OR REPLACE FUNCTION poi_point.store() RETURNS trigger AS
$$
BEGIN
INSERT INTO poi_point.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE TABLE IF NOT EXISTS poi_point.updates
(
@@ -74,11 +132,18 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh poi_point';
PERFORM update_osm_poi_point();
-- Analyze tracking and source tables before performing update
ANALYZE poi_point.osm_ids;
ANALYZE osm_poi_point;
PERFORM update_osm_poi_point(FALSE);
REFRESH MATERIALIZED VIEW osm_poi_stop_centroid;
REFRESH MATERIALIZED VIEW osm_poi_stop_rank;
PERFORM update_osm_poi_point_agg();
-- noinspection SqlWithoutWhere
DELETE FROM poi_point.osm_ids;
-- noinspection SqlWithoutWhere
DELETE FROM poi_point.updates;
RAISE LOG 'Refresh poi_point done in %', age(clock_timestamp(), t);
@@ -86,8 +151,14 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE
ON osm_poi_point
FOR EACH ROW
EXECUTE PROCEDURE poi_point.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_poi_point
FOR EACH STATEMENT
EXECUTE PROCEDURE poi_point.flag();

View File

@@ -6,7 +6,7 @@ CREATE SCHEMA IF NOT EXISTS poi_polygon;
CREATE TABLE IF NOT EXISTS poi_polygon.osm_ids
(
osm_id bigint
osm_id bigint PRIMARY KEY
);
-- etldoc: osm_poi_polygon -> osm_poi_polygon
@@ -51,11 +51,7 @@ SELECT update_poi_polygon(true);
CREATE OR REPLACE FUNCTION poi_polygon.store() RETURNS trigger AS
$$
BEGIN
IF (tg_op = 'DELETE') THEN
INSERT INTO poi_polygon.osm_ids VALUES (OLD.osm_id);
ELSE
INSERT INTO poi_polygon.osm_ids VALUES (NEW.osm_id);
END IF;
INSERT INTO poi_polygon.osm_ids VALUES (NEW.osm_id) ON CONFLICT (osm_id) DO NOTHING;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
@@ -80,6 +76,11 @@ DECLARE
t TIMESTAMP WITH TIME ZONE := clock_timestamp();
BEGIN
RAISE LOG 'Refresh poi_polygon';
-- Analyze tracking and source tables before performing update
ANALYZE poi_polygon.osm_ids;
ANALYZE osm_poi_polygon;
PERFORM update_poi_polygon(false);
-- noinspection SqlWithoutWhere
DELETE FROM poi_polygon.osm_ids;
@@ -92,13 +93,13 @@ END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_store
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_poi_polygon
FOR EACH ROW
EXECUTE PROCEDURE poi_polygon.store();
CREATE TRIGGER trigger_flag
AFTER INSERT OR UPDATE OR DELETE
AFTER INSERT OR UPDATE
ON osm_poi_polygon
FOR EACH STATEMENT
EXECUTE PROCEDURE poi_polygon.flag();

View File

@@ -48,7 +48,7 @@ CREATE OR REPLACE FUNCTION surface_value(surface text) RETURNS text AS
$$
SELECT CASE
WHEN surface IN ('paved', 'asphalt', 'cobblestone', 'concrete', 'concrete:lanes', 'concrete:plates', 'metal',
'paving_stones', 'sett', 'unhewn_cobblestone', 'wood') THEN 'paved'
'paving_stones', 'sett', 'unhewn_cobblestone', 'wood', 'grade1') THEN 'paved'
WHEN surface IN ('unpaved', 'compacted', 'dirt', 'earth', 'fine_gravel', 'grass', 'grass_paver', 'gravel',
'gravel_turf', 'ground', 'ice', 'mud', 'pebblestone', 'salt', 'sand', 'snow', 'woodchips')
THEN 'unpaved'
@@ -56,3 +56,38 @@ SELECT CASE
$$ LANGUAGE SQL IMMUTABLE
STRICT
PARALLEL SAFE;
-- Determine which transportation features are shown at zoom 12
CREATE OR REPLACE FUNCTION transportation_filter_z12(highway text, construction text) RETURNS boolean AS
$$
SELECT CASE
WHEN highway IN ('unclassified', 'residential') THEN TRUE
WHEN highway_class(highway, '', construction) IN
(
'motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'raceway',
'motorway_construction', 'trunk_construction', 'primary_construction',
'secondary_construction', 'tertiary_construction', 'raceway_construction',
'busway', 'bus_guideway'
) THEN TRUE --includes ramps
ELSE FALSE
END
$$ LANGUAGE SQL IMMUTABLE
STRICT
PARALLEL SAFE;
-- Determine which transportation features are shown at zoom 13
-- Assumes that piers have already been excluded
CREATE OR REPLACE FUNCTION transportation_filter_z13(highway text,
public_transport text,
construction text,
service text) RETURNS boolean AS
$$
SELECT CASE
WHEN transportation_filter_z12(highway, construction) THEN TRUE
WHEN highway = 'service' OR construction = 'service' THEN service NOT IN ('driveway', 'parking_aisle')
WHEN highway_class(highway, public_transport, construction) IN ('minor', 'minor_construction') THEN TRUE
ELSE FALSE
END
$$ LANGUAGE SQL IMMUTABLE
STRICT
PARALLEL SAFE;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 KiB

After

Width:  |  Height:  |  Size: 772 KiB

View File

@@ -0,0 +1,11 @@
CREATE OR REPLACE FUNCTION transportation_name_tags(geometry geometry, tags hstore, name text, name_en text, name_de text) RETURNS hstore AS
$$
SELECT hstore(string_agg(nullif(slice_language_tags(tags ||
hstore(ARRAY [
'name', CASE WHEN length(name) > 15 THEN osml10n_street_abbrev_all(name) ELSE NULLIF(name, '') END,
'name:en', CASE WHEN length(name_en) > 15 THEN osml10n_street_abbrev_en(name_en) ELSE NULLIF(name_en, '') END,
'name:de', CASE WHEN length(name_de) > 15 THEN osml10n_street_abbrev_de(name_de) ELSE NULLIF(name_de, '') END
]))::text,
''), ','));
$$ LANGUAGE SQL IMMUTABLE
PARALLEL SAFE;

View File

@@ -31,6 +31,48 @@ generalized_tables:
sql_filter: ST_IsValid(geometry)
tolerance: ZRES13
# etldoc: osm_shipway_linestring_gen_z5 -> osm_shipway_linestring_gen_z4
shipway_linestring_gen_z4:
source: shipway_linestring_gen_z5
sql_filter: ST_Length(geometry)>2*ZRES0
tolerance: ZRES5
# etldoc: osm_shipway_linestring_gen_z6 -> osm_shipway_linestring_gen_z5
shipway_linestring_gen_z5:
source: shipway_linestring_gen_z6
sql_filter: ST_Length(geometry)>ZRES0
tolerance: ZRES6
# etldoc: osm_shipway_linestring_gen_z7 -> osm_shipway_linestring_gen_z6
shipway_linestring_gen_z6:
source: shipway_linestring_gen_z7
sql_filter: ST_Length(geometry)>ZRES1
tolerance: ZRES7
# etldoc: osm_shipway_linestring_gen_z8 -> osm_shipway_linestring_gen_z7
shipway_linestring_gen_z7:
source: shipway_linestring_gen_z8
sql_filter: ST_Length(geometry)>ZRES2
tolerance: ZRES8
# etldoc: osm_shipway_linestring_gen_z9 -> osm_shipway_linestring_gen_z8
shipway_linestring_gen_z8:
source: shipway_linestring_gen_z9
sql_filter: ST_Length(geometry)>ZRES3
tolerance: ZRES9
# etldoc: osm_shipway_linestring_gen_z10 -> osm_shipway_linestring_gen_z9
shipway_linestring_gen_z9:
source: shipway_linestring_gen_z10
sql_filter: ST_Length(geometry)>ZRES4
tolerance: ZRES10
# etldoc: osm_shipway_linestring_gen_z11 -> osm_shipway_linestring_gen_z10
shipway_linestring_gen_z10:
source: shipway_linestring_gen_z11
sql_filter: ST_Length(geometry)>ZRES5
tolerance: ZRES11
# etldoc: osm_shipway_linestring_gen_z12 -> osm_shipway_linestring_gen_z11
shipway_linestring_gen_z11:
source: shipway_linestring_gen_z12
@@ -42,22 +84,10 @@ generalized_tables:
sql_filter: ST_IsValid(geometry)
tolerance: ZRES13
# etldoc: osm_highway_linestring_gen_z10 -> osm_highway_linestring_gen_z9
highway_linestring_gen_z9:
source: highway_linestring_gen_z10
sql_filter: (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link') OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link')) AND NOT is_area
tolerance: ZRES10
# etldoc: osm_highway_linestring_gen_z11 -> osm_highway_linestring_gen_z10
highway_linestring_gen_z10:
source: highway_linestring_gen_z11
sql_filter: (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link') OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary', 'secondary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link')) AND NOT is_area
tolerance: ZRES11
# etldoc: osm_highway_linestring -> osm_highway_linestring_gen_z11
highway_linestring_gen_z11:
source: highway_linestring
sql_filter: (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link') OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link')) AND NOT is_area AND ST_IsValid(geometry)
sql_filter: (highway IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link', 'busway', 'bus_guideway') OR highway = 'construction' AND construction IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary', 'motorway_link', 'trunk_link', 'primary_link', 'secondary_link', 'tertiary_link', 'busway', 'bus_guideway')) AND NOT is_area AND ST_IsValid(geometry)
tolerance: ZRES12
name_field: &name
@@ -104,6 +134,14 @@ service_field: &service
key: service
name: service
type: string
access_field: &access
key: access
name: access
type: string
toll_field: &toll
key: toll
name: toll
type: bool
usage_field: &usage
key: usage
name: usage
@@ -155,10 +193,18 @@ mtb_scale_field: &mtb_scale
key: mtb:scale
name: mtb_scale
type: string
sac_scale_field: &sac_scale
key: sac_scale
name: sac_scale
type: string
surface_field: &surface
key: surface
name: surface
type: string
expressway_field: &expressway
key: expressway
name: expressway
type: bool
tables:
# etldoc: imposm3 -> osm_highway_linestring
@@ -176,6 +222,9 @@ tables:
- name: construction
key: construction
type: string
- name: tracktype
key: tracktype
type: string
- *ref
- *network
- *z_order
@@ -195,6 +244,8 @@ tables:
- *oneway
- *area
- *service
- *access
- *toll
- *usage
- *public_transport
- *man_made
@@ -202,7 +253,9 @@ tables:
- *foot
- *horse
- *mtb_scale
- *sac_scale
- *surface
- *expressway
mapping:
highway:
- motorway
@@ -229,11 +282,16 @@ tables:
- service
- track
- raceway
- busway
- bus_guideway
- construction
public_transport:
- platform
man_made:
- pier
service:
- driveway
- parking_aisle
# etldoc: imposm3 -> osm_railway_linestring
railway_linestring:
@@ -308,8 +366,14 @@ tables:
- *usage
mapping:
aerialway:
- cable_car
- chair_lift
- drag_lift
- platter
- t-bar
- gondola
- cable_car
- j-bar
- mixed_lift
# etldoc: imposm3 -> osm_shipway_linestring
shipway_linestring:
@@ -364,6 +428,7 @@ tables:
type: bool
- *public_transport
- *man_made
- *service
mapping:
highway:
- path
@@ -379,6 +444,33 @@ tables:
- bridge
- pier
# etldoc: imposm3 -> highway_point
highway_point:
type: point
columns:
- name: osm_id
type: id
- name: geometry
type: geometry
- name: highway
key: highway
type: string
- name: z_order
type: wayzorder
- *layer
- *level
- *name
- *name_en
- *name_de
- name: tags
type: hstore_tags
- name: ref
key: ref
type: string
mapping:
highway:
- motorway_junction
# TODO: Future table for joining networks
# etldoc: imposm3 -> osm_route_member
route_member:
@@ -395,6 +487,13 @@ tables:
- *ref
- *network
- *name
- name: osmc_symbol
key: osmc:symbol
type: string
- name: colour
key: colour
type: string
mapping:
route:
- road
- hiking

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 159 KiB

View File

@@ -10,24 +10,25 @@ DROP TRIGGER IF EXISTS trigger_refresh_name ON transportation_name.updates_name;
DO
$$
BEGIN
IF NOT EXISTS(SELECT 1 FROM pg_type WHERE typname = 'route_network_type') THEN
PERFORM 'route_network_type'::regtype;
EXCEPTION
WHEN undefined_object THEN
CREATE TYPE route_network_type AS enum (
'us-interstate', 'us-highway', 'us-state',
'ca-transcanada',
'gb-motorway', 'gb-trunk'
'ca-transcanada', 'ca-provincial-arterial', 'ca-provincial',
'gb-motorway', 'gb-trunk', 'gb-primary',
'ie-motorway', 'ie-national', 'ie-regional'
);
END IF;
END
$$;
DO
-- Top-level national route networks that should display at the lowest zooms
CREATE OR REPLACE FUNCTION osm_national_network(network text) RETURNS boolean AS
$$
BEGIN
BEGIN
ALTER TABLE osm_route_member
ADD COLUMN network_type route_network_type;
EXCEPTION
WHEN duplicate_column THEN RAISE NOTICE 'column network_type already exists in network_type.';
END;
END;
$$;
SELECT network <> '' AND network IN (
-- Canada
'ca-transcanada', 'ca-provincial-arterial',
-- United States
'us-interstate');
$$ LANGUAGE sql IMMUTABLE
PARALLEL SAFE;

File diff suppressed because it is too large Load Diff

View File

@@ -11,34 +11,38 @@ $$ LANGUAGE SQL IMMUTABLE
CREATE OR REPLACE FUNCTION layer_transportation(bbox geometry, zoom_level int)
RETURNS TABLE
(
osm_id bigint,
geometry geometry,
class text,
subclass text,
ramp int,
oneway int,
brunnel text,
service text,
layer int,
level int,
indoor int,
bicycle text,
foot text,
horse text,
mtb_scale text,
surface text
osm_id bigint,
geometry geometry,
class text,
subclass text,
network text,
ramp int,
oneway int,
brunnel text,
service text,
access text,
toll int,
expressway int,
layer int,
level int,
indoor int,
bicycle text,
foot text,
horse text,
mtb_scale text,
surface text
)
AS
$$
SELECT osm_id,
geometry,
CASE
WHEN NULLIF(highway, '') IS NOT NULL OR NULLIF(public_transport, '') IS NOT NULL
WHEN highway <> '' OR public_transport <> ''
THEN highway_class(highway, public_transport, construction)
WHEN NULLIF(railway, '') IS NOT NULL THEN railway_class(railway)
WHEN NULLIF(aerialway, '') IS NOT NULL THEN 'aerialway'
WHEN NULLIF(shipway, '') IS NOT NULL THEN shipway
WHEN NULLIF(man_made, '') IS NOT NULL THEN man_made
WHEN railway <> '' THEN railway_class(railway)
WHEN aerialway <> '' THEN 'aerialway'
WHEN shipway <> '' THEN shipway
WHEN man_made <> '' THEN man_made
END AS class,
CASE
WHEN railway IS NOT NULL THEN railway
@@ -47,14 +51,18 @@ SELECT osm_id,
THEN COALESCE(NULLIF(public_transport, ''), highway)
WHEN aerialway IS NOT NULL THEN aerialway
END AS subclass,
NULLIF(network, '') AS network,
-- All links are considered as ramps as well
CASE
WHEN highway_is_link(highway) OR highway = 'steps'
THEN 1
ELSE is_ramp::int END AS ramp,
is_oneway::int AS oneway,
WHEN highway_is_link(highway)
OR is_ramp
THEN 1 END AS ramp,
CASE WHEN is_oneway <> 0 THEN is_oneway::int END AS oneway,
brunnel(is_bridge, is_tunnel, is_ford) AS brunnel,
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,
NULLIF(layer, 0) AS layer,
"level",
CASE WHEN indoor = TRUE THEN 1 END AS indoor,
@@ -69,14 +77,18 @@ FROM (
geometry,
highway,
construction,
network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
NULL AS service,
NULL AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -98,14 +110,18 @@ FROM (
geometry,
highway,
construction,
network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
NULL AS service,
NULL AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -127,14 +143,18 @@ FROM (
geometry,
highway,
construction,
network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
NULL AS service,
NULL AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -156,14 +176,18 @@ FROM (
geometry,
highway,
construction,
network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
NULL AS service,
NULL AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -185,14 +209,18 @@ FROM (
geometry,
highway,
construction,
network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
NULL AS service,
NULL AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -209,19 +237,23 @@ FROM (
WHERE zoom_level = 8
UNION ALL
-- etldoc: osm_highway_linestring_gen_z9 -> layer_transportation:z9
-- etldoc: osm_transportation_merge_linestring_gen_z9 -> layer_transportation:z9
SELECT osm_id,
geometry,
highway,
construction,
network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
NULL AS service,
access,
toll,
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -234,24 +266,27 @@ FROM (
mtb_scale,
NULL AS surface,
z_order
FROM osm_highway_linestring_gen_z9
FROM osm_transportation_merge_linestring_gen_z9
WHERE zoom_level = 9
AND ST_Length(geometry) > ZRes(11)
UNION ALL
-- etldoc: osm_highway_linestring_gen_z10 -> layer_transportation:z10
-- etldoc: osm_transportation_merge_linestring_gen_z10 -> layer_transportation:z10
SELECT osm_id,
geometry,
highway,
construction,
network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
NULL AS service,
access,
toll,
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -264,24 +299,27 @@ FROM (
mtb_scale,
NULL AS surface,
z_order
FROM osm_highway_linestring_gen_z10
FROM osm_transportation_merge_linestring_gen_z10
WHERE zoom_level = 10
AND ST_Length(geometry) > ZRes(11)
UNION ALL
-- etldoc: osm_highway_linestring_gen_z11 -> layer_transportation:z11
-- etldoc: osm_transportation_merge_linestring_gen_z11 -> layer_transportation:z11
SELECT osm_id,
geometry,
highway,
construction,
network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
NULL AS service,
access,
toll,
is_bridge,
is_tunnel,
is_ford,
expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -294,59 +332,65 @@ FROM (
mtb_scale,
NULL AS surface,
z_order
FROM osm_highway_linestring_gen_z11
FROM osm_transportation_merge_linestring_gen_z11
WHERE zoom_level = 11
AND ST_Length(geometry) > ZRes(12)
UNION ALL
-- etldoc: osm_highway_linestring -> layer_transportation:z12
-- etldoc: osm_highway_linestring -> layer_transportation:z13
-- etldoc: osm_highway_linestring -> layer_transportation:z14_
SELECT osm_id,
geometry,
highway,
-- etldoc: osm_transportation_name_network -> layer_transportation:z12
-- etldoc: osm_transportation_name_network -> layer_transportation:z13
-- etldoc: osm_transportation_name_network -> layer_transportation:z14_
SELECT hl.osm_id,
hl.geometry,
hl.highway,
construction,
network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
public_transport,
service_value(service) AS service,
CASE WHEN access IN ('private', 'no') THEN 'no' END AS access,
toll,
is_bridge,
is_tunnel,
is_ford,
expressway,
is_ramp,
is_oneway,
man_made,
layer,
CASE WHEN highway IN ('footway', 'steps') THEN "level" END AS "level",
CASE WHEN highway IN ('footway', 'steps') THEN indoor END AS indoor,
hl.layer,
CASE WHEN hl.highway IN ('footway', 'steps') THEN hl.level END AS level,
CASE WHEN hl.highway IN ('footway', 'steps') THEN hl.indoor END AS indoor,
bicycle,
foot,
horse,
mtb_scale,
surface_value(surface) AS "surface",
z_order
FROM osm_highway_linestring
surface_value(COALESCE(NULLIF(surface, ''), tracktype)) AS "surface",
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
AND (
zoom_level = 12 AND (
highway_class(highway, public_transport, construction) NOT IN ('track', 'path', 'minor')
OR highway IN ('unclassified', 'residential')
) AND man_made <> 'pier'
OR zoom_level = 13
AND (
highway_class(highway, public_transport, construction) NOT IN ('track', 'path') AND
man_made <> 'pier'
OR
man_made = 'pier' AND NOT ST_IsClosed(geometry)
)
OR zoom_level >= 14
AND (
man_made <> 'pier'
OR
NOT ST_IsClosed(geometry)
)
)
AND
CASE WHEN zoom_level = 12 THEN
CASE WHEN transportation_filter_z12(hl.highway, hl.construction) THEN TRUE
WHEN hl.highway IN ('track', 'path') THEN n.route_rank = 1
END
WHEN zoom_level = 13 THEN
CASE WHEN man_made='pier' THEN NOT ST_IsClosed(hl.geometry)
WHEN hl.highway IN ('track', 'path') THEN (hl.name <> ''
OR n.route_rank BETWEEN 1 AND 2
OR hl.sac_scale <> ''
)
ELSE transportation_filter_z13(hl.highway, public_transport, hl.construction, service)
END
WHEN zoom_level >= 14 THEN
CASE WHEN man_made='pier' THEN NOT ST_IsClosed(hl.geometry)
ELSE TRUE
END
END
UNION ALL
-- etldoc: osm_railway_linestring_gen_z8 -> layer_transportation:z8
@@ -354,14 +398,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
NULL::boolean AS is_bridge,
NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -386,14 +434,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
NULL::boolean AS is_bridge,
NULL::boolean AS is_tunnel,
NULL::boolean AS is_ford,
NULL::boolean AS expressway,
NULL::boolean AS is_ramp,
NULL::int AS is_oneway,
NULL AS man_made,
@@ -418,14 +470,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@@ -449,14 +505,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@@ -480,14 +540,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@@ -512,14 +576,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
railway,
NULL AS aerialway,
NULL AS shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@@ -544,14 +612,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
aerialway,
NULL AS shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@@ -574,14 +646,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
aerialway,
NULL AS shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@@ -598,19 +674,254 @@ FROM (
WHERE zoom_level >= 13
UNION ALL
-- etldoc: osm_shipway_linestring_gen_z11 -> layer_transportation:z11
-- etldoc: osm_shipway_linestring_gen_z4 -> layer_transportation:z4
SELECT osm_id,
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
layer,
NULL::int AS level,
NULL::boolean AS indoor,
NULL AS bicycle,
NULL AS foot,
NULL AS horse,
NULL AS mtb_scale,
NULL AS surface,
z_order
FROM osm_shipway_linestring_gen_z4
WHERE zoom_level = 4
UNION ALL
-- etldoc: osm_shipway_linestring_gen_z5 -> layer_transportation:z5
SELECT osm_id,
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
layer,
NULL::int AS level,
NULL::boolean AS indoor,
NULL AS bicycle,
NULL AS foot,
NULL AS horse,
NULL AS mtb_scale,
NULL AS surface,
z_order
FROM osm_shipway_linestring_gen_z5
WHERE zoom_level = 5
UNION ALL
-- etldoc: osm_shipway_linestring_gen_z6 -> layer_transportation:z6
SELECT osm_id,
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
layer,
NULL::int AS level,
NULL::boolean AS indoor,
NULL AS bicycle,
NULL AS foot,
NULL AS horse,
NULL AS mtb_scale,
NULL AS surface,
z_order
FROM osm_shipway_linestring_gen_z6
WHERE zoom_level = 6
UNION ALL
-- etldoc: osm_shipway_linestring_gen_z7 -> layer_transportation:z7
SELECT osm_id,
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
layer,
NULL::int AS level,
NULL::boolean AS indoor,
NULL AS bicycle,
NULL AS foot,
NULL AS horse,
NULL AS mtb_scale,
NULL AS surface,
z_order
FROM osm_shipway_linestring_gen_z7
WHERE zoom_level = 7
UNION ALL
-- etldoc: osm_shipway_linestring_gen_z8 -> layer_transportation:z8
SELECT osm_id,
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
layer,
NULL::int AS level,
NULL::boolean AS indoor,
NULL AS bicycle,
NULL AS foot,
NULL AS horse,
NULL AS mtb_scale,
NULL AS surface,
z_order
FROM osm_shipway_linestring_gen_z8
WHERE zoom_level = 8
UNION ALL
-- etldoc: osm_shipway_linestring_gen_z9 -> layer_transportation:z9
SELECT osm_id,
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
layer,
NULL::int AS level,
NULL::boolean AS indoor,
NULL AS bicycle,
NULL AS foot,
NULL AS horse,
NULL AS mtb_scale,
NULL AS surface,
z_order
FROM osm_shipway_linestring_gen_z9
WHERE zoom_level = 9
UNION ALL
-- etldoc: osm_shipway_linestring_gen_z10 -> layer_transportation:z10
SELECT osm_id,
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
layer,
NULL::int AS level,
NULL::boolean AS indoor,
NULL AS bicycle,
NULL AS foot,
NULL AS horse,
NULL AS mtb_scale,
NULL AS surface,
z_order
FROM osm_shipway_linestring_gen_z10
WHERE zoom_level = 10
UNION ALL
-- etldoc: osm_shipway_linestring_gen_z11 -> layer_transportation:z11
SELECT osm_id,
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@@ -632,14 +943,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@@ -662,14 +977,18 @@ FROM (
geometry,
NULL AS highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
shipway,
NULL AS public_transport,
service_value(service) AS service,
NULL::text AS access,
NULL::boolean AS toll,
is_bridge,
is_tunnel,
is_ford,
NULL::boolean AS expressway,
is_ramp,
is_oneway,
NULL AS man_made,
@@ -696,17 +1015,21 @@ FROM (
geometry,
highway,
NULL AS construction,
NULL AS network,
NULL AS railway,
NULL AS aerialway,
NULL AS shipway,
public_transport,
NULL AS service,
NULL::text AS access,
NULL::boolean AS toll,
CASE
WHEN man_made IN ('bridge') THEN TRUE
ELSE FALSE
END AS is_bridge,
FALSE AS is_tunnel,
FALSE AS is_ford,
NULL::boolean AS expressway,
FALSE AS is_ramp,
FALSE::int AS is_oneway,
man_made,

View File

@@ -1,5 +1,8 @@
layer:
id: "transportation"
requires:
tables:
- ne_10m_admin_0_countries
description: |
**transportation** contains roads, railways, aerial ways, and shipping
lines.
@@ -21,8 +24,9 @@ layer:
[`railway`](http://wiki.openstreetmap.org/wiki/Key:railway),
[`aerialway`](http://wiki.openstreetmap.org/wiki/Key:aerialway),
[`route`](http://wiki.openstreetmap.org/wiki/Key:route) tag (for
shipping ways), or
[`man_made`](http://wiki.openstreetmap.org/wiki/Key:route).
shipping ways),
[`busway`](https://wiki.openstreetmap.org/wiki/Key:busway), or
[`man_made`](http://wiki.openstreetmap.org/wiki/Key:man_made).
values:
motorway:
highway: ['motorway', 'motorway_link']
@@ -45,6 +49,12 @@ layer:
highway: track
raceway:
highway: raceway
busway:
highway: busway
bus_guideway:
highway: bus_guideway
ferry:
highway: shipway
motorway_construction:
__AND__:
highway: construction
@@ -111,6 +121,14 @@ layer:
- bridleway
- corridor
- platform
- ferry (DEPRECATED - use class)
network:
description: |
The network type derived mainly from [`network`](http://wiki.openstreetmap.org/wiki/Key:network) tag of the road.
See more info about [`us-*`](http://wiki.openstreetmap.org/wiki/Road_signs_in_the_United_States),
[`ca-transcanada`](https://en.wikipedia.org/wiki/Trans-Canada_Highway),
[`gb-*`](http://wiki.openstreetmap.org/wiki/United_Kingdom_Tagging_Guidelines#UK_roads),
or [`ie-*`](http://wiki.openstreetmap.org/wiki/Ireland/Roads).
brunnel:
description: |
Mark whether way is a tunnel or bridge.
@@ -123,12 +141,12 @@ layer:
Mark with `1` whether way is a oneway in the direction of the way,
with `-1` whether way is a oneway in the opposite direction of the way
or not a oneway with `0`.
values: [0, 1, -1]
values: [1, -1]
ramp:
description: |
Mark with `1` whether way is a ramp (link or steps)
or not with `0`.
values: [0, 1]
values: [1]
service:
description: |
Original value of the [`service`](http://wiki.openstreetmap.org/wiki/Key:service) tag.
@@ -140,6 +158,21 @@ layer:
- driveway
- alley
- parking_aisle
access:
description: |
Access restrictions on this road. Supported values of the
[`access`](http://wiki.openstreetmap.org/wiki/Key:access) tag are `no` and `private`,
which resolve to `no`.
values:
- no
toll:
description: |
Whether this is a toll road, based on the [`toll`](http://wiki.openstreetmap.org/wiki/Key:toll) tag.
values: [0, 1]
expressway:
description: |
Whether this is an expressway, based on the [`expressway`](http://wiki.openstreetmap.org/wiki/Key:expressway) tag.
values: [1]
layer:
description: |
Original value of the [`layer`](http://wiki.openstreetmap.org/wiki/Key:layer) tag.
@@ -174,9 +207,12 @@ layer:
datasource:
geometry_field: geometry
srid: 900913
query: (SELECT geometry, class, subclass, oneway, ramp, brunnel, service, layer, level, indoor, bicycle, foot, horse, mtb_scale, surface FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t
query: (SELECT geometry, class, subclass, network, oneway, ramp, brunnel, service, access, toll, expressway, layer, level, indoor, bicycle, foot, horse, mtb_scale, surface FROM layer_transportation(!bbox!, z(!scale_denominator!))) AS t
schema:
- ./network_type.sql
- ./class.sql
- ./highway_name.sql
- ./update_route_member.sql
- ./update_transportation_merge.sql
- ./transportation.sql
datasources:

View File

@@ -0,0 +1,214 @@
DROP TRIGGER IF EXISTS trigger_store_transportation_highway_linestring ON osm_highway_linestring;
-- Create bounding windows for country-specific processing
-- etldoc: ne_10m_admin_0_countries -> ne_10m_admin_0_gb_buffer
CREATE TABLE IF NOT EXISTS ne_10m_admin_0_gb_buffer AS
SELECT ST_Buffer(geometry, 10000)
FROM ne_10m_admin_0_countries
WHERE iso_a2 = 'GB';
-- etldoc: ne_10m_admin_0_countries -> ne_10m_admin_0_ie_buffer
CREATE TABLE IF NOT EXISTS ne_10m_admin_0_ie_buffer AS
SELECT ST_Buffer(geometry, 10000)
FROM ne_10m_admin_0_countries
WHERE iso_a2 = 'IE';
-- Assign pseudo-networks based highway classification
-- etldoc: osm_highway_linestring -> gbr_route_members_view
-- etldoc: ne_10m_admin_0_gb_buffer -> gbr_route_members_view
CREATE OR REPLACE VIEW gbr_route_members_view AS
SELECT osm_id AS member,
substring(ref FROM E'^[ABM][0-9ABM()]+') AS ref,
-- See https://wiki.openstreetmap.org/wiki/Roads_in_the_United_Kingdom
CASE WHEN highway = 'motorway' THEN 'omt-gb-motorway'
WHEN highway = 'trunk' THEN 'omt-gb-trunk'
WHEN highway IN ('primary','secondary') THEN 'omt-gb-primary' END AS network
FROM osm_highway_linestring
WHERE length(ref) > 1
AND ST_Intersects(geometry, (SELECT * FROM ne_10m_admin_0_gb_buffer))
AND highway IN ('motorway', 'trunk', 'primary', 'secondary')
;
-- etldoc: osm_highway_linestring -> ire_route_members_view
-- etldoc: ne_10m_admin_0_ie_buffer -> ire_route_members_view
CREATE OR REPLACE VIEW ire_route_members_view AS
SELECT osm_id AS member,
substring(ref FROM E'^[MNRL][0-9]+') AS ref,
-- See https://wiki.openstreetmap.org/wiki/Ireland/Roads
CASE WHEN highway = 'motorway' THEN 'omt-ie-motorway'
WHEN highway IN ('trunk','primary') THEN 'omt-ie-national'
ELSE 'omt-ie-regional' END AS network
FROM osm_highway_linestring
WHERE length(ref) > 1
AND ST_Intersects(geometry, (SELECT * FROM ne_10m_admin_0_ie_buffer))
AND highway IN ('motorway', 'trunk', 'primary', 'secondary', 'unclassified')
;
CREATE OR REPLACE FUNCTION osm_route_member_network_type(network text, ref text) RETURNS route_network_type AS
$$
SELECT CASE
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
-- https://en.wikipedia.org/wiki/Trans-Canada_Highway
WHEN network LIKE 'CA:transcanada%' THEN 'ca-transcanada'::route_network_type
WHEN network = 'CA:QC:A' THEN 'ca-provincial-arterial'::route_network_type
WHEN network = 'CA:ON:primary' THEN
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
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
WHEN network = 'CA:BC' AND ref IN ('3','5','99') THEN 'ca-provincial-arterial'::route_network_type
WHEN network LIKE 'CA:__' OR network LIKE 'CA:__:%' THEN 'ca-provincial'::route_network_type
WHEN network = 'omt-gb-motorway' THEN 'gb-motorway'::route_network_type
WHEN network = 'omt-gb-trunk' THEN 'gb-trunk'::route_network_type
WHEN network = 'omt-gb-primary' THEN 'gb-primary'::route_network_type
WHEN network = 'omt-ie-motorway' THEN 'ie-motorway'::route_network_type
WHEN network = 'omt-ie-national' THEN 'ie-national'::route_network_type
WHEN network = 'omt-ie-regional' THEN 'ie-regional'::route_network_type
END;
$$ LANGUAGE sql IMMUTABLE
PARALLEL SAFE;
CREATE TABLE IF NOT EXISTS transportation_route_member_coalesced
(
member bigint,
network varchar,
ref varchar,
osm_id bigint not null,
role varchar,
type smallint,
name varchar,
osmc_symbol varchar,
colour varchar,
network_type route_network_type,
concurrency_index integer,
rank integer,
PRIMARY KEY (member, network, ref)
);
CREATE OR REPLACE FUNCTION update_osm_route_member(full_update bool) RETURNS void AS
$$
BEGIN
-- Analyze tracking and source tables before performing update
ANALYZE transportation_name.network_changes;
ANALYZE osm_highway_linestring;
ANALYZE osm_route_member;
DELETE
FROM transportation_route_member_coalesced
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
osm_route_member_filtered.*,
osm_route_member_network_type(network, ref) AS network_type,
DENSE_RANK() OVER (
PARTITION BY member
ORDER BY osm_route_member_network_type(network, ref), network, LENGTH(ref), ref
) AS concurrency_index,
CASE
WHEN network IN ('iwn', 'nwn', 'rwn') THEN 1
WHEN network = 'lwn' THEN 2
WHEN osmc_symbol || colour <> '' THEN 2
END AS rank
FROM (
-- etldoc: osm_route_member -> osm_route_member
-- see http://wiki.openstreetmap.org/wiki/Relation:route#Road_routes
SELECT DISTINCT ON (member, network, ref)
member,
network,
ref,
osm_id,
role,
type,
name,
osmc_symbol,
colour
FROM osm_route_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
)
) 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,
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);
-- Analyze created index
ANALYZE osm_route_member;
-- Ensure transportation_name.network_changes table exists since it is required by update_osm_route_member
CREATE SCHEMA IF NOT EXISTS transportation_name;
CREATE TABLE IF NOT EXISTS transportation_name.network_changes
(
is_old bool,
osm_id bigint,
PRIMARY KEY (is_old, osm_id)
);
-- Fill transportation_route_member_coalesced table
TRUNCATE transportation_route_member_coalesced;
SELECT update_osm_route_member(TRUE);
-- Index for queries against transportation_route_member_coalesced during transportation-name-network updates
CREATE INDEX IF NOT EXISTS transportation_route_member_member_idx ON
transportation_route_member_coalesced ("member", "concurrency_index");
-- Analyze populated table with indexes
ANALYZE transportation_route_member_coalesced;
-- Ensure OSM-ID index exists on osm_highway_linestring
CREATE UNIQUE INDEX IF NOT EXISTS osm_highway_linestring_osm_id_idx ON osm_highway_linestring ("osm_id");
-- etldoc: osm_route_member -> osm_highway_linestring
UPDATE osm_highway_linestring hl
SET network = rm.network_type
FROM transportation_route_member_coalesced rm
WHERE hl.osm_id=rm.member AND rm.concurrency_index=1;
-- etldoc: osm_route_member -> osm_highway_linestring_gen_z11
UPDATE osm_highway_linestring_gen_z11 hl
SET network = rm.network_type
FROM transportation_route_member_coalesced rm
WHERE hl.osm_id=rm.member AND rm.concurrency_index=1;

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 329 KiB

View File

@@ -0,0 +1,57 @@
CREATE OR REPLACE FUNCTION highway_to_val(hwy_class varchar)
RETURNS int
IMMUTABLE
LANGUAGE plpgsql
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;
$$;
CREATE OR REPLACE FUNCTION val_to_highway(hwy_val int)
RETURNS varchar
IMMUTABLE
LANGUAGE plpgsql
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;
$$;
CREATE OR REPLACE FUNCTION highest_hwy_sfunc(agg_state varchar, hwy_class varchar)
RETURNS varchar
IMMUTABLE
LANGUAGE plpgsql
AS $$
BEGIN
RETURN val_to_highway(
GREATEST(
highway_to_val(agg_state),
highway_to_val(hwy_class)
)
);
END;
$$;
DROP AGGREGATE IF EXISTS highest_highway (varchar);
CREATE AGGREGATE highest_highway (varchar)
(
sfunc = highest_hwy_sfunc,
stype = varchar
);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 159 KiB

View File

@@ -0,0 +1,406 @@
{
"layers": [
{
"id": "ferry_label",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "transportation_name",
"minzoom": 14,
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": 10,
"text-field": "{name}",
"text-anchor": "center",
"text-offset": [
0,
0
],
"symbol-placement": "line"
},
"paint": {
"text-color": "#6666ff",
"text-halo-blur": 1,
"text-halo-color": "rgba(255, 255, 255, 0.34)",
"text-halo-width": 1
},
"metadata": {},
"filter": [
"all",
[
"==",
"subclass",
"ferry"
]
],
"order": 184
},
{
"id": "road_label",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "transportation_name",
"minzoom": 14,
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"base": 1,
"stops": [
[
14,
9
],
[
18,
13
]
]
},
"text-field": "{name}",
"text-anchor": "center",
"text-offset": [
0,
0
],
"symbol-placement": "line"
},
"paint": {
"text-color": "#000000",
"text-halo-color": "rgba(255, 255, 255, 0.97)",
"text-halo-width": 1
},
"metadata": {},
"filter": [
"all",
[
"!=",
"subclass",
"ferry"
]
],
"order": 185
},
{
"id": "highway-shield-tertiary",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "transportation_name",
"minzoom": 9,
"layout": {
"icon-size": 1,
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"stops": [
[
9,
10
],
[
15,
11
],
[
17,
12
]
]
},
"icon-image": "road_tertiary",
"text-field": "{ref}",
"visibility": "visible",
"icon-anchor": "center",
"icon-padding": 2,
"icon-text-fit": "both",
"symbol-spacing": 560,
"symbol-placement": {
"base": 1,
"stops": [
[
10,
"point"
],
[
11,
"line"
]
]
},
"symbol-avoid-edges": true,
"icon-text-fit-padding": [
3,
4,
3,
4
],
"icon-rotation-alignment": "viewport",
"text-rotation-alignment": "viewport"
},
"paint": {
"text-color": "#3b3b3b"
},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"==",
"class",
"tertiary"
],
[
"has",
"ref"
]
],
"order": 186
},
{
"id": "highway-shield-secondary",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "transportation_name",
"minzoom": 9,
"layout": {
"icon-size": 1,
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"stops": [
[
9,
10
],
[
15,
11
],
[
17,
12
]
]
},
"icon-image": "road_secondary",
"text-field": "{ref}",
"visibility": "visible",
"icon-anchor": "center",
"icon-padding": 2,
"icon-text-fit": "both",
"symbol-spacing": 560,
"symbol-placement": {
"base": 1,
"stops": [
[
10,
"point"
],
[
11,
"line"
]
]
},
"symbol-avoid-edges": true,
"icon-text-fit-padding": [
3,
4,
3,
4
],
"icon-rotation-alignment": "viewport",
"text-rotation-alignment": "viewport"
},
"paint": {
"text-color": "#323b00"
},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"==",
"class",
"secondary"
],
[
"has",
"ref"
]
],
"order": 187
},
{
"id": "highway-shield-primary",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "transportation_name",
"minzoom": 9,
"layout": {
"icon-size": 1,
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"stops": [
[
9,
10
],
[
15,
11
],
[
17,
12
]
]
},
"icon-image": "road_primary",
"text-field": "{ref}",
"visibility": "visible",
"icon-anchor": "center",
"icon-padding": 2,
"icon-text-fit": "both",
"symbol-spacing": 560,
"symbol-placement": {
"base": 1,
"stops": [
[
10,
"point"
],
[
11,
"line"
]
]
},
"symbol-avoid-edges": true,
"icon-text-fit-padding": [
3,
4,
3,
4
],
"icon-rotation-alignment": "viewport",
"text-rotation-alignment": "viewport"
},
"paint": {
"text-color": "#4c2e00"
},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"==",
"class",
"primary"
],
[
"has",
"ref"
]
],
"order": 188
},
{
"id": "highway-shield-motorway",
"type": "symbol",
"source": "openmaptiles",
"source-layer": "transportation_name",
"minzoom": 9,
"layout": {
"icon-size": 1,
"text-font": [
"Noto Sans Regular"
],
"text-size": {
"stops": [
[
9,
10
],
[
15,
11
],
[
17,
12
]
]
},
"icon-image": "road_motorway",
"text-field": "{ref}",
"visibility": "visible",
"icon-anchor": "center",
"icon-padding": 2,
"icon-text-fit": "both",
"text-optional": false,
"symbol-spacing": 760,
"text-max-width": 10,
"symbol-placement": {
"base": 1,
"stops": [
[
10,
"point"
],
[
11,
"line"
]
]
},
"text-keep-upright": true,
"symbol-avoid-edges": true,
"icon-text-fit-padding": [
3,
4,
3,
4
],
"icon-rotation-alignment": "viewport",
"text-rotation-alignment": "viewport"
},
"paint": {
"text-color": "#620728"
},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"==",
"class",
"motorway"
],
[
"has",
"ref"
]
],
"order": 189
}
]
}

View File

@@ -4,7 +4,6 @@
CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level integer)
RETURNS TABLE
(
osm_id bigint,
geometry geometry,
name text,
name_en text,
@@ -13,6 +12,12 @@ CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level i
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,
@@ -22,25 +27,25 @@ CREATE OR REPLACE FUNCTION layer_transportation_name(bbox geometry, zoom_level i
)
AS
$$
SELECT osm_id,
geometry,
name,
COALESCE(name_en, name) AS name_en,
COALESCE(name_de, name, name_en) AS name_de,
SELECT geometry,
tags->'name' AS name,
COALESCE(tags->'name:en', tags->'name') AS name_en,
COALESCE(tags->'name:de', tags->'name', tags->'name:en') AS name_de,
tags,
ref,
NULLIF(LENGTH(ref), 0) AS ref_length,
--TODO: The road network of the road is not yet implemented
CASE
WHEN network IS NOT NULL
THEN network::text
WHEN length(coalesce(ref, '')) > 0
THEN 'road'
END AS network,
highway_class(highway, '', construction) AS class,
route_1, route_2, route_3, route_4, route_5, route_6,
highway_class(highway, '', subclass) AS class,
CASE
WHEN highway IS NOT NULL AND highway_class(highway, '', construction) = 'path'
WHEN highway IS NOT NULL AND highway_class(highway, '', subclass) = 'path'
THEN highway
ELSE subclass
END AS subclass,
brunnel,
NULLIF(layer, 0) AS layer,
@@ -49,7 +54,20 @@ SELECT osm_id,
FROM (
-- etldoc: osm_transportation_name_linestring_gen4 -> layer_transportation_name:z6
SELECT *,
SELECT geometry,
tags,
ref,
highway,
subclass,
brunnel,
network,
route_1,
route_2,
route_3,
route_4,
route_5,
route_6,
z_order,
NULL::int AS layer,
NULL::int AS level,
NULL::boolean AS indoor
@@ -58,7 +76,20 @@ FROM (
UNION ALL
-- etldoc: osm_transportation_name_linestring_gen3 -> layer_transportation_name:z7
SELECT *,
SELECT geometry,
tags,
ref,
highway,
subclass,
brunnel,
network,
route_1,
route_2,
route_3,
route_4,
route_5,
route_6,
z_order,
NULL::int AS layer,
NULL::int AS level,
NULL::boolean AS indoor
@@ -67,7 +98,20 @@ FROM (
UNION ALL
-- etldoc: osm_transportation_name_linestring_gen2 -> layer_transportation_name:z8
SELECT *,
SELECT geometry,
tags,
ref,
highway,
subclass,
brunnel,
network,
route_1,
route_2,
route_3,
route_4,
route_5,
route_6,
z_order,
NULL::int AS layer,
NULL::int AS level,
NULL::boolean AS indoor
@@ -78,7 +122,20 @@ FROM (
-- etldoc: osm_transportation_name_linestring_gen1 -> layer_transportation_name:z9
-- etldoc: osm_transportation_name_linestring_gen1 -> layer_transportation_name:z10
-- etldoc: osm_transportation_name_linestring_gen1 -> layer_transportation_name:z11
SELECT *,
SELECT geometry,
tags,
ref,
highway,
subclass,
brunnel,
network,
route_1,
route_2,
route_3,
route_4,
route_5,
route_6,
z_order,
NULL::int AS layer,
NULL::int AS level,
NULL::boolean AS indoor
@@ -88,67 +145,98 @@ FROM (
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z12
SELECT geometry,
osm_id,
name,
name_en,
name_de,
"tags",
ref,
highway,
construction,
subclass,
brunnel,
network,
route_1, route_2, route_3, route_4, route_5, route_6,
z_order,
layer,
"level",
indoor
FROM osm_transportation_name_linestring
WHERE zoom_level = 12
AND LineLabel(zoom_level, COALESCE(name, ref), geometry)
AND highway_class(highway, '', construction) NOT IN ('minor', 'track', 'path')
AND LineLabel(zoom_level, COALESCE(tags->'name', ref), geometry)
AND NOT highway_is_link(highway)
AND
CASE WHEN highway_class(highway, NULL::text, NULL::text) NOT IN ('path', 'minor') THEN TRUE
WHEN highway IN ('aerialway', 'unclassified', 'residential', 'shipway') THEN TRUE
WHEN route_rank = 1 THEN TRUE END
UNION ALL
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z13
SELECT geometry,
osm_id,
name,
name_en,
name_de,
"tags",
ref,
highway,
construction,
subclass,
brunnel,
network,
route_1, route_2, route_3, route_4, route_5, route_6,
z_order,
layer,
"level",
indoor
FROM osm_transportation_name_linestring
WHERE zoom_level = 13
AND LineLabel(zoom_level, COALESCE(name, ref), geometry)
AND highway_class(highway, '', construction) NOT IN ('track', 'path')
AND LineLabel(zoom_level, COALESCE(tags->'name', ref), geometry)
AND
CASE WHEN highway <> 'path' THEN TRUE
WHEN highway = 'path' AND (
tags->'name' <> ''
OR network IS NOT NULL
OR sac_scale <> ''
OR route_rank <= 2
) THEN TRUE
END
UNION ALL
-- etldoc: osm_transportation_name_linestring -> layer_transportation_name:z14_
SELECT geometry,
osm_id,
name,
name_en,
name_de,
"tags",
ref,
highway,
construction,
subclass,
brunnel,
network,
route_1, route_2, route_3, route_4, route_5, route_6,
z_order,
layer,
"level",
indoor
FROM osm_transportation_name_linestring
WHERE zoom_level >= 14
UNION ALL
-- etldoc: osm_highway_point -> layer_transportation_name:z10
SELECT
p.geometry,
p.tags,
p.ref,
(
SELECT highest_highway(l.tags->'highway')
FROM osm_highway_linestring l
WHERE ST_Intersects(p.geometry,l.geometry)
) AS class,
'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,
z_order,
layer,
NULL::int AS level,
NULL::boolean AS indoor
FROM osm_highway_point p
WHERE highway = 'motorway_junction' AND zoom_level >= 10
) AS zoom_levels
WHERE geometry && bbox
ORDER BY z_order ASC;

View File

@@ -1,7 +1,9 @@
layer:
id: "transportation_name"
# transportation_name relies on the function highway_class() defined in transportation layer
requires: "transportation"
requires:
layers:
- transportation
description: |
This is the layer for labelling the highways. Only highways that are named `name=*` and are long enough
to place text upon appear. The OSM roads are stitched together if they contain the same name
@@ -26,8 +28,14 @@ layer:
- us-highway
- us-state
- ca-transcanada
- ca-provincial-arterial
- ca-provincial
- gb-motorway
- gb-trunk
- gb-primary
- ie-motorway
- ie-national
- ie-regional
- road (default)
class:
description: |
@@ -55,11 +63,13 @@ layer:
- raceway_construction
- rail
- transit
- motorway_junction
subclass:
description: |
Distinguish more specific classes of path:
Subclass is value of the
[`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) (for paths).
[`highway`](http://wiki.openstreetmap.org/wiki/Key:highway) (for paths),
and "junction" for [`motorway junctions`](http://wiki.openstreetmap.org/wiki/Tag:highway=motorway_junction).
values:
- pedestrian
- path
@@ -69,6 +79,7 @@ layer:
- bridleway
- corridor
- platform
- junction
brunnel:
description: |
Mark whether way is a bridge, a tunnel or a ford.
@@ -90,13 +101,18 @@ 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.
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 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, route_2, route_3, route_4, route_5, route_6 FROM layer_transportation_name(!bbox!, z(!scale_denominator!))) AS t
schema:
- ./network_type.sql
- ./update_route_member.sql
- ./highway_classification.sql
- ./update_transportation_name.sql
- ./transportation_name.sql
datasources:

View File

@@ -1,93 +0,0 @@
CREATE TABLE IF NOT EXISTS ne_10m_admin_0_bg_buffer AS
SELECT ST_Buffer(geometry, 10000)
FROM ne_10m_admin_0_countries
WHERE iso_a2 = 'GB';
CREATE OR REPLACE VIEW gbr_route_members_view AS
SELECT 0,
osm_id,
substring(ref FROM E'^[AM][0-9AM()]+'),
CASE WHEN highway = 'motorway' THEN 'omt-gb-motorway' ELSE 'omt-gb-trunk' END
FROM osm_highway_linestring
WHERE length(ref) > 0
AND ST_Intersects(geometry, (SELECT * FROM ne_10m_admin_0_bg_buffer))
AND highway IN ('motorway', 'trunk')
;
-- Create GBR relations (so we can use it in the same way as other relations)
DELETE
FROM osm_route_member
WHERE network IN ('omt-gb-motorway', 'omt-gb-trunk');
-- etldoc: osm_highway_linestring -> osm_route_member
INSERT INTO osm_route_member (osm_id, member, ref, network)
SELECT *
FROM gbr_route_members_view;
CREATE OR REPLACE FUNCTION osm_route_member_network_type(network text, name text, ref text) RETURNS route_network_type AS
$$
SELECT CASE
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
-- https://en.wikipedia.org/wiki/Trans-Canada_Highway
-- TODO: improve hierarchical queries using
-- http://www.openstreetmap.org/relation/1307243
-- however the relation does not cover the whole Trans-Canada_Highway
WHEN
(network = 'CA:transcanada') OR
(network = 'CA:BC:primary' AND ref IN ('16')) OR
(name = 'Yellowhead Highway (AB)' AND ref IN ('16')) OR
(network = 'CA:SK:primary' AND ref IN ('16')) OR
(network = 'CA:ON:primary' AND ref IN ('17', '417')) OR
(name = 'Route Transcanadienne') OR
(network = 'CA:NB:primary' AND ref IN ('2', '16')) OR
(network = 'CA:PE' AND ref IN ('1')) OR
(network = 'CA:NS' AND ref IN ('104', '105')) OR
(network = 'CA:NL:R' AND ref IN ('1')) OR
(name = 'Trans-Canada Highway')
THEN 'ca-transcanada'::route_network_type
WHEN network = 'omt-gb-motorway' THEN 'gb-motorway'::route_network_type
WHEN network = 'omt-gb-trunk' THEN 'gb-trunk'::route_network_type
END;
$$ LANGUAGE sql IMMUTABLE
PARALLEL SAFE;
-- etldoc: osm_route_member -> osm_route_member
-- see http://wiki.openstreetmap.org/wiki/Relation:route#Road_routes
UPDATE osm_route_member
SET network_type = osm_route_member_network_type(network, name, ref)
WHERE network != ''
AND network_type IS DISTINCT FROM osm_route_member_network_type(network, name, ref)
;
CREATE OR REPLACE FUNCTION update_osm_route_member() RETURNS void AS
$$
BEGIN
DELETE
FROM osm_route_member AS r
USING
transportation_name.network_changes AS c
WHERE network IN ('omt-gb-motorway', 'omt-gb-trunk')
AND r.osm_id = c.osm_id;
INSERT INTO osm_route_member (osm_id, member, ref, network)
SELECT r.*
FROM gbr_route_members_view AS r
JOIN transportation_name.network_changes AS c ON
r.osm_id = c.osm_id;
UPDATE
osm_route_member AS r
SET network_type = osm_route_member_network_type(network, name, ref)
FROM transportation_name.network_changes AS c
WHERE network != ''
AND network_type IS DISTINCT FROM osm_route_member_network_type(network, name, ref)
AND r.member = c.osm_id;
END;
$$ LANGUAGE plpgsql;
CREATE INDEX IF NOT EXISTS osm_route_member_network_idx ON osm_route_member ("network");
CREATE INDEX IF NOT EXISTS osm_route_member_member_idx ON osm_route_member ("member");
CREATE INDEX IF NOT EXISTS osm_route_member_name_idx ON osm_route_member ("name");
CREATE INDEX IF NOT EXISTS osm_route_member_ref_idx ON osm_route_member ("ref");
CREATE INDEX IF NOT EXISTS osm_route_member_network_type_idx ON osm_route_member ("network_type");

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More