[postgis-tickets] r16839 - St_AsMVTGeom: Avoid type changes due to validation
Raul
raul at rmr.ninja
Mon Sep 24 03:06:13 PDT 2018
Author: algunenano
Date: 2018-09-24 03:06:13 -0700 (Mon, 24 Sep 2018)
New Revision: 16839
Modified:
branches/2.4/NEWS
branches/2.4/postgis/mvt.c
branches/2.4/regress/mvt.sql
branches/2.4/regress/mvt_expected
Log:
St_AsMVTGeom: Avoid type changes due to validation
Closes #4181
Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS 2018-09-24 02:50:10 UTC (rev 16838)
+++ branches/2.4/NEWS 2018-09-24 10:06:13 UTC (rev 16839)
@@ -3,6 +3,7 @@
* Bug Fixes and Enhancements
- #4160, Use qualified names in topology extension install (Raúl Marín)
+ - #4181, St_AsMVTGeom: Avoid type changes due to validation (Raúl Marín)
PostGIS 2.4.5
Modified: branches/2.4/postgis/mvt.c
===================================================================
--- branches/2.4/postgis/mvt.c 2018-09-24 02:50:10 UTC (rev 16838)
+++ branches/2.4/postgis/mvt.c 2018-09-24 10:06:13 UTC (rev 16839)
@@ -734,8 +734,19 @@
/* if polygon(s) make valid and force clockwise as per MVT spec */
if (lwgeom_out->type == POLYGONTYPE ||
- lwgeom_out->type == MULTIPOLYGONTYPE) {
- lwgeom_out = lwgeom_make_valid(lwgeom_out);
+ lwgeom_out->type == MULTIPOLYGONTYPE)
+ {
+ lwgeom_out = lwgeom_make_valid(lwgeom_out);
+
+ /* Drop type changes to play nice with MVT renderers */
+ if (!(lwgeom_out->type == POLYGONTYPE ||
+ lwgeom_out->type == MULTIPOLYGONTYPE ||
+ lwgeom_out->type == COLLECTIONTYPE))
+ {
+ lwgeom_free(lwgeom_out);
+ return NULL;
+ }
+
/* Because we are in image coordinates, we need to go to CCW in */
/* order to get a CW output in image space */
lwgeom_force_clockwise(lwgeom_out);
@@ -749,8 +760,18 @@
lwgeom_out = lwgeom_homogenize(lwgeom_out);
/* if polygon(s) make valid and force clockwise as per MVT spec */
if (lwgeom_out->type == POLYGONTYPE ||
- lwgeom_out->type == MULTIPOLYGONTYPE) {
- lwgeom_out = lwgeom_make_valid(lwgeom_out);
+ lwgeom_out->type == MULTIPOLYGONTYPE)
+ {
+ lwgeom_out = lwgeom_make_valid(lwgeom_out);
+
+ /* Drop type changes to play nice with MVT renderers */
+ if (!(lwgeom_out->type == POLYGONTYPE ||
+ lwgeom_out->type == MULTIPOLYGONTYPE))
+ {
+ lwgeom_free(lwgeom_out);
+ return NULL;
+ }
+
/* Because we are in image coordinates, we need to go to CCW in */
/* order to get a CW output in image space */
lwgeom_force_clockwise(lwgeom_out);
Modified: branches/2.4/regress/mvt.sql
===================================================================
--- branches/2.4/regress/mvt.sql 2018-09-24 02:50:10 UTC (rev 16838)
+++ branches/2.4/regress/mvt.sql 2018-09-24 10:06:13 UTC (rev 16839)
@@ -43,6 +43,14 @@
'POINT EMPTY'::geometry,
'BOX(0 0,2 2)'::box2d));
+-- Geometry type change
+SELECT 'PG44', ST_AsEWKT(ST_AsMVTGeom(
+ 'SRID=3857;MULTIPOLYGON(((-8238038.43842083 4974073.00356281,-8238058.59985694 4974035.91194892,-8238046.74211362 4974077.68076013,-8238038.43842083 4974073.00356281)))'::geometry,
+ 'SRID=3857;POLYGON((-8242969.13027341 4975133.29702555,-8242969.13027341 4970241.3272153,-8238077.16046316 4970241.3272153,-8238077.16046316 4975133.29702555,-8242969.13027341 4975133.29702555))'::geometry,
+ 4096,
+ 16,
+ true));
+
-- geometry encoding tests
SELECT 'TG1', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT 1 AS c1,
ST_Normalize(ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
Modified: branches/2.4/regress/mvt_expected
===================================================================
--- branches/2.4/regress/mvt_expected 2018-09-24 02:50:10 UTC (rev 16838)
+++ branches/2.4/regress/mvt_expected 2018-09-24 10:06:13 UTC (rev 16839)
@@ -8,6 +8,7 @@
PG8|MULTIPOLYGON(((5 4096,10 4096,10 4091,5 4096)),((0 4096,0 4101,5 4096,0 4096)))
PG9|POLYGON((0 0,0 4096,4096 4096,4096 0,0 0))
PG10|
+PG44|
TG1|GiEKBHRlc3QSDBICAAAYASIECTLePxoCYzEiAigBKIAgeAI=
TG2|GiMKBHRlc3QSDhICAAAYASIGETTcPwECGgJjMSICKAEogCB4Ag==
TG3|GiYKBHRlc3QSERICAAAYAiIJCQCAQArQD88PGgJjMSICKAEogCB4Ag==
More information about the postgis-tickets
mailing list