PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ itree_from_multipolygon()

static IntervalTree* itree_from_multipolygon ( const LWMPOLY mpoly)
static

Definition at line 269 of file intervaltree.c.

270 {
271  IntervalTree *itree = lwalloc0(sizeof(IntervalTree));
272  if (mpoly->ngeoms == 0) return itree;
273 
274  itree->maxNodes = itree_num_nodes_multipolygon(mpoly);
275  itree->nodes = lwalloc0(itree->maxNodes * sizeof(IntervalTreeNode));
276  itree->numNodes = 0;
277 
278  itree->ringCounts = lwalloc0(mpoly->ngeoms * sizeof(uint32_t));
279  itree->indexes = lwalloc0(itree_num_rings(mpoly) * sizeof(IntervalTreeNode*));
280  itree->indexArrays = lwalloc0(itree_num_rings(mpoly) * sizeof(POINTARRAY*));
281 
282  for (uint32_t i = 0; i < mpoly->ngeoms; i++)
283  {
284  const LWPOLY *poly = mpoly->geoms[i];
285 
286  /* skip empty polygons */
287  if (! poly || lwpoly_is_empty(poly))
288  continue;
289 
290  for (uint32_t j = 0; j < poly->nrings; j++)
291  {
292  const POINTARRAY *pa = poly->rings[j];
293 
294  /* skip empty/unclosed/invalid rings */
295  if (!pa || pa->npoints < 4)
296  continue;
297 
298  itree_add_pointarray(itree, pa);
299 
300  itree->ringCounts[itree->numPolys] += 1;
301  }
302 
303  itree->numPolys += 1;
304  }
305  return itree;
306 }
static void itree_add_pointarray(IntervalTree *itree, const POINTARRAY *pa)
Definition: intervaltree.c:185
static uint32_t itree_num_rings(const LWMPOLY *mpoly)
Definition: intervaltree.c:93
static uint32_t itree_num_nodes_multipolygon(const LWMPOLY *mpoly)
Definition: intervaltree.c:81
void * lwalloc0(size_t sz)
Definition: lwutil.c:234
int lwpoly_is_empty(const LWPOLY *poly)
uint32_t maxNodes
Definition: intervaltree.h:65
struct IntervalTreeNode * nodes
Definition: intervaltree.h:58
uint32_t numNodes
Definition: intervaltree.h:64
struct IntervalTreeNode ** indexes
Definition: intervaltree.h:59
uint32_t * ringCounts
Definition: intervaltree.h:62
uint32_t numPolys
Definition: intervaltree.h:63
POINTARRAY ** indexArrays
Definition: intervaltree.h:60
uint32_t ngeoms
Definition: liblwgeom.h:566
LWPOLY ** geoms
Definition: liblwgeom.h:561
POINTARRAY ** rings
Definition: liblwgeom.h:519
uint32_t nrings
Definition: liblwgeom.h:524
uint32_t npoints
Definition: liblwgeom.h:427

References LWMPOLY::geoms, IntervalTree::indexArrays, IntervalTree::indexes, itree_add_pointarray(), itree_num_nodes_multipolygon(), itree_num_rings(), lwalloc0(), lwpoly_is_empty(), IntervalTree::maxNodes, LWMPOLY::ngeoms, IntervalTree::nodes, POINTARRAY::npoints, LWPOLY::nrings, IntervalTree::numNodes, IntervalTree::numPolys, IntervalTree::ringCounts, and LWPOLY::rings.

Referenced by itree_from_lwgeom().

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