PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ UF_get_collapsed_cluster_ids()

uint32_t * UF_get_collapsed_cluster_ids ( UNIONFIND uf,
const char *  is_in_cluster 
)

Definition at line 146 of file lwunionfind.c.

147{
148 uint32_t* ordered_components = UF_ordered_by_cluster(uf);
149 uint32_t* new_ids = lwalloc(uf->N * sizeof(uint32_t));
150 uint32_t last_old_id, current_new_id, i;
151 char encountered_cluster = LW_FALSE;
152
153 current_new_id = 0; last_old_id = 0;
154 for (i = 0; i < uf->N; i++)
155 {
156 uint32_t j = ordered_components[i];
157 if (!is_in_cluster || is_in_cluster[j])
158 {
159 uint32_t current_old_id = UF_find(uf, j);
160 if (!encountered_cluster)
161 {
162 encountered_cluster = LW_TRUE;
163 last_old_id = current_old_id;
164 }
165
166 if (current_old_id != last_old_id)
167 current_new_id++;
168
169 new_ids[j] = current_new_id;
170 last_old_id = current_old_id;
171 }
172 }
173
174 lwfree(ordered_components);
175
176 return new_ids;
177}
#define LW_FALSE
Definition liblwgeom.h:94
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:248
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
uint32_t UF_find(UNIONFIND *uf, uint32_t i)
Definition lwunionfind.c:62
uint32_t * UF_ordered_by_cluster(UNIONFIND *uf)
uint32_t N
Definition lwunionfind.h:36

References LW_FALSE, LW_TRUE, lwalloc(), lwfree(), UNIONFIND::N, UF_find(), and UF_ordered_by_cluster().

Referenced by do_dbscan_test(), ST_ClusterDBSCAN(), ST_ClusterIntersectingWin(), ST_ClusterWithinWin(), and test_unionfind_collapse_cluster_ids().

Here is the call graph for this function:
Here is the caller graph for this function: