PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwgeom_gt()

Datum lwgeom_gt ( PG_FUNCTION_ARGS  )

Definition at line 271 of file lwgeom_btree.c.

References error_if_srid_mismatch(), FALSE, FPeq, gserialized_get_gbox_p(), gserialized_get_srid(), LW_FAILURE, lwgeom_cmp(), PG_FUNCTION_INFO_V1(), TRUE, GBOX::xmax, GBOX::xmin, GBOX::ymax, and GBOX::ymin.

Referenced by lwgeom_ge().

272 {
273  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
274  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
275  GBOX box1;
276  GBOX box2;
277  bool empty1, empty2;
278 
279  POSTGIS_DEBUG(2, "lwgeom_gt called");
280 
282 
283  empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
284  empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
285 
286  PG_FREE_IF_COPY(geom1, 0);
287  PG_FREE_IF_COPY(geom2, 1);
288 
289  if ( empty1 != empty2 )
290  {
291  PG_RETURN_BOOL(FALSE);
292  }
293 
294  if ( ! FPeq(box1.xmin , box2.xmin) )
295  {
296  if (box1.xmin > box2.xmin)
297  {
298  PG_RETURN_BOOL(TRUE);
299  }
300  }
301 
302  if ( ! FPeq(box1.ymin , box2.ymin) )
303  {
304  if (box1.ymin > box2.ymin)
305  {
306  PG_RETURN_BOOL(TRUE);
307  }
308  }
309 
310  if ( ! FPeq(box1.xmax , box2.xmax) )
311  {
312  if (box1.xmax > box2.xmax)
313  {
314  PG_RETURN_BOOL(TRUE);
315  }
316  }
317 
318  if ( ! FPeq(box1.ymax , box2.ymax) )
319  {
320  if (box1.ymax > box2.ymax)
321  {
322  PG_RETURN_BOOL(TRUE);
323  }
324  }
325 
326  PG_RETURN_BOOL(FALSE);
327 }
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:398
double xmax
Definition: liblwgeom.h:292
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:369
#define LW_FAILURE
Definition: liblwgeom.h:78
double ymin
Definition: liblwgeom.h:293
double xmin
Definition: liblwgeom.h:291
double ymax
Definition: liblwgeom.h:294
#define FALSE
Definition: dbfopen.c:168
#define FPeq(A, B)
Definition: box2d.c:37
#define TRUE
Definition: dbfopen.c:169
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:83
Here is the call graph for this function:
Here is the caller graph for this function: