889{
891
893 bool isnull;
894
895 GEOSGeometry **geoms = NULL;
896 GEOSGeometry *geos = NULL;
897 GEOSGeometry *geos_result = NULL;
898 uint32 ngeoms = 0;
899
900 ArrayType *array = PG_GETARG_ARRAYTYPE_P(0);
901 uint32 nelems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
902 ArrayIterator iterator = array_create_iterator(array, 0, NULL);
903
904
905 if (nelems == 0)
906 PG_RETURN_NULL();
907
908
909 geoms = palloc(sizeof(GEOSGeometry *) * nelems);
910
912
913 while (array_iterate(iterator, &value, &isnull))
914 {
916
917 if (isnull) continue;
918
919
922
923
925 if (!geos) continue;
926
927 geoms[ngeoms++] = geos;
928 }
929 array_free_iterator(iterator);
930
931 if (ngeoms == 0)
932 PG_RETURN_NULL();
933
934 geos = GEOSGeom_createCollection(
935 GEOS_GEOMETRYCOLLECTION,
936 geoms, ngeoms);
937
938 if (!geos)
939 {
942 }
943
944 geos_result = GEOSCoverageUnion(geos);
945 GEOSGeom_destroy(geos);
946 if (!geos_result)
948
950 GEOSGeom_destroy(geos_result);
951
952 PG_RETURN_POINTER(
result);
953}
char result[OUT_DOUBLE_BUFFER_SIZE]
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
void lwgeom_geos_error(const char *fmt,...)
static void coverage_destroy_geoms(GEOSGeometry **geoms, uint32 ngeoms)
GSERIALIZED * GEOS2POSTGIS(GEOSGeom geom, char want3d)
GEOSGeometry * POSTGIS2GEOS(const GSERIALIZED *pglwgeom)
#define HANDLE_GEOS_ERROR(label)