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

Definition at line 275 of file lwgeom_btree.c.

References BTREE_SRID_MISMATCH_SEVERITY, FALSE, FPeq, gserialized_get_gbox_p(), gserialized_get_srid(), TRUE, GBOX::xmax, GBOX::xmin, GBOX::ymax, and GBOX::ymin.

276 {
277  GSERIALIZED *geom1 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
278  GSERIALIZED *geom2 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
279  GBOX box1;
280  GBOX box2;
281 
282  POSTGIS_DEBUG(2, "lwgeom_gt called");
283 
284  if (gserialized_get_srid(geom1) != gserialized_get_srid(geom2))
285  {
287  "Operation on two GEOMETRIES with different SRIDs\n");
288  PG_FREE_IF_COPY(geom1, 0);
289  PG_FREE_IF_COPY(geom2, 1);
290  PG_RETURN_NULL();
291  }
292 
293  gserialized_get_gbox_p(geom1, &box1);
294  gserialized_get_gbox_p(geom2, &box2);
295 
296  PG_FREE_IF_COPY(geom1, 0);
297  PG_FREE_IF_COPY(geom2, 1);
298 
299  if ( ! FPeq(box1.xmin , box2.xmin) )
300  {
301  if (box1.xmin > box2.xmin)
302  {
303  PG_RETURN_BOOL(TRUE);
304  }
305  }
306 
307  if ( ! FPeq(box1.ymin , box2.ymin) )
308  {
309  if (box1.ymin > box2.ymin)
310  {
311  PG_RETURN_BOOL(TRUE);
312  }
313  }
314 
315  if ( ! FPeq(box1.xmax , box2.xmax) )
316  {
317  if (box1.xmax > box2.xmax)
318  {
319  PG_RETURN_BOOL(TRUE);
320  }
321  }
322 
323  if ( ! FPeq(box1.ymax , box2.ymax) )
324  {
325  if (box1.ymax > box2.ymax)
326  {
327  PG_RETURN_BOOL(TRUE);
328  }
329  }
330 
331  PG_RETURN_BOOL(FALSE);
332 }
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:373
double xmax
Definition: liblwgeom.h:249
double ymin
Definition: liblwgeom.h:250
double xmin
Definition: liblwgeom.h:248
#define BTREE_SRID_MISMATCH_SEVERITY
Definition: lwgeom_btree.c:42
double ymax
Definition: liblwgeom.h:251
#define FALSE
Definition: dbfopen.c:169
#define FPeq(A, B)
Definition: box2d.c:11
#define TRUE
Definition: dbfopen.c:170
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:70

Here is the call graph for this function: