PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ rect_tree_from_lwcurvepoly()

static RECT_NODE* rect_tree_from_lwcurvepoly ( const LWGEOM lwgeom)
static

Definition at line 772 of file lwtree.c.

773 {
774  RECT_NODE **nodes;
775  RECT_NODE *tree;
776  uint32_t i, j = 0;
777  const LWCURVEPOLY *lwcol = (const LWCURVEPOLY*)lwgeom;
778 
779  if (lwcol->nrings < 1)
780  return NULL;
781 
782  nodes = lwalloc(sizeof(RECT_NODE*) * lwcol->nrings);
783  for (i = 0; i < lwcol->nrings; i++)
784  {
785  RECT_NODE *node = rect_tree_from_lwgeom(lwcol->rings[i]);
786  if (node)
787  {
788  /*
789  * In the case of arc circle, it's possible for a ring to consist
790  * of a single closed edge. That will arrive as a leaf node. We
791  * need to wrap that node in an internal node with an appropriate
792  * ring type so all the other code can try and make sense of it.
793  */
794  if (node->type == RECT_NODE_LEAF_TYPE)
795  {
796  RECT_NODE *internal = rect_node_internal_new(node);
797  rect_node_internal_add_node(internal, node);
798  node = internal;
799  }
800  /* Each subcomponent is a ring */
802  nodes[j++] = node;
803  }
804  }
805  /* Put the top nodes in a z-order curve for a spatially coherent */
806  /* tree after node merge */
807  qsort(nodes, j, sizeof(RECT_NODE*), rect_node_cmp);
808 
809  tree = rect_nodes_merge(nodes, j);
810 
811  tree->geom_type = lwgeom->type;
812  lwfree(nodes);
813  return tree;
814 
815 }
void lwfree(void *mem)
Definition: lwutil.c:244
void * lwalloc(size_t size)
Definition: lwutil.c:229
RECT_NODE * rect_tree_from_lwgeom(const LWGEOM *lwgeom)
Create a tree index on top an LWGEOM.
Definition: lwtree.c:861
static RECT_NODE * rect_nodes_merge(RECT_NODE **nodes, uint32_t num_nodes)
Definition: lwtree.c:596
static int rect_node_cmp(const void *pn1, const void *pn2)
Definition: lwtree.c:41
static void rect_node_internal_add_node(RECT_NODE *node, RECT_NODE *add)
Definition: lwtree.c:556
static RECT_NODE * rect_node_internal_new(const RECT_NODE *seed)
Definition: lwtree.c:570
@ RECT_NODE_LEAF_TYPE
Definition: lwtree.h:30
@ RECT_NODE_RING_EXTERIOR
Definition: lwtree.h:36
@ RECT_NODE_RING_INTERIOR
Definition: lwtree.h:37
LWGEOM ** rings
Definition: liblwgeom.h:538
uint32_t nrings
Definition: liblwgeom.h:536
uint8_t type
Definition: liblwgeom.h:399
RECT_NODE_RING_TYPE ring_type
Definition: lwtree.h:60
RECT_NODE_TYPE type
Definition: lwtree.h:67
RECT_NODE_INTERNAL i
Definition: lwtree.h:75
unsigned char geom_type
Definition: lwtree.h:68
unsigned int uint32_t
Definition: uthash.h:78

References rect_node::geom_type, rect_node::i, lwalloc(), lwfree(), LWCURVEPOLY::nrings, rect_node_cmp(), rect_node_internal_add_node(), rect_node_internal_new(), RECT_NODE_LEAF_TYPE, RECT_NODE_RING_EXTERIOR, RECT_NODE_RING_INTERIOR, rect_nodes_merge(), rect_tree_from_lwgeom(), RECT_NODE_INTERNAL::ring_type, LWCURVEPOLY::rings, LWGEOM::type, and rect_node::type.

Referenced by rect_tree_from_lwgeom().

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