PostGIS  2.5.1dev-r@@SVN_REVISION@@

## ◆ lwcollection_calculate_circ_tree()

 static CIRC_NODE* lwcollection_calculate_circ_tree ( const LWCOLLECTION * lwcol )
static

Definition at line 947 of file lwgeodetic_tree.c.

Referenced by lwgeom_calculate_circ_tree().

948 {
949  uint32_t i = 0, j = 0;
950  CIRC_NODE** nodes;
951  CIRC_NODE* node;
952
953  /* One geometry? Done! */
954  if ( lwcol->ngeoms == 1 )
955  return lwgeom_calculate_circ_tree(lwcol->geoms[0]);
956
957  /* Calculate a tree for each sub-geometry*/
958  nodes = lwalloc(lwcol->ngeoms * sizeof(CIRC_NODE*));
959  for ( i = 0; i < lwcol->ngeoms; i++ )
960  {
961  node = lwgeom_calculate_circ_tree(lwcol->geoms[i]);
962  if ( node )
963  nodes[j++] = node;
964  }
965  /* Put the trees into a spatially correlated order */
966  circ_nodes_sort(nodes, j);
967  /* Merge the trees pairwise up to a parent node and return */
968  node = circ_nodes_merge(nodes, j);
969  /* Don't need the working list any more */
970  lwfree(nodes);
971  node->geom_type = lwgeom_get_type((LWGEOM*)lwcol);
972  return node;
973 }
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.
uint32_t geom_type
void lwfree(void *mem)
Definition: lwutil.c:244
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition: lwgeom.c:923
uint32_t ngeoms
Definition: liblwgeom.h:509
CIRC_NODE * lwgeom_calculate_circ_tree(const LWGEOM *lwgeom)
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM ** geoms
Definition: liblwgeom.h:511
static CIRC_NODE * circ_nodes_merge(CIRC_NODE **nodes, int num_nodes)
static void circ_nodes_sort(CIRC_NODE **nodes, int num_nodes)
Given a list of nodes, sort them into a spatially consistent order, then pairwise merge them up into ...
void * lwalloc(size_t size)
Definition: lwutil.c:229
CIRC_NODE * node
Here is the call graph for this function:
Here is the caller graph for this function: