PostGIS  2.5.7dev-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 638 of file lwgeodetic_tree.c.

639 {
640  uint32_t i;
641  struct sort_node sort_nodes[CIRC_NODE_SIZE];
642 
643  /* Copy incoming nodes into sorting array and calculate */
644  /* distance to the target node */
645  for (i = 0; i < num_nodes; i++)
646  {
647  sort_nodes[i].node = nodes[i];
648  sort_nodes[i].d = sphere_distance(&(nodes[i]->center), &(target_node->center));
649  }
650 
651  /* Sort the nodes and copy the result back into the input array */
652  qsort(sort_nodes, num_nodes, sizeof(struct sort_node), circ_nodes_sort_cmp);
653  for (i = 0; i < num_nodes; i++)
654  {
655  nodes[i] = sort_nodes[i].node;
656  }
657  return;
658 }
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:948
static int circ_nodes_sort_cmp(const void *a, const void *b)
#define CIRC_NODE_SIZE
GEOGRAPHIC_POINT center
CIRC_NODE * node
unsigned int uint32_t
Definition: uthash.h:78

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: