2029 Datum* result_array_data;
2030 ArrayType *array, *
result;
2032 uint32 nelems, nclusters, i;
2033 GEOSGeometry **geos_inputs, **geos_results;
2042 if (PG_ARGISNULL(0))
2045 array = PG_GETARG_ARRAYTYPE_P(0);
2048 POSTGIS_DEBUGF(3,
"clusterintersecting_garray: number of non-null elements: %d", nelems);
2050 if ( nelems == 0 ) PG_RETURN_NULL();
2057 geos_inputs =
ARRAY2GEOS(array, nelems, &is3d, &srid);
2065 elog(ERROR,
"clusterintersecting: Error performing clustering");
2070 if (!geos_results) PG_RETURN_NULL();
2072 result_array_data = palloc(nclusters *
sizeof(Datum));
2073 for (i=0; i<nclusters; ++i)
2075 result_array_data[i] = PointerGetDatum(
GEOS2POSTGIS(geos_results[i], is3d));
2076 GEOSGeom_destroy(geos_results[i]);
2080 get_typlenbyvalalign(array->elemtype, &elmlen, &elmbyval, &elmalign);
2081 result = construct_array(result_array_data, nclusters, array->elemtype, elmlen, elmbyval, elmalign);
2085 elog(ERROR,
"clusterintersecting: Error constructing return-array");
2089 PG_RETURN_POINTER(
result);
char result[OUT_DOUBLE_BUFFER_SIZE]
void lwgeom_geos_error(const char *fmt,...)
int cluster_intersecting(GEOSGeometry **geoms, uint32_t num_geoms, GEOSGeometry ***clusterGeoms, uint32_t *num_clusters)
Takes an array of GEOSGeometry* and constructs an array of GEOSGeometry*, where each element in the c...
#define SRID_UNKNOWN
Unknown SRID value.
static uint32_t array_nelems_not_null(ArrayType *array)
GSERIALIZED * GEOS2POSTGIS(GEOSGeom geom, char want3d)
GEOSGeometry ** ARRAY2GEOS(ArrayType *array, uint32_t nelems, int *is3d, int *srid)