PostGIS  3.0.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 625 of file lwgeodetic_tree.c.

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

Referenced by circ_tree_distance_tree_internal().

626 {
627  uint32_t i;
628  struct sort_node sort_nodes[CIRC_NODE_SIZE];
629 
630  /* Copy incoming nodes into sorting array and calculate */
631  /* distance to the target node */
632  for (i = 0; i < num_nodes; i++)
633  {
634  sort_nodes[i].node = nodes[i];
635  sort_nodes[i].d = sphere_distance(&(nodes[i]->center), &(target_node->center));
636  }
637 
638  /* Sort the nodes and copy the result back into the input array */
639  qsort(sort_nodes, num_nodes, sizeof(struct sort_node), circ_nodes_sort_cmp);
640  for (i = 0; i < num_nodes; i++)
641  {
642  nodes[i] = sort_nodes[i].node;
643  }
644  return;
645 }
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:917
#define CIRC_NODE_SIZE
GEOGRAPHIC_POINT center
unsigned int uint32_t
Definition: uthash.h:78
static int circ_nodes_sort_cmp(const void *a, const void *b)
CIRC_NODE * node
Here is the call graph for this function:
Here is the caller graph for this function: