PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwgeom_lt()

Datum lwgeom_lt ( PG_FUNCTION_ARGS  )

Definition at line 50 of file lwgeom_btree.c.

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

51 {
52  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
53  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
54  GBOX box1;
55  GBOX box2;
56  bool empty1, empty2;
57 
58  POSTGIS_DEBUG(2, "lwgeom_lt called");
59 
61 
62  POSTGIS_DEBUG(3, "lwgeom_lt passed getSRID test");
63 
64  empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
65  empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
66 
67  PG_FREE_IF_COPY(geom1, 0);
68  PG_FREE_IF_COPY(geom2, 1);
69 
70  POSTGIS_DEBUG(3, "lwgeom_lt getbox2d_p passed");
71 
72  if ( empty1 != empty2 )
73  {
74  PG_RETURN_BOOL(FALSE);
75  }
76 
77  if ( ! FPeq(box1.xmin , box2.xmin) )
78  {
79  if (box1.xmin < box2.xmin)
80  PG_RETURN_BOOL(TRUE);
81  }
82 
83  if ( ! FPeq(box1.ymin , box2.ymin) )
84  {
85  if (box1.ymin < box2.ymin)
86  PG_RETURN_BOOL(TRUE);
87  }
88 
89  if ( ! FPeq(box1.xmax , box2.xmax) )
90  {
91  if (box1.xmax < box2.xmax)
92  PG_RETURN_BOOL(TRUE);
93  }
94 
95  if ( ! FPeq(box1.ymax , box2.ymax) )
96  {
97  if (box1.ymax < box2.ymax)
98  PG_RETURN_BOOL(TRUE);
99  }
100 
101  PG_RETURN_BOOL(FALSE);
102 }
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: