kopia lustrzana https://github.com/openmaptiles/openmaptiles
Merge pull request #135 from openmaptiles/osmborder
Switch to OSM Borders by Paul Normanpull/124/head^2
commit
da474c703d
|
@ -36,6 +36,11 @@ services:
|
||||||
- ./data:/import
|
- ./data:/import
|
||||||
- ./build:/mapping
|
- ./build:/mapping
|
||||||
- cache:/cache
|
- cache:/cache
|
||||||
|
import-osmborder:
|
||||||
|
image: "openmaptiles/import-osmborder:0.2"
|
||||||
|
env_file: .env
|
||||||
|
links:
|
||||||
|
- postgres
|
||||||
import-osm-diff:
|
import-osm-diff:
|
||||||
image: "openmaptiles/import-osm:latest"
|
image: "openmaptiles/import-osm:latest"
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
-- etldoc: ne_110m_admin_0_boundary_lines_land -> boundary_z0
|
-- etldoc: ne_110m_admin_0_boundary_lines_land -> boundary_z0
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW boundary_z0 AS (
|
CREATE OR REPLACE VIEW boundary_z0 AS (
|
||||||
SELECT geometry, 2 AS admin_level
|
SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime
|
||||||
FROM ne_110m_admin_0_boundary_lines_land
|
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
|
-- etldoc: ne_50m_admin_1_states_provinces_lines -> boundary_z1
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW boundary_z1 AS (
|
CREATE OR REPLACE VIEW boundary_z1 AS (
|
||||||
SELECT geometry, 2 AS admin_level
|
SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime
|
||||||
FROM ne_50m_admin_0_boundary_lines_land
|
FROM ne_50m_admin_0_boundary_lines_land
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT geometry, 4 AS admin_level
|
SELECT geometry, 4 AS admin_level, false AS disputed, false AS maritime
|
||||||
FROM ne_50m_admin_1_states_provinces_lines
|
FROM ne_50m_admin_1_states_provinces_lines
|
||||||
WHERE scalerank <= 2
|
WHERE scalerank <= 2
|
||||||
);
|
);
|
||||||
|
@ -24,102 +24,108 @@ CREATE OR REPLACE VIEW boundary_z1 AS (
|
||||||
-- etldoc: ne_50m_admin_1_states_provinces_lines -> boundary_z3
|
-- etldoc: ne_50m_admin_1_states_provinces_lines -> boundary_z3
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW boundary_z3 AS (
|
CREATE OR REPLACE VIEW boundary_z3 AS (
|
||||||
SELECT geometry, 2 AS admin_level
|
SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime
|
||||||
FROM ne_50m_admin_0_boundary_lines_land
|
FROM ne_50m_admin_0_boundary_lines_land
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT geometry, 4 AS admin_level
|
SELECT geometry, 4 AS admin_level, false AS disputed, false AS maritime
|
||||||
FROM ne_50m_admin_1_states_provinces_lines
|
FROM ne_50m_admin_1_states_provinces_lines
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
-- etldoc: ne_10m_admin_0_boundary_lines_land -> boundary_z4
|
-- etldoc: ne_10m_admin_0_boundary_lines_land -> boundary_z4
|
||||||
-- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> 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 (
|
CREATE OR REPLACE VIEW boundary_z4 AS (
|
||||||
SELECT geometry, 2 AS admin_level
|
SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime
|
||||||
FROM ne_10m_admin_0_boundary_lines_land
|
FROM ne_10m_admin_0_boundary_lines_land
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT geometry, 4 AS admin_level
|
SELECT geometry, 4 AS admin_level, false AS disputed, false AS maritime
|
||||||
FROM ne_10m_admin_1_states_provinces_lines_shp
|
FROM ne_10m_admin_1_states_provinces_lines_shp
|
||||||
WHERE scalerank <= 3 AND featurecla = 'Adm-1 boundary'
|
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_0_boundary_lines_land -> boundary_z5
|
||||||
-- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> 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 (
|
CREATE OR REPLACE VIEW boundary_z5 AS (
|
||||||
SELECT geometry, 2 AS admin_level
|
SELECT geometry, 2 AS admin_level, false AS disputed, false AS maritime
|
||||||
FROM ne_10m_admin_0_boundary_lines_land
|
FROM ne_10m_admin_0_boundary_lines_land
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT geometry, 4 AS admin_level
|
SELECT geometry, 4 AS admin_level, false AS disputed, false AS maritime
|
||||||
FROM ne_10m_admin_1_states_provinces_lines_shp
|
FROM ne_10m_admin_1_states_provinces_lines_shp
|
||||||
WHERE scalerank <= 7 AND featurecla = 'Adm-1 boundary'
|
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: osm_border_linestring_gen8 -> boundary_z6
|
||||||
-- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z6
|
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW boundary_z6 AS (
|
CREATE OR REPLACE VIEW boundary_z6 AS (
|
||||||
SELECT geometry, 2 AS admin_level
|
SELECT geometry, admin_level, disputed, maritime
|
||||||
FROM ne_10m_admin_0_boundary_lines_land
|
FROM osm_border_linestring_gen8
|
||||||
UNION ALL
|
WHERE admin_level <= 4
|
||||||
SELECT geometry, 4 AS admin_level
|
|
||||||
FROM ne_10m_admin_1_states_provinces_lines_shp
|
|
||||||
WHERE scalerank <= 9 AND featurecla = 'Adm-1 boundary'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: ne_10m_admin_0_boundary_lines_land -> boundary_z7
|
-- etldoc: osm_border_linestring_gen7 -> boundary_z7
|
||||||
-- etldoc: ne_10m_admin_1_states_provinces_lines_shp -> boundary_z7
|
|
||||||
CREATE OR REPLACE VIEW boundary_z7 AS (
|
CREATE OR REPLACE VIEW boundary_z7 AS (
|
||||||
SELECT geometry, 2 AS admin_level
|
SELECT geometry, admin_level, disputed, maritime
|
||||||
FROM ne_10m_admin_0_boundary_lines_land
|
FROM osm_border_linestring_gen7
|
||||||
UNION ALL
|
WHERE admin_level <= 4
|
||||||
SELECT geometry, 4 AS admin_level
|
|
||||||
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_gen6 -> boundary_z8
|
||||||
CREATE OR REPLACE VIEW boundary_z8 AS (
|
CREATE OR REPLACE VIEW boundary_z8 AS (
|
||||||
SELECT geometry, admin_level
|
SELECT geometry, admin_level, disputed, maritime
|
||||||
FROM osm_boundary_linestring_gen5
|
FROM osm_border_linestring_gen6
|
||||||
WHERE admin_level <= 4 AND ST_Length(geometry) > 1000
|
WHERE admin_level <= 4
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: osm_boundary_linestring_gen4 -> boundary_z9
|
-- etldoc: osm_border_linestring_gen5 -> boundary_z9
|
||||||
CREATE OR REPLACE VIEW boundary_z9 AS (
|
CREATE OR REPLACE VIEW boundary_z9 AS (
|
||||||
SELECT geometry, admin_level
|
SELECT geometry, admin_level, disputed, maritime
|
||||||
FROM osm_boundary_linestring_gen4
|
FROM osm_border_linestring_gen5
|
||||||
WHERE admin_level <= 6
|
WHERE admin_level <= 6
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: osm_boundary_linestring_gen3 -> boundary_z10
|
-- etldoc: osm_border_linestring_gen4 -> boundary_z10
|
||||||
CREATE OR REPLACE VIEW boundary_z10 AS (
|
CREATE OR REPLACE VIEW boundary_z10 AS (
|
||||||
SELECT geometry, admin_level
|
SELECT geometry, admin_level, disputed, maritime
|
||||||
FROM osm_boundary_linestring_gen3
|
FROM osm_border_linestring_gen4
|
||||||
WHERE admin_level <= 6
|
WHERE admin_level <= 6
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: osm_boundary_linestring_gen2 -> boundary_z11
|
-- etldoc: osm_border_linestring_gen3 -> boundary_z11
|
||||||
CREATE OR REPLACE VIEW boundary_z11 AS (
|
CREATE OR REPLACE VIEW boundary_z11 AS (
|
||||||
SELECT geometry, admin_level
|
SELECT geometry, admin_level, disputed, maritime
|
||||||
FROM osm_boundary_linestring_gen2
|
FROM osm_border_linestring_gen3
|
||||||
WHERE admin_level <= 8
|
WHERE admin_level <= 8
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: osm_boundary_linestring_gen1 -> boundary_z12
|
-- etldoc: osm_border_linestring_gen2 -> boundary_z12
|
||||||
CREATE OR REPLACE VIEW boundary_z12 AS (
|
CREATE OR REPLACE VIEW boundary_z12 AS (
|
||||||
SELECT geometry, admin_level
|
SELECT geometry, admin_level, disputed, maritime
|
||||||
FROM osm_boundary_linestring_gen1
|
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
|
||||||
);
|
);
|
||||||
|
|
||||||
-- etldoc: layer_boundary[shape=record fillcolor=lightpink, style="rounded,filled",
|
-- etldoc: layer_boundary[shape=record fillcolor=lightpink, style="rounded,filled",
|
||||||
-- etldoc: label="<sql> layer_boundary |<z0> z0 |<z1_2> z1_2 | <z3> z3 | <z4> z4 | <z5> z5 | <z6> z6 | <z7> z7 | <z8> z8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13+"]
|
-- etldoc: label="<sql> layer_boundary |<z0> z0 |<z1_2> z1_2 | <z3> z3 | <z4> z4 | <z5> z5 | <z6> z6 | <z7> z7 | <z8> z8 | <z9> z9 |<z10> z10 |<z11> z11 |<z12> z12|<z13> z13+"]
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION layer_boundary (bbox geometry, zoom_level int)
|
CREATE OR REPLACE FUNCTION layer_boundary (bbox geometry, zoom_level int)
|
||||||
RETURNS TABLE(geometry geometry, admin_level int) AS $$
|
RETURNS TABLE(geometry geometry, admin_level int, disputed int, maritime int) AS $$
|
||||||
SELECT geometry, admin_level FROM (
|
SELECT geometry, admin_level, disputed::int, maritime::int FROM (
|
||||||
-- etldoc: boundary_z0 -> layer_boundary:z0
|
-- etldoc: boundary_z0 -> layer_boundary:z0
|
||||||
SELECT * FROM boundary_z0 WHERE geometry && bbox AND zoom_level = 0
|
SELECT * FROM boundary_z0 WHERE geometry && bbox AND zoom_level = 0
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -156,7 +162,7 @@ RETURNS TABLE(geometry geometry, admin_level int) AS $$
|
||||||
-- etldoc: boundary_z12 -> layer_boundary:z12
|
-- etldoc: boundary_z12 -> layer_boundary:z12
|
||||||
SELECT * FROM boundary_z12 WHERE geometry && bbox AND zoom_level = 12
|
SELECT * FROM boundary_z12 WHERE geometry && bbox AND zoom_level = 12
|
||||||
UNION ALL
|
UNION ALL
|
||||||
-- etldoc: boundary_z12 -> layer_boundary:z13
|
-- etldoc: boundary_z13 -> layer_boundary:z13
|
||||||
SELECT * FROM boundary_z12 WHERE geometry && bbox AND zoom_level >= 13
|
SELECT * FROM boundary_z13 WHERE geometry && bbox AND zoom_level >= 13
|
||||||
) AS zoom_levels;
|
) AS zoom_levels;
|
||||||
$$ LANGUAGE SQL IMMUTABLE;
|
$$ LANGUAGE SQL IMMUTABLE;
|
||||||
|
|
|
@ -15,12 +15,16 @@ layer:
|
||||||
At low zoom levels the Natural Earth boundaries are mapped to the equivalent admin levels.
|
At low zoom levels the Natural Earth boundaries are mapped to the equivalent admin levels.
|
||||||
disputed:
|
disputed:
|
||||||
description: |
|
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]
|
values: [0, 1]
|
||||||
buffer_size: 4
|
buffer_size: 4
|
||||||
datasource:
|
datasource:
|
||||||
geometry_field: geometry
|
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:
|
schema:
|
||||||
- ./boundary.sql
|
- ./boundary.sql
|
||||||
datasources:
|
datasources:
|
||||||
|
|
|
@ -194,6 +194,14 @@ echo " : Data license: http://openstreetmapdata.com/info/license "
|
||||||
echo " : Thank you: http://openstreetmapdata.com/info/supporting "
|
echo " : Thank you: http://openstreetmapdata.com/info/supporting "
|
||||||
docker-compose run --rm import-water
|
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 "-------------------------------------------------------------------------------------"
|
echo "-------------------------------------------------------------------------------------"
|
||||||
echo "====> : Start importing http://www.naturalearthdata.com into PostgreSQL "
|
echo "====> : Start importing http://www.naturalearthdata.com into PostgreSQL "
|
||||||
|
|
Ładowanie…
Reference in New Issue