]> granicus.if.org Git - postgis/commitdiff
Force multi-type in output if input was multi [RT-SIGTA]
authorSandro Santilli <strk@keybit.net>
Sun, 21 Feb 2010 22:10:02 +0000 (22:10 +0000)
committerSandro Santilli <strk@keybit.net>
Sun, 21 Feb 2010 22:10:02 +0000 (22:10 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5281 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_geos_clean.c

index 385eb8bfaf1d260710c854009e3166cb9040d406..18fa0e3211874b5d0206c8275ee872b318096176 100644 (file)
@@ -637,7 +637,7 @@ LWGEOM_GEOS_makeValidPolygon(const GEOSGeometry* gin)
                        /* cleanup and throw */
                        lwnotice("GEOSGeom_createCollection() threw an error: %s",
                                 loggederror);
-                       return NULL;
+                       return 0;
                }
 
        }
@@ -810,7 +810,13 @@ Datum st_makevalid(PG_FUNCTION_ARGS)
         * Input geometry was lwgeom_in
         */
 
-       out = GEOS2POSTGIS(geosgeom, is3d);
+       lwgeom_out = GEOS2LWGEOM(geosgeom, is3d);
+       if ( lwgeom_is_collection(TYPE_GETTYPE(lwgeom_in->type))
+               && ! lwgeom_is_collection(TYPE_GETTYPE(lwgeom_out->type)) )
+       {
+               lwgeom_out = lwgeom_as_multi(lwgeom_out);
+       }
+       out = pglwgeom_serialize(lwgeom_out);
        GEOSGeom_destroy(geosgeom);
        geosgeom=0;