391{
392 uint32_t p, i;
395 {
397 .num_items_found = 0,
398 .items_found_size = 0
399 };
401 uint32_t* neighbors;
402 char* in_a_cluster;
403 char* is_in_core;
404
405 in_a_cluster =
lwalloc(num_geoms *
sizeof(
char));
406 memset(in_a_cluster, 0, num_geoms * sizeof(char));
407
408 if (in_a_cluster_ret)
409 *in_a_cluster_ret = in_a_cluster;
410
411
412 if (num_geoms < min_points)
413 {
414 if (!in_a_cluster_ret)
417 }
418
420 if (tree.tree == NULL)
421 {
424 }
425
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));
429
430 for (p = 0; p < num_geoms; p++)
431 {
432 uint32_t num_neighbors = 0;
433 int rv;
434
436 continue;
437
440 {
443 }
444
445
447 continue;
448
450 {
452
453 if (num_neighbors >= min_points)
454 {
455
456
457
458
460 continue;
461
462
463
464
465 if (in_a_cluster[q] && !is_in_core[q])
466 continue;
467 }
468
470 if (mindist == FLT_MAX)
471 {
473 break;
474 }
475
476 if (mindist <= eps)
477 {
478
479
480
481 if (num_neighbors < min_points)
482 {
483 neighbors[num_neighbors++] = q;
484
485
486
487
488 if (num_neighbors == min_points)
489 {
490 uint32_t j;
493 for (j = 0; j < num_neighbors; j++)
494 {
496 }
497 }
498 }
499 else
500 {
501
502
503
504
506 }
507 }
508 }
509
510 if (!success)
511 break;
512 }
513
516
517
518 if (!in_a_cluster_ret)
520
523
525 return success;
526}
void * lwalloc(size_t size)
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
#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)