3258 Datum* result_array_data;
3259 ArrayType *array, *result;
3261 uint32 nelems, nclusters, i;
3273 if (PG_ARGISNULL(0))
3276 array = PG_GETARG_ARRAYTYPE_P(0);
3278 tolerance = PG_GETARG_FLOAT8(1);
3281 lwpgerror(
"Tolerance must be a positive number.");
3287 POSTGIS_DEBUGF(3,
"cluster_within_distance_garray: number of non-null elements: %d", nelems);
3289 if ( nelems == 0 ) PG_RETURN_NULL();
3304 elog(ERROR,
"cluster_within: Error performing clustering");
3309 if (!lw_results) PG_RETURN_NULL();
3311 result_array_data = palloc(nclusters *
sizeof(Datum));
3312 for (i=0; i<nclusters; ++i)
3319 get_typlenbyvalalign(array->elemtype, &elmlen, &elmbyval, &elmalign);
3320 result = (ArrayType*) construct_array(result_array_data, nclusters, array->elemtype, elmlen, elmbyval, elmalign);
3324 elog(ERROR,
"clusterwithin: Error constructing return-array");
3328 PG_RETURN_POINTER(result);
uint32_t array_nelems_not_null(ArrayType *array)
void lwgeom_free(LWGEOM *geom)
int cluster_within_distance(LWGEOM **geoms, uint32_t num_geoms, double tolerance, LWGEOM ***clusterGeoms, uint32_t *num_clusters)
Takes an array of LWGEOM* and constructs an array of LWGEOM*, where each element in the constructed a...
LWGEOM ** ARRAY2LWGEOM(ArrayType *array, uint32_t nelems, int *is3d, int *srid)
void lwgeom_geos_error(const char *fmt,...)
#define SRID_UNKNOWN
Unknown SRID value.
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.