PostGIS  2.3.8dev-r@@SVN_REVISION@@

## ◆ lwcollection_calculate_circ_tree()

 static CIRC_NODE* lwcollection_calculate_circ_tree ( const LWCOLLECTION * lwcol )
static

Definition at line 896 of file lwgeodetic_tree.c.

Referenced by lwgeom_calculate_circ_tree().

897 {
898  int i = 0, j = 0;
899  CIRC_NODE** nodes;
900  CIRC_NODE* node;
901
902  /* One geometry? Done! */
903  if ( lwcol->ngeoms == 1 )
904  return lwgeom_calculate_circ_tree(lwcol->geoms[0]);
905
906  /* Calculate a tree for each sub-geometry*/
907  nodes = lwalloc(lwcol->ngeoms * sizeof(CIRC_NODE*));
908  for ( i = 0; i < lwcol->ngeoms; i++ )
909  {
910  node = lwgeom_calculate_circ_tree(lwcol->geoms[i]);
911  if ( node )
912  nodes[j++] = node;
913  }
914  /* Put the trees into a spatially correlated order */
915  circ_nodes_sort(nodes, j);
916  /* Merge the trees pairwise up to a parent node and return */
917  node = circ_nodes_merge(nodes, j);
918  /* Don't need the working list any more */
919  lwfree(nodes);
920  node->geom_type = lwgeom_get_type((LWGEOM*)lwcol);
921  return node;
922 }
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.
void lwfree(void *mem)
Definition: lwutil.c:242
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition: lwgeom.c:842
CIRC_NODE * lwgeom_calculate_circ_tree(const LWGEOM *lwgeom)
LWGEOM ** geoms
Definition: liblwgeom.h:508
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:227
Here is the call graph for this function:
Here is the caller graph for this function: