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

Definition at line 297 of file lwgeom_btree.c.

References error_if_srid_mismatch(), FPeq, gserialized_get_gbox_p(), gserialized_get_srid(), GBOX::xmax, GBOX::xmin, GBOX::ymax, and GBOX::ymin.

298 {
299  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
300  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
301  GBOX box1;
302  GBOX box2;
303 
304  POSTGIS_DEBUG(2, "lwgeom_cmp called");
305 
307 
308  gserialized_get_gbox_p(geom1, &box1);
309  gserialized_get_gbox_p(geom2, &box2);
310 
311  PG_FREE_IF_COPY(geom1, 0);
312  PG_FREE_IF_COPY(geom2, 1);
313 
314  if ( ! FPeq(box1.xmin , box2.xmin) )
315  {
316  if (box1.xmin < box2.xmin)
317  {
318  PG_RETURN_INT32(-1);
319  }
320  PG_RETURN_INT32(1);
321  }
322 
323  if ( ! FPeq(box1.ymin , box2.ymin) )
324  {
325  if (box1.ymin < box2.ymin)
326  {
327  PG_RETURN_INT32(-1);
328  }
329  PG_RETURN_INT32(1);
330  }
331 
332  if ( ! FPeq(box1.xmax , box2.xmax) )
333  {
334  if (box1.xmax < box2.xmax)
335  {
336  PG_RETURN_INT32(-1);
337  }
338  PG_RETURN_INT32(1);
339  }
340 
341  if ( ! FPeq(box1.ymax , box2.ymax) )
342  {
343  if (box1.ymax < box2.ymax)
344  {
345  PG_RETURN_INT32(-1);
346  }
347  PG_RETURN_INT32(1);
348  }
349 
350  PG_RETURN_INT32(0);
351 }
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box)
Read the bounding box off a serialization and calculate one if it is not already there.
Definition: g_serialized.c:371
double xmax
Definition: liblwgeom.h:277
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
double ymin
Definition: liblwgeom.h:278
double xmin
Definition: liblwgeom.h:276
double ymax
Definition: liblwgeom.h:279
#define FPeq(A, B)
Definition: box2d.c:11
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:69

Here is the call graph for this function: