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

◆ lwpoly_calculate_circ_tree()

static CIRC_NODE * lwpoly_calculate_circ_tree ( const LWPOLY lwpoly)
static

Definition at line 937 of file lwgeodetic_tree.c.

938{
939 uint32_t i = 0, j = 0;
940 CIRC_NODE** nodes;
941 CIRC_NODE* node;
942
943 /* One ring? Handle it like a line. */
944 if ( lwpoly->nrings == 1 )
945 {
946 node = circ_tree_new(lwpoly->rings[0]);
947 }
948 else
949 {
950 /* Calculate a tree for each non-trivial ring of the polygon */
951 nodes = lwalloc(lwpoly->nrings * sizeof(CIRC_NODE*));
952 for ( i = 0; i < lwpoly->nrings; i++ )
953 {
954 node = circ_tree_new(lwpoly->rings[i]);
955 if ( node )
956 nodes[j++] = node;
957 }
958 /* Put the trees into a spatially correlated order */
959 circ_nodes_sort(nodes, j);
960 /* Merge the trees pairwise up to a parent node and return */
961 node = circ_nodes_merge(nodes, j);
962 /* Don't need the working list any more */
963 lwfree(nodes);
964 }
965
966 /* Metadata about polygons, we need this to apply P-i-P tests */
967 /* selectively when doing distance calculations */
968 node->geom_type = lwgeom_get_type((LWGEOM*)lwpoly);
969 lwpoly_pt_outside(lwpoly, &(node->pt_outside));
970
971 return node;
972}
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:248
int lwpoly_pt_outside(const LWPOLY *poly, POINT2D *pt_outside)
CIRC_NODE * circ_tree_new(const POINTARRAY *pa)
Build a tree of nodes from a point array, one node per edge.
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 ...
static uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition lwinline.h:141
POINTARRAY ** rings
Definition liblwgeom.h:519
uint32_t nrings
Definition liblwgeom.h:524
POINT2D pt_outside
uint32_t geom_type
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.

References circ_nodes_merge(), circ_nodes_sort(), circ_tree_new(), circ_node::geom_type, lwalloc(), lwfree(), lwgeom_get_type(), lwpoly_pt_outside(), sort_node::node, LWPOLY::nrings, circ_node::pt_outside, and LWPOLY::rings.

Referenced by lwgeom_calculate_circ_tree().

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