214{
215 WindowObject win_obj = PG_WINDOW_OBJECT();
216 uint32_t row = WinGetCurrentPosition(win_obj);
217 uint32_t ngeoms = WinGetPartitionRowCount(win_obj);
219
220 if (row == 0)
221 {
222 uint32_t i;
223 uint32_t* result_ids;
226 bool tolerance_is_null;
227 double tolerance = DatumGetFloat8(WinGetFuncArgCurrent(win_obj, 1, &tolerance_is_null));
228
229
230 if (tolerance_is_null || tolerance < 0)
231 {
232 lwpgerror("Tolerance must be a positive number, got %g", tolerance);
233 PG_RETURN_NULL();
234 }
235
237
240 for (i = 0; i < ngeoms; i++)
241 {
242 bool geom_is_null;
245
246 if (!geoms[i])
247 {
248 lwpgerror("Error reading geometry.");
249 PG_RETURN_NULL();
250 }
251 }
252
254
257
258 for (i = 0; i < ngeoms; i++)
259 {
261 }
263
265 {
267 lwpgerror("Error during clustering");
268 PG_RETURN_NULL();
269 }
270
272 for (i = 0; i < ngeoms; i++)
273 {
275 }
276
279 }
280
282 PG_RETURN_NULL();
283
285}
void lwgeom_geos_error(const char *fmt,...)
int union_dbscan(LWGEOM **geoms, uint32_t num_geoms, UNIONFIND *uf, double eps, uint32_t min_points, char **is_in_cluster_ret)
void lwgeom_free(LWGEOM *geom)
void * lwalloc(size_t size)
#define LW_TRUE
Return types for functions with status returns.
static LWGEOM * read_lwgeom_from_partition(WindowObject win_obj, uint32_t i, bool *is_null)
static cluster_context * fetch_cluster_context(WindowObject win_obj, uint32_t ngeoms)
void UF_destroy(UNIONFIND *uf)
UNIONFIND * UF_create(uint32_t N)
uint32_t * UF_get_collapsed_cluster_ids(UNIONFIND *uf, const char *is_in_cluster)
cluster_entry clusters[1]