PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum geography_cmp ( PG_FUNCTION_ARGS  )

Definition at line 232 of file geography_btree.c.

References FALSE, FP_EQUALS, geography_gidx_center(), POINT3D::x, POINT3D::y, and POINT3D::z.

233 {
234  /* Put aside some stack memory and use it for GIDX pointers. */
235  char gboxmem1[GIDX_MAX_SIZE];
236  char gboxmem2[GIDX_MAX_SIZE];
237  GIDX *gbox1 = (GIDX*)gboxmem1;
238  GIDX *gbox2 = (GIDX*)gboxmem2;
239  POINT3D p1, p2;
240 
241  /* Must be able to build box for each argument (ie, not empty geometry) */
242  if ( ! gserialized_datum_get_gidx_p(PG_GETARG_DATUM(0), gbox1) ||
243  ! gserialized_datum_get_gidx_p(PG_GETARG_DATUM(1), gbox2) )
244  {
245  PG_RETURN_BOOL(FALSE);
246  }
247 
248  geography_gidx_center(gbox1, &p1);
249  geography_gidx_center(gbox2, &p2);
250 
251  if ( ! FP_EQUALS(p1.x, p2.x) )
252  {
253  if (p1.x < p2.x)
254  {
255  PG_RETURN_INT32(-1);
256  }
257  PG_RETURN_INT32(1);
258  }
259 
260  if ( ! FP_EQUALS(p1.y, p2.y) )
261  {
262  if (p1.y < p2.y)
263  {
264  PG_RETURN_INT32(-1);
265  }
266  PG_RETURN_INT32(1);
267  }
268 
269  if ( ! FP_EQUALS(p1.z, p2.z) )
270  {
271  if (p1.z < p2.z)
272  {
273  PG_RETURN_INT32(-1);
274  }
275  PG_RETURN_INT32(1);
276  }
277 
278  PG_RETURN_INT32(0);
279 }
double y
Definition: liblwgeom.h:324
double x
Definition: liblwgeom.h:324
double z
Definition: liblwgeom.h:324
static void geography_gidx_center(GIDX *gidx, POINT3D *p)
#define FALSE
Definition: dbfopen.c:168
#define FP_EQUALS(A, B)

Here is the call graph for this function: