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

Definition at line 233 of file geography_btree.c.

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

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

Here is the call graph for this function: