]> granicus.if.org Git - postgis/commitdiff
simplifyvw: allow polygon inner rings to collapse
authorNicklas Avén <nicklas.aven@jordogskog.no>
Sat, 4 Apr 2015 19:42:02 +0000 (19:42 +0000)
committerNicklas Avén <nicklas.aven@jordogskog.no>
Sat, 4 Apr 2015 19:42:02 +0000 (19:42 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13420 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/effectivearea.c

index f8d301ef7f89620a1fa6ec56263746a65e493045..b89fd2cb3bdef72011c3d7695491bdbe1939f6a7 100644 (file)
@@ -423,6 +423,7 @@ static POINTARRAY * ptarray_set_effective_area(POINTARRAY *inpts,int avoid_colla
                }       
        }
        destroy_effectivearea(ea);
+       
        return opts;
        
 }
@@ -455,6 +456,7 @@ static LWPOLY* lwpoly_set_effective_area(const LWPOLY *ipoly,int set_area, doubl
        LWDEBUG(2, "Entered  lwpoly_set_effective_area");
        int i;
        int set_m;
+       int avoid_collapse=4;
        if(set_area)
                set_m=1;
        else
@@ -467,9 +469,15 @@ static LWPOLY* lwpoly_set_effective_area(const LWPOLY *ipoly,int set_area, doubl
 
        for (i = 0; i < ipoly->nrings; i++)
        {
+               POINTARRAY *pa = ptarray_set_effective_area(ipoly->rings[i],avoid_collapse,set_area,trshld);
                /* Add ring to simplified polygon */
-               if( lwpoly_add_ring(opoly, ptarray_set_effective_area(ipoly->rings[i],4,set_area,trshld)) == LW_FAILURE )
-                       return NULL;
+               if(pa->npoints>=4)
+               {
+                       if( lwpoly_add_ring(opoly,pa ) == LW_FAILURE )
+                               return NULL;
+               }
+               /*Inner rings we allow to ocollapse and then we remove them*/
+               avoid_collapse=0;
        }