PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ rect_tree_node_sort()

static void rect_tree_node_sort ( RECT_NODE n1,
RECT_NODE n2 
)
static

Definition at line 1248 of file lwtree.c.

1249 {
1250  int i;
1251  RECT_NODE *n;
1252  POINT2D c1, c2, c;
1253  if (!rect_node_is_leaf(n1) && ! n1->i.sorted)
1254  {
1255  rect_node_to_p2d(n2, &c2);
1256  /* Distance of each child from center of other node */
1257  for (i = 0; i < n1->i.num_nodes; i++)
1258  {
1259  n = n1->i.nodes[i];
1260  rect_node_to_p2d(n, &c);
1261  n->d = distance2d_sqr_pt_pt(&c2, &c);
1262  }
1263  /* Sort the children by distance */
1264  n1->i.sorted = 1;
1265  qsort(n1->i.nodes,
1266  n1->i.num_nodes,
1267  sizeof(RECT_NODE*),
1269  }
1270  if (!rect_node_is_leaf(n2) && ! n2->i.sorted)
1271  {
1272  rect_node_to_p2d(n1, &c1);
1273  /* Distance of each child from center of other node */
1274  for (i = 0; i < n2->i.num_nodes; i++)
1275  {
1276  n = n2->i.nodes[i];
1277  rect_node_to_p2d(n, &c);
1278  n->d = distance2d_sqr_pt_pt(&c1, &c);
1279  }
1280  /* Sort the children by distance */
1281  n2->i.sorted = 1;
1282  qsort(n2->i.nodes,
1283  n2->i.num_nodes,
1284  sizeof(RECT_NODE*),
1286  }
1287 }
double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
Definition: measures.c:2323
static int rect_tree_node_sort_cmp(const void *a, const void *b)
Definition: lwtree.c:1226
static int rect_node_is_leaf(const RECT_NODE *node)
Definition: lwtree.c:31
static void rect_node_to_p2d(const RECT_NODE *n, POINT2D *pt)
Definition: lwtree.c:1237
struct rect_node * nodes[RECT_NODE_SIZE]
Definition: lwtree.h:61
RECT_NODE_INTERNAL i
Definition: lwtree.h:75
double d
Definition: lwtree.h:73

References rect_node::d, distance2d_sqr_pt_pt(), rect_node::i, RECT_NODE_INTERNAL::nodes, RECT_NODE_INTERNAL::num_nodes, rect_node_is_leaf(), rect_node_to_p2d(), rect_tree_node_sort_cmp(), and RECT_NODE_INTERNAL::sorted.

Referenced by rect_tree_distance_tree_recursive().

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