]> granicus.if.org Git - postgis/commitdiff
ST_CollectionExtract: inconsistent EMPTY results (#1778)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 21 May 2012 09:41:04 +0000 (09:41 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 21 May 2012 09:41:04 +0000 (09:41 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9764 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_functions_basic.c

index 2e31c57da6e53b0fa8b18b938686bd06de51862f..fd8556748e265caa25d4762047f1311f9b7d6d6a 100644 (file)
@@ -2558,13 +2558,12 @@ Datum ST_CollectionExtract(PG_FUNCTION_ARGS)
                /* Non-collections of the matching type go back */
                if(lwgeom_type == type)
                {
-                       lwgeom_free(lwgeom);
-                       PG_RETURN_POINTER(input);
+                       lwcol = lwgeom_as_multi(lwgeom);
                }
                /* Others go back as EMPTY */
                else
                {
-                       lwcol = lwgeom_construct_empty(type, lwgeom->srid, FLAGS_GET_Z(lwgeom->flags), FLAGS_GET_M(lwgeom->flags));
+                       lwcol = lwgeom_as_multi(lwgeom_construct_empty(type, lwgeom->srid, FLAGS_GET_Z(lwgeom->flags), FLAGS_GET_M(lwgeom->flags)));
                }
        }
        else
@@ -2572,13 +2571,6 @@ Datum ST_CollectionExtract(PG_FUNCTION_ARGS)
                lwcol = lwcollection_as_lwgeom(lwcollection_extract((LWCOLLECTION*)lwgeom, type));
        }
 
-#if 0
-       if (lwgeom_is_empty(lwcollection_as_lwgeom(lwcol)))
-       {
-               lwgeom_free(lwgeom);
-               PG_RETURN_NULL();
-       }
-#endif
        output = geometry_serialize((LWGEOM*)lwcol);
        lwgeom_free(lwgeom);
        lwgeom_free(lwcol);