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

◆ itree_from_polygon()

static IntervalTree * itree_from_polygon ( const LWPOLY poly)
static

Definition at line 238 of file intervaltree.c.

239{
240 IntervalTree *itree = lwalloc0(sizeof(IntervalTree));
241 if (poly->nrings == 0) return itree;
242
243 itree->maxNodes = itree_num_nodes_polygon(poly);
244 itree->nodes = lwalloc0(itree->maxNodes * sizeof(IntervalTreeNode));
245 itree->numNodes = 0;
246
247 itree->ringCounts = lwalloc0(sizeof(uint32_t));
248 itree->indexes = lwalloc0(poly->nrings * sizeof(IntervalTreeNode*));
249 itree->indexArrays = lwalloc0(poly->nrings * sizeof(POINTARRAY*));
250
251 for (uint32_t j = 0; j < poly->nrings; j++)
252 {
253 const POINTARRAY *pa = poly->rings[j];
254
255 /* skip empty/unclosed/invalid rings */
256 if (!pa || pa->npoints < 4)
257 continue;
258
259 itree_add_pointarray(itree, pa);
260
261 itree->ringCounts[itree->numPolys] += 1;
262 }
263 itree->numPolys = 1;
264 return itree;
265}
static void itree_add_pointarray(IntervalTree *itree, const POINTARRAY *pa)
static uint32_t itree_num_nodes_polygon(const LWPOLY *poly)
void * lwalloc0(size_t sz)
Definition lwutil.c:234
uint32_t maxNodes
struct IntervalTreeNode * nodes
uint32_t numNodes
struct IntervalTreeNode ** indexes
uint32_t * ringCounts
uint32_t numPolys
POINTARRAY ** indexArrays
POINTARRAY ** rings
Definition liblwgeom.h:519
uint32_t nrings
Definition liblwgeom.h:524
uint32_t npoints
Definition liblwgeom.h:427

References IntervalTree::indexArrays, IntervalTree::indexes, itree_add_pointarray(), itree_num_nodes_polygon(), lwalloc0(), IntervalTree::maxNodes, 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: