[postgis-tickets] r16831 - St_AsMVTGeom: Avoid type changes due to validation
Raul
raul at rmr.ninja
Sat Sep 22 06:00:42 PDT 2018
Author: algunenano
Date: 2018-09-22 06:00:41 -0700 (Sat, 22 Sep 2018)
New Revision: 16831
Modified:
trunk/NEWS
trunk/postgis/mvt.c
trunk/regress/mvt.sql
trunk/regress/mvt_expected
Log:
St_AsMVTGeom: Avoid type changes due to validation
References #4181
Closes https://github.com/postgis/postgis/pull/304/
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2018-09-22 10:39:09 UTC (rev 16830)
+++ trunk/NEWS 2018-09-22 13:00:41 UTC (rev 16831)
@@ -18,6 +18,7 @@
- #4176, ST_Intersects supports GEOMETRYCOLLECTION (Darafei Praliaskouski)
- #4177, Postgres 12 disallows variable length arrays in C (Laurenz Albe)
- #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.5.0rc1
2018/08/19
Modified: trunk/postgis/mvt.c
===================================================================
--- trunk/postgis/mvt.c 2018-09-22 10:39:09 UTC (rev 16830)
+++ trunk/postgis/mvt.c 2018-09-22 13:00:41 UTC (rev 16831)
@@ -921,14 +921,24 @@
if (lwgeom == NULL || lwgeom_is_empty(lwgeom))
return NULL;
- /* if polygon(s) make valid and force clockwise as per MVT spec */
+
if (lwgeom->type == POLYGONTYPE ||
lwgeom->type == MULTIPOLYGONTYPE ||
lwgeom->type == COLLECTIONTYPE)
{
+ /* Force validation as per MVT spec */
lwgeom = lwgeom_make_valid(lwgeom);
- /* In image coordinates CW actually comes out a CCW, so */
- /* we also reverse. ¯\_(ツ)_/¯ */
+
+ /* Drop type changes tp play nice with MVT renderers */
+ if (!(lwgeom->type == POLYGONTYPE ||
+ lwgeom->type == MULTIPOLYGONTYPE ||
+ lwgeom->type == COLLECTIONTYPE))
+ {
+ lwgeom_free(lwgeom);
+ return NULL;
+ }
+
+ /* In image coordinates CW actually comes out a CCW, so we reverse */
lwgeom_force_clockwise(lwgeom);
lwgeom_reverse_in_place(lwgeom);
}
Modified: trunk/regress/mvt.sql
===================================================================
--- trunk/regress/mvt.sql 2018-09-22 10:39:09 UTC (rev 16830)
+++ trunk/regress/mvt.sql 2018-09-22 13:00:41 UTC (rev 16831)
@@ -257,6 +257,14 @@
ST_MakeBox2D(ST_Point(0, 0), ST_Point(100, 100)),
10, 0, false));
+-- 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_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
@@ -485,4 +493,4 @@
SELECT 1::double precision AS c1, 'abcd'::text AS c2, 20::integer as c1,
ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)), 4096, 0, false) AS geom
-) AS q;
\ No newline at end of file
+) AS q;
Modified: trunk/regress/mvt_expected
===================================================================
--- trunk/regress/mvt_expected 2018-09-22 10:39:09 UTC (rev 16830)
+++ trunk/regress/mvt_expected 2018-09-22 13:00:41 UTC (rev 16831)
@@ -46,6 +46,7 @@
PG42 - OFF|LINESTRING(0 10,0 0,1 0)
PG43 - ON |MULTIPOLYGON(((5 5,0 0,10 0,5 5)),((0 10,5 5,10 10,0 10)))
PG43 - OFF|MULTIPOLYGON(((5 5,-1 -1,11 -1,5 5)),((5 5,11 11,-1 11,5 5)))
+PG44|
TG1|GiEKBHRlc3QSDBICAAAYASIECTLePxoCYzEiAigBKIAgeAI=
TG2|GiMKBHRlc3QSDhICAAAYASIGETLePwIBGgJjMSICKAEogCB4Ag==
TG3|GiYKBHRlc3QSERICAAAYAiIJCQCAQArQD88PGgJjMSICKAEogCB4Ag==
More information about the postgis-tickets
mailing list