PostGIS  2.3.7dev-r@@SVN_REVISION@@

◆ cluster_within_distance()

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 array is a GeometryCollection representing a set of geometries separated by no more than the specified tolerance.

Caller is responsible for freeing the input array, but not the LWGEOM* items inside it.

Definition at line 522 of file lwgeom_geos_cluster.c.

References combine_geometries(), LW_FAILURE, UF_create(), UF_destroy(), and union_dbscan().

Referenced by cluster_within_distance_garray(), and perform_cluster_within_distance_test().

523 {
524  int cluster_success;
525  UNIONFIND* uf = UF_create(num_geoms);
527  if (union_dbscan(geoms, num_geoms, uf, tolerance, 1, NULL) == LW_FAILURE)
528  {
529  UF_destroy(uf);
530  return LW_FAILURE;
531  }
533  cluster_success = combine_geometries(uf, (void**) geoms, num_geoms, (void***) clusterGeoms, num_clusters, 1);
534  UF_destroy(uf);
535  return cluster_success;
536 }
void UF_destroy(UNIONFIND *uf)
Definition: lwunionfind.c:53
#define LW_FAILURE
Definition: liblwgeom.h:78
UNIONFIND * UF_create(uint32_t N)
Definition: lwunionfind.c:34
static int combine_geometries(UNIONFIND *uf, void **geoms, uint32_t num_geoms, void ***clustersGeoms, uint32_t *num_clusters, char is_lwgeom)
Uses a UNIONFIND to identify the set with which each input geometry is associated, and groups the geometries into GeometryCollections.
int union_dbscan(LWGEOM **geoms, uint32_t num_geoms, UNIONFIND *uf, double eps, uint32_t min_points, char **in_a_cluster_ret)
Here is the call graph for this function:
Here is the caller graph for this function: