PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ circ_node_compare()

static int circ_node_compare ( const void *  v1,
const void *  v2 
)
static

Comparing on geohash ensures that nearby nodes will be close to each other in the list.

Definition at line 141 of file lwgeodetic_tree.c.

References circ_node::center, geohash_point_as_int(), rad2deg, POINT2D::x, and POINT2D::y.

Referenced by circ_nodes_sort().

142 {
143  POINT2D p1, p2;
144  unsigned int u1, u2;
145  CIRC_NODE *c1 = *((CIRC_NODE**)v1);
146  CIRC_NODE *c2 = *((CIRC_NODE**)v2);
147  p1.x = rad2deg((c1->center).lon);
148  p1.y = rad2deg((c1->center).lat);
149  p2.x = rad2deg((c2->center).lon);
150  p2.y = rad2deg((c2->center).lat);
151  u1 = geohash_point_as_int(&p1);
152  u2 = geohash_point_as_int(&p2);
153  if ( u1 < u2 ) return -1;
154  if ( u1 > u2 ) return 1;
155  return 0;
156 }
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.
GEOGRAPHIC_POINT center
double x
Definition: liblwgeom.h:328
#define rad2deg(r)
Definition: lwgeodetic.h:80
double y
Definition: liblwgeom.h:328
unsigned int geohash_point_as_int(POINT2D *pt)
Definition: lwalgorithm.c:647
Here is the call graph for this function:
Here is the caller graph for this function: