PostGIS  2.3.7dev-r@@SVN_REVISION@@
Datum lwgeom_ge ( PG_FUNCTION_ARGS  )

Definition at line 208 of file lwgeom_btree.c.

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

209 {
210  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
211  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
212  GBOX box1;
213  GBOX box2;
214  bool empty1, empty2;
215 
216  POSTGIS_DEBUG(2, "lwgeom_ge called");
217 
219 
220  empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
221  empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
222 
223  PG_FREE_IF_COPY(geom1, 0);
224  PG_FREE_IF_COPY(geom2, 1);
225 
226  if ( empty1 != empty2 )
227  {
228  PG_RETURN_BOOL(FALSE);
229  }
230 
231  if ( ! FPeq(box1.xmin , box2.xmin) )
232  {
233  if (box1.xmin > box2.xmin)
234  {
235  PG_RETURN_BOOL(TRUE);
236  }
237  PG_RETURN_BOOL(FALSE);
238  }
239 
240  if ( ! FPeq(box1.ymin , box2.ymin) )
241  {
242  if (box1.ymin > box2.ymin)
243  {
244  PG_RETURN_BOOL(TRUE);
245  }
246  PG_RETURN_BOOL(FALSE);
247  }
248 
249  if ( ! FPeq(box1.xmax , box2.xmax) )
250  {
251  if (box1.xmax > box2.xmax)
252  {
253  PG_RETURN_BOOL(TRUE);
254  }
255  PG_RETURN_BOOL(FALSE);
256  }
257 
258  if ( ! FPeq(box1.ymax , box2.ymax) )
259  {
260  if (box1.ymax > box2.ymax)
261  {
262  PG_RETURN_BOOL(TRUE);
263  }
264  PG_RETURN_BOOL(FALSE);
265  }
266 
267  PG_RETURN_BOOL(TRUE);
268 }
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: