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

Definition at line 247 of file geography_btree.c.

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

248 {
249  /* Put aside some stack memory and use it for GIDX pointers. */
250  char gboxmem1[GIDX_MAX_SIZE];
251  char gboxmem2[GIDX_MAX_SIZE];
252  GIDX *gbox1 = (GIDX*)gboxmem1;
253  GIDX *gbox2 = (GIDX*)gboxmem2;
254  POINT3D p1, p2;
255 
256  /* Must be able to build box for each argument (ie, not empty geometry) */
257  if ( ! gserialized_datum_get_gidx_p(PG_GETARG_DATUM(0), gbox1) ||
258  ! gserialized_datum_get_gidx_p(PG_GETARG_DATUM(1), gbox2) )
259  {
260  PG_RETURN_BOOL(FALSE);
261  }
262 
263  geography_gidx_center(gbox1, &p1);
264  geography_gidx_center(gbox2, &p2);
265 
266  if ( ! FP_EQUALS(p1.x, p2.x) )
267  {
268  if (p1.x < p2.x)
269  {
270  PG_RETURN_INT32(-1);
271  }
272  PG_RETURN_INT32(1);
273  }
274 
275  if ( ! FP_EQUALS(p1.y, p2.y) )
276  {
277  if (p1.y < p2.y)
278  {
279  PG_RETURN_INT32(-1);
280  }
281  PG_RETURN_INT32(1);
282  }
283 
284  if ( ! FP_EQUALS(p1.z, p2.z) )
285  {
286  if (p1.z < p2.z)
287  {
288  PG_RETURN_INT32(-1);
289  }
290  PG_RETURN_INT32(1);
291  }
292 
293  PG_RETURN_INT32(0);
294 }
double y
Definition: liblwgeom.h:339
double x
Definition: liblwgeom.h:339
double z
Definition: liblwgeom.h:339
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: