397 .num_items_found = 0,
398 .items_found_size = 0
405 in_a_cluster =
lwalloc(num_geoms *
sizeof(
char));
406 memset(in_a_cluster, 0, num_geoms *
sizeof(
char));
408 if (in_a_cluster_ret)
409 *in_a_cluster_ret = in_a_cluster;
412 if (num_geoms < min_points)
414 if (!in_a_cluster_ret)
420 if (tree.tree == NULL)
426 is_in_core =
lwalloc(num_geoms *
sizeof(
char));
427 memset(is_in_core, 0, num_geoms *
sizeof(
char));
428 neighbors =
lwalloc(min_points *
sizeof(uint32_t));
430 for (p = 0; p < num_geoms; p++)
432 uint32_t num_neighbors = 0;
453 if (num_neighbors >= min_points)
465 if (in_a_cluster[q] && !is_in_core[q])
470 if (mindist == FLT_MAX)
481 if (num_neighbors < min_points)
483 neighbors[num_neighbors++] = q;
488 if (num_neighbors == min_points)
493 for (j = 0; j < num_neighbors; j++)
518 if (!in_a_cluster_ret)
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
void * lwalloc(size_t size)
#define LW_TRUE
Return types for functions with status returns.
static int dbscan_update_context(GEOSSTRtree *tree, struct QueryContext *cxt, LWGEOM **geoms, uint32_t p, double eps)
static struct STRTree make_strtree(void **geoms, uint32_t num_geoms, char is_lwgeom)
Make a GEOSSTRtree that stores a pointer to a variable containing the array index of the input geoms.
static void destroy_strtree(struct STRTree *tree)
Clean up STRTree after use.
static void union_if_available(UNIONFIND *uf, uint32_t p, uint32_t q, char *is_in_core, char *in_a_cluster)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
uint32_t UF_find(UNIONFIND *uf, uint32_t i)