]> granicus.if.org Git - postgis/commitdiff
Only keep the highest dimension geometry for collections
authorBjörn Harrtell <bjorn@wololo.org>
Thu, 16 Mar 2017 13:08:38 +0000 (13:08 +0000)
committerBjörn Harrtell <bjorn@wololo.org>
Thu, 16 Mar 2017 13:08:38 +0000 (13:08 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@15335 b70326c6-7e19-0410-871a-916f4a2858ee

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

index e38a39cec38d0563dc5a1c45314ecfc78a19b692..d7070976d713d8f3bbd48bbfc730c25e31c4b5e8 100644 (file)
@@ -507,6 +507,24 @@ LWGEOM *mvt_geom(LWGEOM *lwgeom, GBOX *gbox, uint32_t extent, uint32_t buffer,
        lwgeom_force_clockwise(lwgeom_out);
        lwgeom_out = lwgeom_make_valid(lwgeom_out);
 
+       int type = lwgeom_out->type;
+       int i, extract_type = 1;
+       if (type == COLLECTIONTYPE) {
+               LWCOLLECTION *lwcoll = (LWCOLLECTION*) lwgeom_out;
+               for (i = 0; i < lwcoll->ngeoms; i++) {
+                       LWGEOM *geom = lwcoll->geoms[i];
+                       if (geom->type == POLYGONTYPE) {
+                               extract_type = 3;
+                               break;
+                       } else if (geom->type == LINETYPE) {
+                               extract_type = 2;
+                       }
+               }
+               lwgeom_out = lwcollection_as_lwgeom(
+                       lwcollection_extract(lwcoll, extract_type));
+               lwgeom_out = lwgeom_homogenize(lwgeom_out);
+       }
+
        return lwgeom_out;
 }
 
index f5a5fca3473b52a8fded1a52d9658e2420551f3e..f32c22d230bdfaeaa80d7ec0518191225de6b208 100644 (file)
@@ -23,6 +23,15 @@ select 'PG6', ST_AsText(ST_AsMVTGeom(
        ST_GeomFromText('POLYGON ((762780 6474467, 717821 6797045, 1052826 6797045, 762780 6474467))'),
        ST_MakeBox2D(ST_Point(626172.135625, 6261721.35625), ST_Point(1252344.27125, 6887893.49188)),
        4096, 0, false));
+select 'PG7', ST_AsText(ST_AsMVTGeom(
+    ST_GeomFromText('POLYGON((-7792023.4539488 1411512.60791779,-7785283.40665468 1406282.69482469,-7783978.88137195 1404858.20373788,-7782986.89858399 1402324.91434802,-7779028.02672366 1397370.31802772,
+        -7778652.06985644 1394387.75452545,-7779906.76953697 1393279.22658385,-7782212.33678782 1393293.14086794,-7784631.14401331 1394225.4151684,-7786257.27108231 1395867.40241344,-7783978.88137195 1395867.40241344,
+        -7783978.88137195 1396646.68250521,-7787752.03959369 1398469.72134299,-7795443.30325373 1405280.43988858,-7797717.16326269 1406217.73286975,-7798831.44531677 1406904.48130551,-7799311.5830898 1408004.24038921,
+        -7799085.10302919 1409159.72782477,-7798052.35381919 1411108.84582812,-7797789.63692662 1412213.40365339,-7798224.47868753 1414069.89725829,-7799003.5701851 1415694.42577482,-7799166.63587328 1416966.26267896,
+        -7797789.63692662 1417736.81850415,-7793160.38395328 1412417.61222784,-7792023.4539488 1411512.60791779))'),
+        ST_MakeBox2D(ST_Point(-20037508.34, 20037508.34), ST_Point(20037508.34, -20037508.34)),
+        4096, 10, true));
+
 
 -- geometry encoding tests
 SELECT 'TG1', encode(ST_AsMVT('test', 4096, 'geom', q), 'base64') FROM (SELECT 1 AS c1,
index 97e843d9e1bc633f005123a74c309036717d2181..8e2598a9ef82dd76d2f12c664536377ae837ac43 100644 (file)
@@ -4,6 +4,7 @@ PG3|POINT(2 4092)
 PG4|MULTIPOLYGON(((5 4096,10 4096,10 4091,5 4096)),((0 4096,0 4101,5 4096,0 4096)))
 PG5|POINT(0 4096)
 PG6|POLYGON((894 2704,2791 594,600 594,894 2704))
+PG7|POLYGON((1252 1904,1251 1904,1252 1905,1253 1906,1253 1905,1252 1904))
 TG1|GiEKBHRlc3QSDBICAAAYASIECTLePxoCYzEiAigBKIAgeAI=
 TG2|GiMKBHRlc3QSDhICAAAYASIGETLePwIBGgJjMSICKAEogCB4Ag==
 TG3|GiYKBHRlc3QSERICAAAYAiIJCQCAQArQD88PGgJjMSICKAEogCB4Ag==