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

Definition at line 211 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.

212 {
213  GSERIALIZED *geom1 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
214  GSERIALIZED *geom2 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
215  GBOX box1;
216  GBOX box2;
217 
218  POSTGIS_DEBUG(2, "lwgeom_ge called");
219 
220  if (gserialized_get_srid(geom1) != gserialized_get_srid(geom2))
221  {
223  "Operation on two GEOMETRIES with different SRIDs\n");
224  PG_FREE_IF_COPY(geom1, 0);
225  PG_FREE_IF_COPY(geom2, 1);
226  PG_RETURN_NULL();
227  }
228 
229  gserialized_get_gbox_p(geom1, &box1);
230  gserialized_get_gbox_p(geom2, &box2);
231 
232  PG_FREE_IF_COPY(geom1, 0);
233  PG_FREE_IF_COPY(geom2, 1);
234 
235  if ( ! FPeq(box1.xmin , box2.xmin) )
236  {
237  if (box1.xmin > box2.xmin)
238  {
239  PG_RETURN_BOOL(TRUE);
240  }
241  PG_RETURN_BOOL(FALSE);
242  }
243 
244  if ( ! FPeq(box1.ymin , box2.ymin) )
245  {
246  if (box1.ymin > box2.ymin)
247  {
248  PG_RETURN_BOOL(TRUE);
249  }
250  PG_RETURN_BOOL(FALSE);
251  }
252 
253  if ( ! FPeq(box1.xmax , box2.xmax) )
254  {
255  if (box1.xmax > box2.xmax)
256  {
257  PG_RETURN_BOOL(TRUE);
258  }
259  PG_RETURN_BOOL(FALSE);
260  }
261 
262  if ( ! FPeq(box1.ymax , box2.ymax) )
263  {
264  if (box1.ymax > box2.ymax)
265  {
266  PG_RETURN_BOOL(TRUE);
267  }
268  PG_RETURN_BOOL(FALSE);
269  }
270 
271  PG_RETURN_BOOL(TRUE);
272 }
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: