]> granicus.if.org Git - postgis/commitdiff
St_AsMVTGeom: Avoid type changes due to validation
authorRaúl Marín Rodríguez <rmrodriguez@carto.com>
Sat, 22 Sep 2018 13:06:55 +0000 (13:06 +0000)
committerRaúl Marín Rodríguez <rmrodriguez@carto.com>
Sat, 22 Sep 2018 13:06:55 +0000 (13:06 +0000)
References #4181

git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@16832 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
postgis/mvt.c
regress/mvt.sql
regress/mvt_expected

diff --git a/NEWS b/NEWS
index e7205aac9edf9c9be2d4ee4ae0ddcadfb2b97cf2..b236001c1479ac3a853a22b86882beb2270c0f7a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index cdca7e68d1eda1c694a6dd73a4e8fe11b7d363fa..8168524dac129e2fc3b9c76a349bf94d0256a34a 100644 (file)
@@ -849,14 +849,24 @@ LWGEOM *mvt_geom(LWGEOM *lwgeom, const GBOX *gbox, uint32_t extent, uint32_t buf
        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);
        }
index 64d786fcd6044d450c5c1fd55cc4b9f6f606d307..cbe398871ea05ae050d748bc1e0824beced9a9c6 100644 (file)
@@ -257,6 +257,14 @@ SELECT 'PG43 - OFF', ST_AsText(ST_AsMVTGeom(
        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)'),
index 0070de6f13c07068c5af76578fa3df76ceb0b2ff..13a39103319c383fce18913fb933b5d783e9351e 100644 (file)
@@ -46,6 +46,7 @@ PG42 - ON |LINESTRING(0 10,0 0,1 0)
 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==