383{
384 uint32_t p, i;
387 {
389 .num_items_found = 0,
390 .items_found_size = 0
391 };
393 uint32_t* neighbors;
394 char* in_a_cluster;
395 char* is_in_core;
396
397 in_a_cluster =
lwalloc(num_geoms *
sizeof(
char));
398 memset(in_a_cluster, 0, num_geoms * sizeof(char));
399
400 if (in_a_cluster_ret)
401 *in_a_cluster_ret = in_a_cluster;
402
403
404 if (num_geoms < min_points)
405 {
406 if (!in_a_cluster_ret)
409 }
410
412 if (tree.tree == NULL)
413 {
416 }
417
418 is_in_core =
lwalloc(num_geoms *
sizeof(
char));
419 memset(is_in_core, 0, num_geoms * sizeof(char));
420 neighbors =
lwalloc(min_points *
sizeof(uint32_t));
421
422 for (p = 0; p < num_geoms; p++)
423 {
424 uint32_t num_neighbors = 0;
425
427 continue;
428
430
431
433 continue;
434
436 {
438
439 if (num_neighbors >= min_points)
440 {
441
442
443
444
446 continue;
447
448
449
450
451 if (in_a_cluster[q] && !is_in_core[q])
452 continue;
453 }
454
456 if (mindist == FLT_MAX)
457 {
459 break;
460 }
461
462 if (mindist <= eps)
463 {
464
465
466
467 if (num_neighbors < min_points)
468 {
469 neighbors[num_neighbors++] = q;
470
471
472
473
474 if (num_neighbors == min_points)
475 {
476 uint32_t j;
479 for (j = 0; j < num_neighbors; j++)
480 {
482 }
483 }
484 }
485 else
486 {
487
488
489
490
492 }
493 }
494 }
495
496 if (!success)
497 break;
498 }
499
502
503
504 if (!in_a_cluster_ret)
506
509
511 return success;
512}
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)