PostGIS  2.3.7dev-r@@SVN_REVISION@@
 static CIRC_NODE* lwpoly_calculate_circ_tree ( const LWPOLY * lwpoly )
static

Definition at line 858 of file lwgeodetic_tree.c.

Referenced by lwgeom_calculate_circ_tree().

859 {
860  int i = 0, j = 0;
861  CIRC_NODE** nodes;
862  CIRC_NODE* node;
863
864  /* One ring? Handle it like a line. */
865  if ( lwpoly->nrings == 1 )
866  {
867  node = circ_tree_new(lwpoly->rings[0]);
868  }
869  else
870  {
871  /* Calculate a tree for each non-trivial ring of the polygon */
872  nodes = lwalloc(lwpoly->nrings * sizeof(CIRC_NODE*));
873  for ( i = 0; i < lwpoly->nrings; i++ )
874  {
875  node = circ_tree_new(lwpoly->rings[i]);
876  if ( node )
877  nodes[j++] = node;
878  }
879  /* Put the trees into a spatially correlated order */
880  circ_nodes_sort(nodes, j);
881  /* Merge the trees pairwise up to a parent node and return */
882  node = circ_nodes_merge(nodes, j);
883  /* Don't need the working list any more */
884  lwfree(nodes);
885  }
886
887  /* Metatdata about polygons, we need this to apply P-i-P tests */
888  /* selectively when doing distance calculations */
889  node->geom_type = lwgeom_get_type((LWGEOM*)lwpoly);
890  lwpoly_pt_outside(lwpoly, &(node->pt_outside));
891
892  return node;
893 }
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 * circ_tree_new(const POINTARRAY *pa)
Build a tree of nodes from a point array, one node per edge.
POINTARRAY ** rings
Definition: liblwgeom.h:456
void lwpoly_pt_outside(const LWPOLY *poly, POINT2D *pt_outside)
Definition: lwgeodetic.c:1440
static CIRC_NODE * circ_nodes_merge(CIRC_NODE **nodes, int num_nodes)
int nrings
Definition: liblwgeom.h:454
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 ...
POINT2D pt_outside
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: