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

◆ 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
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)
static uint32_t itree_num_rings(const LWMPOLY *mpoly)
static uint32_t itree_num_nodes_multipolygon(const LWMPOLY *mpoly)
void * lwalloc0(size_t sz)
Definition lwutil.c:234
int lwpoly_is_empty(const LWPOLY *poly)
uint32_t maxNodes
struct IntervalTreeNode * nodes
uint32_t numNodes
struct IntervalTreeNode ** indexes
uint32_t * ringCounts
uint32_t numPolys
POINTARRAY ** indexArrays
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: