PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ circ_nodes_merge()

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

Definition at line 410 of file lwgeodetic_tree.c.

411 {
412  CIRC_NODE **inodes = NULL;
413  int num_children = num_nodes;
414  int inode_num = 0;
415  int num_parents = 0;
416  int j;
417 
418  /* TODO, roll geom_type *up* as tree is built, changing to collection types as simple types are merged
419  * TODO, change the distance algorithm to drive down to simple types first, test pip on poly/other cases, then test edges
420  */
421 
422  while( num_children > 1 )
423  {
424  for ( j = 0; j < num_children; j++ )
425  {
426  inode_num = (j % CIRC_NODE_SIZE);
427  if ( inode_num == 0 )
428  inodes = lwalloc(sizeof(CIRC_NODE*)*CIRC_NODE_SIZE);
429 
430  inodes[inode_num] = nodes[j];
431 
432  if ( inode_num == CIRC_NODE_SIZE-1 )
433  nodes[num_parents++] = circ_node_internal_new(inodes, CIRC_NODE_SIZE);
434  }
435 
436  /* Clean up any remaining nodes... */
437  if ( inode_num == 0 )
438  {
439  /* Promote solo nodes without merging */
440  nodes[num_parents++] = inodes[0];
441  lwfree(inodes);
442  }
443  else if ( inode_num < CIRC_NODE_SIZE-1 )
444  {
445  /* Merge spare nodes */
446  nodes[num_parents++] = circ_node_internal_new(inodes, inode_num+1);
447  }
448 
449  num_children = num_parents;
450  num_parents = 0;
451  }
452 
453  /* Return a reference to the head of the tree */
454  return nodes[0];
455 }
void lwfree(void *mem)
Definition: lwutil.c:244
void * lwalloc(size_t size)
Definition: lwutil.c:229
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: