[postgis-tickets] r16832 - St_AsMVTGeom: Avoid type changes due to validation

Raul raul at rmr.ninja
Sat Sep 22 06:06:55 PDT 2018


Author: algunenano
Date: 2018-09-22 06:06:55 -0700 (Sat, 22 Sep 2018)
New Revision: 16832

Modified:
   branches/2.5/NEWS
   branches/2.5/postgis/mvt.c
   branches/2.5/regress/mvt.sql
   branches/2.5/regress/mvt_expected
Log:
St_AsMVTGeom: Avoid type changes due to validation

References #4181


Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS	2018-09-22 13:00:41 UTC (rev 16831)
+++ branches/2.5/NEWS	2018-09-22 13:06:55 UTC (rev 16832)
@@ -1,3 +1,12 @@
+PostGIS 2.5.0rc3
+XXXX/XX/XX
+WARNING: If compiling with PostgreSQL+JIT, LLVM >= 6 is required
+
+New since Postgis 2.5.0rc2:
+  - #4181, St_AsMVTGeom: Avoid type changes due to validation (Raúl Marín)
+  - #4156, ST_ChaikinSmoothing: also smooth start/end point of
+  polygon by default (Darafei Praliaskouski)
+
 PostGIS 2.5.0rc2
 2018/09/16
 WARNING: If compiling with PostgreSQL+JIT, LLVM >= 6 is required

Modified: branches/2.5/postgis/mvt.c
===================================================================
--- branches/2.5/postgis/mvt.c	2018-09-22 13:00:41 UTC (rev 16831)
+++ branches/2.5/postgis/mvt.c	2018-09-22 13:06:55 UTC (rev 16832)
@@ -849,14 +849,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: branches/2.5/regress/mvt.sql
===================================================================
--- branches/2.5/regress/mvt.sql	2018-09-22 13:00:41 UTC (rev 16831)
+++ branches/2.5/regress/mvt.sql	2018-09-22 13:06:55 UTC (rev 16832)
@@ -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)'),

Modified: branches/2.5/regress/mvt_expected
===================================================================
--- branches/2.5/regress/mvt_expected	2018-09-22 13:00:41 UTC (rev 16831)
+++ branches/2.5/regress/mvt_expected	2018-09-22 13:06:55 UTC (rev 16832)
@@ -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