Don't use a collection when there's no area
authorSandro Santilli <strk@keybit.net>
Sun, 28 Feb 2010 22:48:42 +0000 (22:48 +0000)
committerSandro Santilli <strk@keybit.net>
Sun, 28 Feb 2010 22:48:42 +0000 (22:48 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5359 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_geos_clean.c

index 46fdc3599ceb1b8be11110dff21de2945ed83047..a6ffa3750ad378d11a814840694d2d3ee838852a 100644 (file)
@@ -543,9 +543,15 @@ LWGEOM_GEOS_makeValidPolygon(const GEOSGeometry* gin)
                geos_cut_edges = new_cut_edges;
        }
 
-       /* Collect areas and lines (if any line) */
-       if ( ! GEOSisEmpty(geos_cut_edges) )
+       if ( GEOSisEmpty(geos_area) )
        {
+               /* Return cut edges */
+               GEOSGeom_destroy(geos_area);
+               return geos_cut_edges;
+       }
+       else if ( ! GEOSisEmpty(geos_cut_edges) )
+       {
+               /* Collect areas and lines (if any line) */
                vgeoms[0] = geos_area;
                vgeoms[1] = geos_cut_edges;
                gout = GEOSGeom_createCollection(GEOS_GEOMETRYCOLLECTION, vgeoms, 2);
@@ -557,14 +563,14 @@ LWGEOM_GEOS_makeValidPolygon(const GEOSGeometry* gin)
                        return NULL;
                }
 
+               return gout;
        }
        else
        {
                GEOSGeom_destroy(geos_cut_edges);
-               gout = geos_area;
+               return geos_area;
        }
 
-       return gout;
 }
 
 /*