PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ union_intersecting_pairs()

static int union_intersecting_pairs ( GEOSGeometry **  geoms,
uint32_t  num_geoms,
UNIONFIND uf 
)
static

Definition at line 189 of file lwgeom_geos_cluster.c.

References destroy_strtree(), UnionIfIntersectingContext::error, LW_FAILURE, LW_SUCCESS, make_strtree(), STRTree::num_geoms, UnionIfIntersectingContext::prep, STRTree::tree, UnionIfIntersectingContext::uf, and union_if_intersecting().

Referenced by cluster_intersecting().

190 {
191  uint32_t i;
192 
193  if (num_geoms <= 1)
194  {
195  return LW_SUCCESS;
196  }
197 
198  struct STRTree tree = make_strtree((void**) geoms, num_geoms, 0);
199  if (tree.tree == NULL)
200  {
201  destroy_strtree(tree);
202  return LW_FAILURE;
203  }
204  for (i = 0; i < num_geoms; i++)
205  {
206  if (GEOSisEmpty(geoms[i]))
207  {
208  continue;
209  }
210 
211  struct UnionIfIntersectingContext cxt =
212  {
213  .uf = uf,
214  .error = 0,
215  .p = &i,
216  .prep = NULL,
217  .geoms = geoms
218  };
219  GEOSGeometry* query_envelope = GEOSEnvelope(geoms[i]);
220  GEOSSTRtree_query(tree.tree, query_envelope, &union_if_intersecting, &cxt);
221 
222  GEOSGeom_destroy(query_envelope);
223  GEOSPreparedGeom_destroy(cxt.prep);
224  if (cxt.error)
225  {
226  return LW_FAILURE;
227  }
228  }
229 
230  destroy_strtree(tree);
231  return LW_SUCCESS;
232 }
static void destroy_strtree(struct STRTree tree)
Clean up STRTree after use.
const GEOSPreparedGeometry * prep
#define LW_SUCCESS
Definition: liblwgeom.h:65
static void union_if_intersecting(void *item, void *userdata)
GEOSSTRtree * tree
#define LW_FAILURE
Definition: liblwgeom.h:64
static struct STRTree make_strtree(void **geoms, uint32_t num_geoms, char is_lwgeom)
Make a GEOSSTRtree of either GEOSGeometry* or LWGEOM* pointers.
uint32_t num_geoms
Here is the call graph for this function:
Here is the caller graph for this function: