From c0cb6df571c82d926476741f2fe647bbf97a9928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20La=C5=BEa?= Date: Fri, 30 Oct 2020 17:50:49 +0100 Subject: [PATCH] Bug fix tile_to_bbox(): use pixel_width instead of extent. (#333) When PgQuery makes a query into postgres it uses smaller tile buffer than Mapnik. In example below layer `place` has a `buffer_size` set to 256. Example: Queried tile: 7/69/43 Queried layer: `layer_place` Green: bbox of tile Purple: bbox of PgQuery query of `layer_place` before bug fix Blue dash: bbox of PgQuery query of `layer_place` after bug fix Red dot dash: bbox of Mapnik query of `layer_place` Blue: ![image](https://user-images.githubusercontent.com/19833762/97620293-a9350800-1a21-11eb-9c85-0488539d2b82.png) --- openmaptiles/sqltomvt.py | 4 ++-- tests/expected/mvttile_func.sql | 2 +- tests/expected/mvttile_func_key.sql | 2 +- tests/expected/mvttile_prep.sql | 2 +- tests/expected/mvttile_psql.sql | 2 +- tests/expected/mvttile_query.sql | 2 +- tests/expected/mvttile_query_gzip.sql | 2 +- tests/expected/mvttile_query_gzip9.sql | 2 +- tests/expected/mvttile_query_no_feat_ids.sql | 2 +- tests/expected/mvttile_query_test_geom.sql | 2 +- tests/expected/mvttile_query_test_geom_key.sql | 2 +- tests/expected/mvttile_query_v2.4.0dev-a.sql | 2 +- tests/expected/mvttile_query_v2.4.0dev.sql | 2 +- tests/expected/mvttile_query_v2.4.8-a.sql | 2 +- tests/expected/mvttile_query_v2.4.8.sql | 2 +- tests/expected/mvttile_query_v2.5.sql | 2 +- tests/expected/mvttile_query_v3.0.sql | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/openmaptiles/sqltomvt.py b/openmaptiles/sqltomvt.py index 0ffd6318..21b21267 100644 --- a/openmaptiles/sqltomvt.py +++ b/openmaptiles/sqltomvt.py @@ -228,11 +228,11 @@ def tile_to_bbox(self, layer: Layer, zoom, x, y): # Every subsequent zoom divides it by 2 if layer.buffer_size > 0: if not self.tile_envelope_margin: - percentage = 40075016.6855785 * layer.buffer_size / self.extent + percentage = 40075016.6855785 * layer.buffer_size / self.pixel_width return f"ST_Expand({self.bbox(zoom, x, y)}, {percentage}/2^{zoom})" else: # Once https://github.com/postgis/postgis/pull/514 is merged - return self.bbox(zoom, x, y, float(layer.buffer_size) / self.extent) + return self.bbox(zoom, x, y, float(layer.buffer_size) / self.pixel_width) else: return self.bbox(zoom, x, y) diff --git a/tests/expected/mvttile_func.sql b/tests/expected/mvttile_func.sql index d10cc22d..2d8d8c08 100644 --- a/tests/expected/mvttile_func.sql +++ b/tests/expected/mvttile_func.sql @@ -2,7 +2,7 @@ DROP FUNCTION IF EXISTS gettile(integer, integer, integer); CREATE FUNCTION gettile(zoom integer, x integer, y integer) RETURNS bytea AS $$ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope(zoom, x, y), 78271.51696402051/2^zoom) as ST_AsMVTGeom(geometry, ST_TileEnvelope(zoom, x, y), 4096, 8, true) AS mvtgeometry, zoom AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope(zoom, x, y), 1252344.2714243282/2^zoom) as ST_AsMVTGeom(geometry, ST_TileEnvelope(zoom, x, y), 4096, 8, true) AS mvtgeometry, zoom AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl FROM (SELECT ST_TileEnvelope(zoom, x, y) as ST_AsMVTGeom(geometry, ST_TileEnvelope(zoom, x, y), 4096, 0, true) AS mvtgeometry, zoom AS osm_id, 'foo' AS class) AS t ) AS all_layers diff --git a/tests/expected/mvttile_func_key.sql b/tests/expected/mvttile_func_key.sql index 59d0ab95..f8cd5fe9 100644 --- a/tests/expected/mvttile_func_key.sql +++ b/tests/expected/mvttile_func_key.sql @@ -2,7 +2,7 @@ DROP FUNCTION IF EXISTS gettile(integer, integer, integer); CREATE FUNCTION gettile(zoom integer, x integer, y integer) RETURNS TABLE(mvt bytea, key text) AS $$ SELECT mvt, md5(mvt) AS key FROM (SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope(zoom, x, y), 78271.51696402051/2^zoom) as ST_AsMVTGeom(geometry, ST_TileEnvelope(zoom, x, y), 4096, 8, true) AS mvtgeometry, zoom AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope(zoom, x, y), 1252344.2714243282/2^zoom) as ST_AsMVTGeom(geometry, ST_TileEnvelope(zoom, x, y), 4096, 8, true) AS mvtgeometry, zoom AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl FROM (SELECT ST_TileEnvelope(zoom, x, y) as ST_AsMVTGeom(geometry, ST_TileEnvelope(zoom, x, y), 4096, 0, true) AS mvtgeometry, zoom AS osm_id, 'foo' AS class) AS t ) AS all_layers) AS mvt_data diff --git a/tests/expected/mvttile_prep.sql b/tests/expected/mvttile_prep.sql index 36401d2d..0ebbd6d4 100644 --- a/tests/expected/mvttile_prep.sql +++ b/tests/expected/mvttile_prep.sql @@ -8,7 +8,7 @@ END $$; -- Run this statement with EXECUTE gettile(zoom, x, y) PREPARE gettile(integer, integer, integer) AS SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl FROM (SELECT ST_TileEnvelope($1, $2, $3) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t ) AS all_layers diff --git a/tests/expected/mvttile_psql.sql b/tests/expected/mvttile_psql.sql index 379cc921..b98bcc08 100644 --- a/tests/expected/mvttile_psql.sql +++ b/tests/expected/mvttile_psql.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope(:zoom, :x, :y), 78271.51696402051/2^:zoom) as ST_AsMVTGeom(geometry, ST_TileEnvelope(:zoom, :x, :y), 4096, 8, true) AS mvtgeometry, :zoom AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope(:zoom, :x, :y), 1252344.2714243282/2^:zoom) as ST_AsMVTGeom(geometry, ST_TileEnvelope(:zoom, :x, :y), 4096, 8, true) AS mvtgeometry, :zoom AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl FROM (SELECT ST_TileEnvelope(:zoom, :x, :y) as ST_AsMVTGeom(geometry, ST_TileEnvelope(:zoom, :x, :y), 4096, 0, true) AS mvtgeometry, :zoom AS osm_id, 'foo' AS class) AS t ) AS all_layers diff --git a/tests/expected/mvttile_query.sql b/tests/expected/mvttile_query.sql index 9ebd709f..6d4c54e5 100644 --- a/tests/expected/mvttile_query.sql +++ b/tests/expected/mvttile_query.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl FROM (SELECT ST_TileEnvelope($1, $2, $3) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t ) AS all_layers diff --git a/tests/expected/mvttile_query_gzip.sql b/tests/expected/mvttile_query_gzip.sql index 92e69a22..0ebce497 100644 --- a/tests/expected/mvttile_query_gzip.sql +++ b/tests/expected/mvttile_query_gzip.sql @@ -1,5 +1,5 @@ SELECT GZIP(STRING_AGG(mvtl, '')) AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl FROM (SELECT ST_TileEnvelope($1, $2, $3) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t ) AS all_layers diff --git a/tests/expected/mvttile_query_gzip9.sql b/tests/expected/mvttile_query_gzip9.sql index 9e0afe02..678e66f3 100644 --- a/tests/expected/mvttile_query_gzip9.sql +++ b/tests/expected/mvttile_query_gzip9.sql @@ -1,5 +1,5 @@ SELECT GZIP(STRING_AGG(mvtl, ''), 9) AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl FROM (SELECT ST_TileEnvelope($1, $2, $3) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t ) AS all_layers diff --git a/tests/expected/mvttile_query_no_feat_ids.sql b/tests/expected/mvttile_query_no_feat_ids.sql index a754583b..6fb1f1db 100644 --- a/tests/expected/mvttile_query_no_feat_ids.sql +++ b/tests/expected/mvttile_query_no_feat_ids.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_TileEnvelope($1, $2, $3) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t ) AS all_layers diff --git a/tests/expected/mvttile_query_test_geom.sql b/tests/expected/mvttile_query_test_geom.sql index 451ba6c6..18fe0782 100644 --- a/tests/expected/mvttile_query_test_geom.sql +++ b/tests/expected/mvttile_query_test_geom.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt, SUM(COALESCE(_bad_geos_, 0)) as _bad_geos_ FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl, SUM((1-COALESCE(ST_IsValid(mvtgeometry)::int, 1))+COALESCE(_bad_geos_, 0)) as _bad_geos_ FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, (1-ST_IsValid(geometry)::int) as _bad_geos_, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl, SUM((1-COALESCE(ST_IsValid(mvtgeometry)::int, 1))+COALESCE(_bad_geos_, 0)) as _bad_geos_ FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, (1-ST_IsValid(geometry)::int) as _bad_geos_, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl, SUM((1-COALESCE(ST_IsValid(mvtgeometry)::int, 1))+COALESCE(_bad_geos_, 0)) as _bad_geos_ FROM (SELECT ST_TileEnvelope($1, $2, $3) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 0, true) AS mvtgeometry, (1-ST_IsValid(geometry)::int) as _bad_geos_, $1 AS osm_id, 'foo' AS class) AS t ) AS all_layers diff --git a/tests/expected/mvttile_query_test_geom_key.sql b/tests/expected/mvttile_query_test_geom_key.sql index 3c9487b8..093f3960 100644 --- a/tests/expected/mvttile_query_test_geom_key.sql +++ b/tests/expected/mvttile_query_test_geom_key.sql @@ -1,5 +1,5 @@ SELECT mvt, md5(mvt) AS key, _bad_geos_ FROM (SELECT STRING_AGG(mvtl, '') AS mvt, SUM(COALESCE(_bad_geos_, 0)) as _bad_geos_ FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl, SUM((1-COALESCE(ST_IsValid(mvtgeometry)::int, 1))+COALESCE(_bad_geos_, 0)) as _bad_geos_ FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, (1-ST_IsValid(geometry)::int) as _bad_geos_, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl, SUM((1-COALESCE(ST_IsValid(mvtgeometry)::int, 1))+COALESCE(_bad_geos_, 0)) as _bad_geos_ FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, (1-ST_IsValid(geometry)::int) as _bad_geos_, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl, SUM((1-COALESCE(ST_IsValid(mvtgeometry)::int, 1))+COALESCE(_bad_geos_, 0)) as _bad_geos_ FROM (SELECT ST_TileEnvelope($1, $2, $3) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 0, true) AS mvtgeometry, (1-ST_IsValid(geometry)::int) as _bad_geos_, $1 AS osm_id, 'foo' AS class) AS t ) AS all_layers) AS mvt_data diff --git a/tests/expected/mvttile_query_v2.4.0dev-a.sql b/tests/expected/mvttile_query_v2.4.0dev-a.sql index 0f5b4972..4d33f9c0 100644 --- a/tests/expected/mvttile_query_v2.4.0dev-a.sql +++ b/tests/expected/mvttile_query_v2.4.0dev-a.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT('housenumber', 4096, 'mvtgeometry', t), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t WHERE mvtgeometry IS NOT NULL + SELECT COALESCE(ST_AsMVT('housenumber', 4096, 'mvtgeometry', t), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t WHERE mvtgeometry IS NOT NULL UNION ALL SELECT COALESCE(ST_AsMVT('enumfield', 4096, 'mvtgeometry', t), '') as mvtl FROM (SELECT TileBBox($1, $2, $3) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t WHERE mvtgeometry IS NOT NULL ) AS all_layers diff --git a/tests/expected/mvttile_query_v2.4.0dev.sql b/tests/expected/mvttile_query_v2.4.0dev.sql index 0f5b4972..4d33f9c0 100644 --- a/tests/expected/mvttile_query_v2.4.0dev.sql +++ b/tests/expected/mvttile_query_v2.4.0dev.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT('housenumber', 4096, 'mvtgeometry', t), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t WHERE mvtgeometry IS NOT NULL + SELECT COALESCE(ST_AsMVT('housenumber', 4096, 'mvtgeometry', t), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t WHERE mvtgeometry IS NOT NULL UNION ALL SELECT COALESCE(ST_AsMVT('enumfield', 4096, 'mvtgeometry', t), '') as mvtl FROM (SELECT TileBBox($1, $2, $3) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t WHERE mvtgeometry IS NOT NULL ) AS all_layers diff --git a/tests/expected/mvttile_query_v2.4.8-a.sql b/tests/expected/mvttile_query_v2.4.8-a.sql index 0a641de5..a40be636 100644 --- a/tests/expected/mvttile_query_v2.4.8-a.sql +++ b/tests/expected/mvttile_query_v2.4.8-a.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t WHERE mvtgeometry IS NOT NULL + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t WHERE mvtgeometry IS NOT NULL UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT TileBBox($1, $2, $3) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t WHERE mvtgeometry IS NOT NULL ) AS all_layers diff --git a/tests/expected/mvttile_query_v2.4.8.sql b/tests/expected/mvttile_query_v2.4.8.sql index 0a641de5..a40be636 100644 --- a/tests/expected/mvttile_query_v2.4.8.sql +++ b/tests/expected/mvttile_query_v2.4.8.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t WHERE mvtgeometry IS NOT NULL + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t WHERE mvtgeometry IS NOT NULL UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT TileBBox($1, $2, $3) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t WHERE mvtgeometry IS NOT NULL ) AS all_layers diff --git a/tests/expected/mvttile_query_v2.5.sql b/tests/expected/mvttile_query_v2.5.sql index 80087892..288ee4f4 100644 --- a/tests/expected/mvttile_query_v2.5.sql +++ b/tests/expected/mvttile_query_v2.5.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(TileBBox($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT TileBBox($1, $2, $3) as ST_AsMVTGeom(geometry, TileBBox($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t ) AS all_layers diff --git a/tests/expected/mvttile_query_v3.0.sql b/tests/expected/mvttile_query_v3.0.sql index 9ebd709f..6d4c54e5 100644 --- a/tests/expected/mvttile_query_v3.0.sql +++ b/tests/expected/mvttile_query_v3.0.sql @@ -1,5 +1,5 @@ SELECT STRING_AGG(mvtl, '') AS mvt FROM ( - SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 78271.51696402051/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t + SELECT COALESCE(ST_AsMVT(t, 'housenumber', 4096, 'mvtgeometry'), '') as mvtl FROM (SELECT ST_Expand(ST_TileEnvelope($1, $2, $3), 1252344.2714243282/2^$1) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 8, true) AS mvtgeometry, $1 AS housenumber, NULLIF(tags->'name:en', '') AS "name:en", NULLIF(tags->'name:de', '') AS "name:de", NULLIF(tags->'name:cs', '') AS "name:cs", NULLIF(tags->'name_int', '') AS "name_int", NULLIF(tags->'name:latin', '') AS "name:latin", NULLIF(tags->'name:nonlatin', '') AS "name:nonlatin" FROM (SELECT 'name:en=>"enname"'::hstore as tags) AS tt) AS t UNION ALL SELECT COALESCE(ST_AsMVT(t, 'enumfield', 4096, 'mvtgeometry', 'osm_id'), '') as mvtl FROM (SELECT ST_TileEnvelope($1, $2, $3) as ST_AsMVTGeom(geometry, ST_TileEnvelope($1, $2, $3), 4096, 0, true) AS mvtgeometry, $1 AS osm_id, 'foo' AS class) AS t ) AS all_layers