PostGIS  2.2.8dev-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 116 of file lwgeodetic_tree.c.

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

Referenced by circ_nodes_sort().

117 {
118  POINT2D p1, p2;
119  unsigned int u1, u2;
120  CIRC_NODE *c1 = *((CIRC_NODE**)v1);
121  CIRC_NODE *c2 = *((CIRC_NODE**)v2);
122  p1.x = rad2deg((c1->center).lon);
123  p1.y = rad2deg((c1->center).lat);
124  p2.x = rad2deg((c2->center).lon);
125  p2.y = rad2deg((c2->center).lat);
126  u1 = geohash_point_as_int(&p1);
127  u2 = geohash_point_as_int(&p2);
128  if ( u1 < u2 ) return -1;
129  if ( u1 > u2 ) return 1;
130  return 0;
131 }
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.
GEOGRAPHIC_POINT center
double x
Definition: liblwgeom.h:312
#define rad2deg(r)
Definition: lwgeodetic.h:60
double y
Definition: liblwgeom.h:312
unsigned int geohash_point_as_int(POINT2D *pt)
Definition: lwalgorithm.c:633
Here is the call graph for this function:
Here is the caller graph for this function: