PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwgeom_le()

Datum lwgeom_le ( PG_FUNCTION_ARGS  )

Definition at line 105 of file lwgeom_btree.c.

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

Referenced by lwgeom_lt().

106 {
107  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
108  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
109  GBOX box1;
110  GBOX box2;
111  bool empty1, empty2;
112 
113  POSTGIS_DEBUG(2, "lwgeom_le called");
114 
116 
117  empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
118  empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
119 
120  PG_FREE_IF_COPY(geom1, 0);
121  PG_FREE_IF_COPY(geom2, 1);
122 
123  if ( empty1 != empty2 )
124  {
125  PG_RETURN_BOOL(FALSE);
126  }
127 
128  if ( ! FPeq(box1.xmin , box2.xmin) )
129  {
130  if (box1.xmin < box2.xmin)
131  {
132  PG_RETURN_BOOL(TRUE);
133  }
134  PG_RETURN_BOOL(FALSE);
135  }
136 
137  if ( ! FPeq(box1.ymin , box2.ymin) )
138  {
139  if (box1.ymin < box2.ymin)
140  {
141  PG_RETURN_BOOL(TRUE);
142  }
143  PG_RETURN_BOOL(FALSE);
144  }
145 
146  if ( ! FPeq(box1.xmax , box2.xmax) )
147  {
148  if (box1.xmax < box2.xmax)
149  {
150  PG_RETURN_BOOL(TRUE);
151  }
152  PG_RETURN_BOOL(FALSE);
153  }
154 
155  if ( ! FPeq(box1.ymax , box2.ymax) )
156  {
157  if (box1.ymax < box2.ymax)
158  {
159  PG_RETURN_BOOL(TRUE);
160  }
161  PG_RETURN_BOOL(FALSE);
162  }
163 
164  PG_RETURN_BOOL(TRUE);
165 }
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: