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

◆ circ_nodes_merge()

static CIRC_NODE * circ_nodes_merge ( CIRC_NODE **  nodes,
int  num_nodes 
)
static

Definition at line 409 of file lwgeodetic_tree.c.

410{
411 CIRC_NODE **inodes = NULL;
412 int num_children = num_nodes;
413 int inode_num = 0;
414 int num_parents = 0;
415 int j;
416
417 /* TODO, roll geom_type *up* as tree is built, changing to collection types as simple types are merged
418 * TODO, change the distance algorithm to drive down to simple types first, test pip on poly/other cases, then test edges
419 */
420
421 while( num_children > 1 )
422 {
423 for ( j = 0; j < num_children; j++ )
424 {
425 inode_num = (j % CIRC_NODE_SIZE);
426 if ( inode_num == 0 )
427 inodes = lwalloc(sizeof(CIRC_NODE*)*CIRC_NODE_SIZE);
428
429 inodes[inode_num] = nodes[j];
430
431 if ( inode_num == CIRC_NODE_SIZE-1 )
432 nodes[num_parents++] = circ_node_internal_new(inodes, CIRC_NODE_SIZE);
433 }
434
435 /* Clean up any remaining nodes... */
436 if ( inode_num == 0 )
437 {
438 /* Promote solo nodes without merging */
439 nodes[num_parents++] = inodes[0];
440 lwfree(inodes);
441 }
442 else if ( inode_num < CIRC_NODE_SIZE-1 )
443 {
444 /* Merge spare nodes */
445 nodes[num_parents++] = circ_node_internal_new(inodes, inode_num+1);
446 }
447
448 num_children = num_parents;
449 num_parents = 0;
450 }
451
452 /* Return a reference to the head of the tree */
453 return nodes[0];
454}
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:248
static CIRC_NODE * circ_node_internal_new(CIRC_NODE **c, uint32_t num_nodes)
Create a new internal node, calculating the new measure range for the node, and storing pointers to t...
#define CIRC_NODE_SIZE
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.

References circ_node_internal_new(), CIRC_NODE_SIZE, lwalloc(), and lwfree().

Referenced by circ_tree_new(), lwcollection_calculate_circ_tree(), and lwpoly_calculate_circ_tree().

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