Build a tree of nodes from a point array, one node per edge, and each with an associated measure range along a one-dimensional space.
We can then search that space as a range tree.
Definition at line 175 of file lwtree.c.
References lwalloc(), lwfree(), POINTARRAY::npoints, rect_node_internal_new(), and rect_node_leaf_new().
Referenced by test_rect_tree_contains_point(), and test_rect_tree_intersects_tree().
177 int num_edges, num_children, num_parents;
197 for ( i = 0; i < num_edges; i++ )
215 num_parents = num_children / 2;
216 while ( num_parents > 0 )
219 while ( j < num_parents )
230 if ( num_children % 2 )
232 nodes[j] = nodes[num_children - 1];
235 num_children = num_parents;
236 num_parents = num_children / 2;
RECT_NODE * rect_node_leaf_new(const POINTARRAY *pa, int i)
Create a new leaf node, calculating a measure value for each point on the edge and storing pointers b...
void * lwalloc(size_t size)
RECT_NODE * rect_node_internal_new(RECT_NODE *left_node, RECT_NODE *right_node)
Create a new internal node, calculating the new measure range for the node, and storing pointers to t...