From 8874140207b061c5ca81f30be2c7c14d22987ebe Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 16 Jan 2017 20:11:35 +0100 Subject: [PATCH 1/6] Use boundaries from osmborder --- docker-compose.yml | 7 ++++ layers/boundary/boundary.sql | 60 +++++++++++++++++------------------ layers/boundary/boundary.yaml | 8 +++-- 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 84c5e984..8e75af35 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -36,6 +36,13 @@ services: - ./data:/import - ./build:/mapping - cache:/cache + import-osmborder: + image: "openmaptiles/import-osmborder:0.1" + env_file: .env + links: + - postgres + volumes: + - ./data:/import import-osm-diff: image: "openmaptiles/import-osm:latest" env_file: .env diff --git a/layers/boundary/boundary.sql b/layers/boundary/boundary.sql index 31e951c1..d37524c2 100644 --- a/layers/boundary/boundary.sql +++ b/layers/boundary/boundary.sql @@ -3,7 +3,7 @@ -- etldoc: ne_110m_admin_0_boundary_lines_land -> boundary_z0 CREATE OR REPLACE VIEW boundary_z0 AS ( - SELECT geometry, 2 AS admin_level + SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_110m_admin_0_boundary_lines_land ); @@ -11,10 +11,10 @@ CREATE OR REPLACE VIEW boundary_z0 AS ( -- etldoc: ne_50m_admin_1_states_provinces_lines -> boundary_z1 CREATE OR REPLACE VIEW boundary_z1 AS ( - SELECT geometry, 2 AS admin_level + SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_50m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level + SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_50m_admin_1_states_provinces_lines WHERE scalerank <= 2 ); @@ -24,10 +24,10 @@ CREATE OR REPLACE VIEW boundary_z1 AS ( -- etldoc: ne_50m_admin_1_states_provinces_lines -> boundary_z3 CREATE OR REPLACE VIEW boundary_z3 AS ( - SELECT geometry, 2 AS admin_level + SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_50m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level + SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_50m_admin_1_states_provinces_lines ); @@ -36,10 +36,10 @@ CREATE OR REPLACE VIEW boundary_z3 AS ( -- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z4 CREATE OR REPLACE VIEW boundary_z4 AS ( - SELECT geometry, 2 AS admin_level + SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_10m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level + SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_10m_admin_1_states_provinces_lines_shp WHERE scalerank <= 3 AND featurecla = 'Adm-1 boundary' ); @@ -48,10 +48,10 @@ CREATE OR REPLACE VIEW boundary_z4 AS ( -- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z5 CREATE OR REPLACE VIEW boundary_z5 AS ( - SELECT geometry, 2 AS admin_level + SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_10m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level + SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_10m_admin_1_states_provinces_lines_shp WHERE scalerank <= 7 AND featurecla = 'Adm-1 boundary' ); @@ -60,10 +60,10 @@ CREATE OR REPLACE VIEW boundary_z5 AS ( -- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z6 CREATE OR REPLACE VIEW boundary_z6 AS ( - SELECT geometry, 2 AS admin_level + SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_10m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level + SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_10m_admin_1_states_provinces_lines_shp WHERE scalerank <= 9 AND featurecla = 'Adm-1 boundary' ); @@ -71,55 +71,55 @@ CREATE OR REPLACE VIEW boundary_z6 AS ( -- etldoc: ne_10m_admin_0_boundary_lines_land -> boundary_z7 -- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z7 CREATE OR REPLACE VIEW boundary_z7 AS ( - SELECT geometry, 2 AS admin_level + SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime FROM ne_10m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level + SELECT geometry, 4 AS admin_level, NULL AS disputed, NULL AS maritime FROM ne_10m_admin_1_states_provinces_lines_shp WHERE featurecla = 'Adm-1 boundary' ); --- etldoc: osm_boundary_linestring_gen5 -> boundary_z8 +-- etldoc: osm_border_linestring_gen5 -> boundary_z8 CREATE OR REPLACE VIEW boundary_z8 AS ( - SELECT geometry, admin_level - FROM osm_boundary_linestring_gen5 + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen5 WHERE admin_level <= 4 AND ST_Length(geometry) > 1000 ); --- etldoc: osm_boundary_linestring_gen4 -> boundary_z9 +-- etldoc: osm_border_linestring_gen4 -> boundary_z9 CREATE OR REPLACE VIEW boundary_z9 AS ( - SELECT geometry, admin_level - FROM osm_boundary_linestring_gen4 + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen4 WHERE admin_level <= 6 ); --- etldoc: osm_boundary_linestring_gen3 -> boundary_z10 +-- etldoc: osm_border_linestring_gen3 -> boundary_z10 CREATE OR REPLACE VIEW boundary_z10 AS ( - SELECT geometry, admin_level - FROM osm_boundary_linestring_gen3 + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen3 WHERE admin_level <= 6 ); --- etldoc: osm_boundary_linestring_gen2 -> boundary_z11 +-- etldoc: osm_border_linestring_gen2 -> boundary_z11 CREATE OR REPLACE VIEW boundary_z11 AS ( - SELECT geometry, admin_level - FROM osm_boundary_linestring_gen2 + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen2 WHERE admin_level <= 8 ); --- etldoc: osm_boundary_linestring_gen1 -> boundary_z12 +-- etldoc: osm_border_linestring_gen1 -> boundary_z12 CREATE OR REPLACE VIEW boundary_z12 AS ( - SELECT geometry, admin_level - FROM osm_boundary_linestring_gen1 + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen1 ); -- etldoc: layer_boundary[shape=record fillcolor=lightpink, style="rounded,filled", -- etldoc: label=" layer_boundary | z0 | z1_2 | z3 | z4 | z5 | z6 | z7 | z8 | z9 | z10 | z11 | z12| z13+"] CREATE OR REPLACE FUNCTION layer_boundary (bbox geometry, zoom_level int) -RETURNS TABLE(geometry geometry, admin_level int) AS $$ - SELECT geometry, admin_level FROM ( +RETURNS TABLE(geometry geometry, admin_level int, disputed int, maritime int) AS $$ + SELECT geometry, admin_level, disputed::int, maritime::int FROM ( -- etldoc: boundary_z0 -> layer_boundary:z0 SELECT * FROM boundary_z0 WHERE geometry && bbox AND zoom_level = 0 UNION ALL diff --git a/layers/boundary/boundary.yaml b/layers/boundary/boundary.yaml index 29dec595..f4acdc28 100644 --- a/layers/boundary/boundary.yaml +++ b/layers/boundary/boundary.yaml @@ -15,12 +15,16 @@ layer: At low zoom levels the Natural Earth boundaries are mapped to the equivalent admin levels. disputed: description: | - Mark with `1` if the boundary is disputed. + Mark with `1` if the border is disputed. + values: [0, 1] + maritime: + description: | + Mark with `1` if it is a maritime border. values: [0, 1] buffer_size: 4 datasource: geometry_field: geometry - query: (SELECT geometry, admin_level FROM layer_boundary(!bbox!, z(!scale_denominator!))) AS t + query: (SELECT geometry, admin_level, disputed, maritime FROM layer_boundary(!bbox!, z(!scale_denominator!))) AS t schema: - ./boundary.sql datasources: From d9f791e11ed47fde72782f2f5a4da9876d1433c7 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 16 Jan 2017 20:50:56 +0100 Subject: [PATCH 2/6] Mix maritime boundaries with NE and switch to OSM earlier --- layers/boundary/boundary.sql | 92 +++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/layers/boundary/boundary.sql b/layers/boundary/boundary.sql index d37524c2..d0b7b2fa 100644 --- a/layers/boundary/boundary.sql +++ b/layers/boundary/boundary.sql @@ -3,7 +3,7 @@ -- etldoc: ne_110m_admin_0_boundary_lines_land -> boundary_z0 CREATE OR REPLACE VIEW boundary_z0 AS ( - SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime + SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime FROM ne_110m_admin_0_boundary_lines_land ); @@ -11,10 +11,10 @@ CREATE OR REPLACE VIEW boundary_z0 AS ( -- etldoc: ne_50m_admin_1_states_provinces_lines -> boundary_z1 CREATE OR REPLACE VIEW boundary_z1 AS ( - SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime + SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime FROM ne_50m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime + SELECT geometry, 4 AS admin_level, false AS disputed, false AS maritime FROM ne_50m_admin_1_states_provinces_lines WHERE scalerank <= 2 ); @@ -24,92 +24,98 @@ CREATE OR REPLACE VIEW boundary_z1 AS ( -- etldoc: ne_50m_admin_1_states_provinces_lines -> boundary_z3 CREATE OR REPLACE VIEW boundary_z3 AS ( - SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime + SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime FROM ne_50m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime + SELECT geometry, 4 AS admin_level, false AS disputed, false AS maritime FROM ne_50m_admin_1_states_provinces_lines ); -- etldoc: ne_10m_admin_0_boundary_lines_land -> boundary_z4 -- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z4 +-- etldoc: osm_border_linestring_gen10 -> boundary_z4 CREATE OR REPLACE VIEW boundary_z4 AS ( - SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime + SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime FROM ne_10m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime + SELECT geometry, 4 AS admin_level, false AS disputed, false AS maritime FROM ne_10m_admin_1_states_provinces_lines_shp WHERE scalerank <= 3 AND featurecla = 'Adm-1 boundary' + UNION ALL + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen10 + WHERE maritime=true AND admin_level <= 2 ); -- etldoc: ne_10m_admin_0_boundary_lines_land -> boundary_z5 -- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z5 +-- etldoc: osm_border_linestring_gen9 -> boundary_z5 CREATE OR REPLACE VIEW boundary_z5 AS ( - SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime + SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime FROM ne_10m_admin_0_boundary_lines_land UNION ALL - SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime + SELECT geometry, 4 AS admin_level, false AS disputed, false AS maritime FROM ne_10m_admin_1_states_provinces_lines_shp WHERE scalerank <= 7 AND featurecla = 'Adm-1 boundary' + UNION ALL + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen9 + WHERE maritime=true AND admin_level <= 2 ); --- etldoc: ne_10m_admin_0_boundary_lines_land -> boundary_z6 --- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z6 - +-- etldoc: osm_border_linestring_gen8 -> boundary_z6 CREATE OR REPLACE VIEW boundary_z6 AS ( - SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime - FROM ne_10m_admin_0_boundary_lines_land - UNION ALL - SELECT geometry, 4 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime - FROM ne_10m_admin_1_states_provinces_lines_shp - WHERE scalerank <= 9 AND featurecla = 'Adm-1 boundary' + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen8 + WHERE admin_level <= 4 ); --- etldoc: ne_10m_admin_0_boundary_lines_land -> boundary_z7 --- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z7 +-- etldoc: osm_border_linestring_gen7 -> boundary_z7 CREATE OR REPLACE VIEW boundary_z7 AS ( - SELECT geometry, 2 AS admin_level, NULL::bool AS disputed, NULL::bool AS maritime - FROM ne_10m_admin_0_boundary_lines_land - UNION ALL - SELECT geometry, 4 AS admin_level, NULL AS disputed, NULL AS maritime - FROM ne_10m_admin_1_states_provinces_lines_shp - WHERE featurecla = 'Adm-1 boundary' - + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen7 + WHERE admin_level <= 4 ); --- etldoc: osm_border_linestring_gen5 -> boundary_z8 +-- etldoc: osm_border_linestring_gen6 -> boundary_z8 CREATE OR REPLACE VIEW boundary_z8 AS ( SELECT geometry, admin_level, disputed, maritime - FROM osm_border_linestring_gen5 - WHERE admin_level <= 4 AND ST_Length(geometry) > 1000 + FROM osm_border_linestring_gen6 + WHERE admin_level <= 4 ); --- etldoc: osm_border_linestring_gen4 -> boundary_z9 +-- etldoc: osm_border_linestring_gen5 -> boundary_z9 CREATE OR REPLACE VIEW boundary_z9 AS ( + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen5 + WHERE admin_level <= 6 +); + +-- etldoc: osm_border_linestring_gen4 -> boundary_z10 +CREATE OR REPLACE VIEW boundary_z10 AS ( SELECT geometry, admin_level, disputed, maritime FROM osm_border_linestring_gen4 WHERE admin_level <= 6 ); --- etldoc: osm_border_linestring_gen3 -> boundary_z10 -CREATE OR REPLACE VIEW boundary_z10 AS ( - SELECT geometry, admin_level, disputed, maritime - FROM osm_border_linestring_gen3 - WHERE admin_level <= 6 -); - --- etldoc: osm_border_linestring_gen2 -> boundary_z11 +-- etldoc: osm_border_linestring_gen3 -> boundary_z11 CREATE OR REPLACE VIEW boundary_z11 AS ( SELECT geometry, admin_level, disputed, maritime - FROM osm_border_linestring_gen2 + FROM osm_border_linestring_gen3 WHERE admin_level <= 8 ); --- etldoc: osm_border_linestring_gen1 -> boundary_z12 +-- etldoc: osm_border_linestring_gen2 -> boundary_z12 CREATE OR REPLACE VIEW boundary_z12 AS ( + SELECT geometry, admin_level, disputed, maritime + FROM osm_border_linestring_gen2 +); + +-- etldoc: osm_border_linestring_gen1 -> boundary_z12 +CREATE OR REPLACE VIEW boundary_z13 AS ( SELECT geometry, admin_level, disputed, maritime FROM osm_border_linestring_gen1 ); @@ -156,7 +162,7 @@ RETURNS TABLE(geometry geometry, admin_level int, disputed int, maritime int) AS -- etldoc: boundary_z12 -> layer_boundary:z12 SELECT * FROM boundary_z12 WHERE geometry && bbox AND zoom_level = 12 UNION ALL - -- etldoc: boundary_z12 -> layer_boundary:z13 - SELECT * FROM boundary_z12 WHERE geometry && bbox AND zoom_level >= 13 + -- etldoc: boundary_z13 -> layer_boundary:z13 + SELECT * FROM boundary_z13 WHERE geometry && bbox AND zoom_level >= 13 ) AS zoom_levels; $$ LANGUAGE SQL IMMUTABLE; From 8a99e49df70253c3d135bd34dfe71ca1fdc22fe9 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 16 Jan 2017 20:54:14 +0100 Subject: [PATCH 3/6] Fix version of import-osmborder --- docker-compose.yml | 2 +- openmaptiles.yaml | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8e75af35..0476c1b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,7 +37,7 @@ services: - ./build:/mapping - cache:/cache import-osmborder: - image: "openmaptiles/import-osmborder:0.1" + image: "openmaptiles/import-osmborder:0.2" env_file: .env links: - postgres diff --git a/openmaptiles.yaml b/openmaptiles.yaml index ded85741..64236195 100644 --- a/openmaptiles.yaml +++ b/openmaptiles.yaml @@ -1,19 +1,6 @@ tileset: layers: - - layers/water/water.yaml - - layers/waterway/waterway.yaml - - layers/landcover/landcover.yaml - - layers/landuse/landuse.yaml - - layers/park/park.yaml - layers/boundary/boundary.yaml - - layers/aeroway/aeroway.yaml - - layers/transportation/transportation.yaml - - layers/building/building.yaml - - layers/water_name/water_name.yaml - - layers/transportation_name/transportation_name.yaml - - layers/place/place.yaml - - layers/housenumber/housenumber.yaml - - layers/poi/poi.yaml name: OpenMapTiles version: 3.3.0 id: openmaptiles From dcfc14ab4cbb4cdc10e7da55ff1609342bb21566 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Mon, 16 Jan 2017 20:58:24 +0100 Subject: [PATCH 4/6] Readd missing layers to tileset --- openmaptiles.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/openmaptiles.yaml b/openmaptiles.yaml index 64236195..c2078840 100644 --- a/openmaptiles.yaml +++ b/openmaptiles.yaml @@ -1,9 +1,22 @@ tileset: layers: + - layers/water/water.yaml + - layers/waterway/waterway.yaml + - layers/landcover/landcover.yaml + - layers/landuse/landuse.yaml + - layers/park/park.yaml - layers/boundary/boundary.yaml + - layers/aeroway/aeroway.yaml + - layers/transportation/transportation.yaml + - layers/building/building.yaml + - layers/water_name/water_name.yaml + - layers/transportation_name/transportation_name.yaml + - layers/place/place.yaml + - layers/housenumber/housenumber.yaml + - layers/poi/poi.yaml name: OpenMapTiles version: 3.3.0 - id: openmaptiles + id: openmaptiles description: "A tileset showcasing all layers in OpenMapTiles. http://openmaptiles.org" attribution: '© OpenMapTiles © OpenStreetMap contributors' center: [-12.2168, 28.6135, 4] From f0786f6dea3fb5035590f1dc71ec27088eee4429 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Tue, 17 Jan 2017 07:18:03 +0100 Subject: [PATCH 5/6] Add border import to quickstart --- quickstart.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/quickstart.sh b/quickstart.sh index 1330d027..b7e8f65e 100755 --- a/quickstart.sh +++ b/quickstart.sh @@ -194,6 +194,14 @@ echo " : Data license: http://openstreetmapdata.com/info/license " echo " : Thank you: http://openstreetmapdata.com/info/supporting " docker-compose run --rm import-water +echo " " +echo "-------------------------------------------------------------------------------------" +echo "====> : Start importing border data from http://openstreetmap.org into PostgreSQL " +echo " : Source code: https://github.com/openmaptiles/import-osmborder" +echo " : Data license: http://www.openstreetmap.org/copyright" +echo " : Thank you: https://github.com/pnorman/osmborder " +docker-compose run --rm import-osmborder + echo " " echo "-------------------------------------------------------------------------------------" echo "====> : Start importing http://www.naturalearthdata.com into PostgreSQL " From 2ec80a60aee73270346399e717f51fb979cf05a5 Mon Sep 17 00:00:00 2001 From: Lukas Martinelli Date: Wed, 18 Jan 2017 13:39:33 +0100 Subject: [PATCH 6/6] Do not mount import to import-osmborder --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0476c1b1..c4b97091 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -41,8 +41,6 @@ services: env_file: .env links: - postgres - volumes: - - ./data:/import import-osm-diff: image: "openmaptiles/import-osm:latest" env_file: .env