PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ circ_internal_nodes_sort()

static void circ_internal_nodes_sort ( CIRC_NODE **  nodes,
uint32_t  num_nodes,
const CIRC_NODE target_node 
)
static

Definition at line 652 of file lwgeodetic_tree.c.

653 {
654  uint32_t i;
655  struct sort_node sort_nodes[CIRC_NODE_SIZE];
656 
657  /* Copy incoming nodes into sorting array and calculate */
658  /* distance to the target node */
659  for (i = 0; i < num_nodes; i++)
660  {
661  sort_nodes[i].node = nodes[i];
662  sort_nodes[i].d = sphere_distance(&(nodes[i]->center), &(target_node->center));
663  }
664 
665  /* Sort the nodes and copy the result back into the input array */
666  qsort(sort_nodes, num_nodes, sizeof(struct sort_node), circ_nodes_sort_cmp);
667  for (i = 0; i < num_nodes; i++)
668  {
669  nodes[i] = sort_nodes[i].node;
670  }
671  return;
672 }
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
Definition: lwgeodetic.c:896
static int circ_nodes_sort_cmp(const void *a, const void *b)
#define CIRC_NODE_SIZE
GEOGRAPHIC_POINT center
CIRC_NODE * node

References circ_node::center, CIRC_NODE_SIZE, circ_nodes_sort_cmp(), sort_node::d, sort_node::node, and sphere_distance().

Referenced by circ_tree_distance_tree_internal().

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