3192 Datum* result_array_data;
3193 ArrayType *array, *result;
3195 uint32 nelems, nclusters, i;
3196 GEOSGeometry **geos_inputs, **geos_results;
3205 if (PG_ARGISNULL(0))
3208 array = PG_GETARG_ARRAYTYPE_P(0);
3211 POSTGIS_DEBUGF(3,
"clusterintersecting_garray: number of non-null elements: %d", nelems);
3213 if ( nelems == 0 ) PG_RETURN_NULL();
3220 geos_inputs =
ARRAY2GEOS(array, nelems, &is3d, &srid);
3228 elog(ERROR,
"clusterintersecting: Error performing clustering");
3233 if (!geos_results) PG_RETURN_NULL();
3235 result_array_data = palloc(nclusters *
sizeof(Datum));
3236 for (i=0; i<nclusters; ++i)
3238 result_array_data[i] = PointerGetDatum(
GEOS2POSTGIS(geos_results[i], is3d));
3239 GEOSGeom_destroy(geos_results[i]);
3241 pfree(geos_results);
3243 get_typlenbyvalalign(array->elemtype, &elmlen, &elmbyval, &elmalign);
3244 result = (ArrayType*) construct_array(result_array_data, nclusters, array->elemtype, elmlen, elmbyval, elmalign);
3248 elog(ERROR,
"clusterintersecting: Error constructing return-array");
3252 PG_RETURN_POINTER(result);
GEOSGeometry ** ARRAY2GEOS(ArrayType *array, uint32_t nelems, int *is3d, int *srid)
uint32_t array_nelems_not_null(ArrayType *array)
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...
void lwgeom_geos_error(const char *fmt,...)
#define SRID_UNKNOWN
Unknown SRID value.
GSERIALIZED * GEOS2POSTGIS(GEOSGeom geom, char want3d)