Skip to content

Commit

Permalink
boundary.sql parallelization issue fix (openmaptiles#1551)
Browse files Browse the repository at this point in the history
VectorTiles generated via the [openmaptiles-tools](https://github.com/openmaptiles/openmaptiles-tools) toolchain and using the OpenMaptiles-SQL-Layers as the query-source result in tiles which can contain duplicated keys.

This is because PostGIS `ST_AsMVT` is used to generate the Tiles and due to the way they [implemented parallelization](https://trac.osgeo.org/postgis/ticket/4310).

Although it is not prohibited by the Mapbox-Vector-Tile-Specification MapBox as well as MapLibre depending on version either throw a lot of warnings or even crash when encountering tiles with duplicated keys.
mapbox/vector-tile#55
maplibre/maplibre-native#795

After investigating I identified the boundary layer in zoom-leves 1 - 4 as the only layers containing duplicated keys.
  • Loading branch information
benedikt-brandtner-bikemap authored Jul 10, 2023
1 parent 103e37b commit a8e6573
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions layers/boundary/boundary.sql
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ FROM ne_110m_admin_0_boundary_lines_land_gen_z0
-- etldoc: ne_50m_admin_0_boundary_lines_land_gen_z1 -> boundary_z1
-- etldoc: ne_10m_admin_1_states_provinces_lines_gen_z1 -> boundary_z1
-- etldoc: osm_border_disp_linestring_gen_z1 -> boundary_z1
CREATE OR REPLACE VIEW boundary_z1 AS
DROP MATERIALIZED VIEW IF EXISTS boundary_z1 CASCADE;
CREATE MATERIALIZED VIEW boundary_z1 AS
(
SELECT geometry,
admin_level,
Expand Down Expand Up @@ -380,12 +381,14 @@ SELECT geometry,
maritime
FROM osm_border_disp_linestring_gen_z1
);
CREATE INDEX IF NOT EXISTS boundary_z1_idx ON boundary_z1 USING gist (geometry);


-- etldoc: ne_50m_admin_0_boundary_lines_land_gen_z2 -> boundary_z2
-- etldoc: ne_10m_admin_1_states_provinces_lines_gen_z2 -> boundary_z2
-- etldoc: osm_border_disp_linestring_gen_z2 -> boundary_z2
CREATE OR REPLACE VIEW boundary_z2 AS
DROP MATERIALIZED VIEW IF EXISTS boundary_z2 CASCADE;
CREATE MATERIALIZED VIEW boundary_z2 AS
(
SELECT geometry,
admin_level,
Expand Down Expand Up @@ -417,11 +420,13 @@ SELECT geometry,
maritime
FROM osm_border_disp_linestring_gen_z2
);
CREATE INDEX IF NOT EXISTS boundary_z2_idx ON boundary_z2 USING gist (geometry);

-- etldoc: ne_50m_admin_0_boundary_lines_land_gen_z3 -> boundary_z3
-- etldoc: ne_10m_admin_1_states_provinces_lines_gen_z3 -> boundary_z3
-- etldoc: osm_border_disp_linestring_gen_z3 -> boundary_z3
CREATE OR REPLACE VIEW boundary_z3 AS
DROP MATERIALIZED VIEW IF EXISTS boundary_z3 CASCADE;
CREATE MATERIALIZED VIEW boundary_z3 AS
(
SELECT geometry,
admin_level,
Expand Down Expand Up @@ -453,11 +458,13 @@ SELECT geometry,
maritime
FROM osm_border_disp_linestring_gen_z3
);
CREATE INDEX IF NOT EXISTS boundary_z3_idx ON boundary_z3 USING gist (geometry);

-- etldoc: ne_10m_admin_0_boundary_lines_land_gen_z4 -> boundary_z4
-- etldoc: ne_10m_admin_1_states_provinces_lines_gen_z4 -> boundary_z4
-- etldoc: osm_border_linestring_gen_z4 -> boundary_z4
CREATE OR REPLACE VIEW boundary_z4 AS
DROP MATERIALIZED VIEW IF EXISTS boundary_z4 CASCADE;
CREATE MATERIALIZED VIEW boundary_z4 AS
(
SELECT geometry,
admin_level,
Expand Down Expand Up @@ -489,6 +496,7 @@ SELECT geometry,
maritime
FROM osm_border_linestring_gen_z4
);
CREATE INDEX IF NOT EXISTS boundary_z4_idx ON boundary_z4 USING gist (geometry);

-- etldoc: osm_border_linestring_gen_z5 -> boundary_z5
CREATE OR REPLACE VIEW boundary_z5 AS
Expand Down

0 comments on commit a8e6573

Please sign in to comment.