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

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

102 {
103  GSERIALIZED *geom1 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
104  GSERIALIZED *geom2 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
105  GBOX box1;
106  GBOX box2;
107 
108  POSTGIS_DEBUG(2, "lwgeom_le called");
109 
110  if (gserialized_get_srid(geom1) != gserialized_get_srid(geom2))
111  {
113  "Operation on two GEOMETRIES with different SRIDs\n");
114  PG_FREE_IF_COPY(geom1, 0);
115  PG_FREE_IF_COPY(geom2, 1);
116  PG_RETURN_NULL();
117  }
118 
119  gserialized_get_gbox_p(geom1, &box1);
120  gserialized_get_gbox_p(geom2, &box2);
121 
122  PG_FREE_IF_COPY(geom1, 0);
123  PG_FREE_IF_COPY(geom2, 1);
124 
125  if ( ! FPeq(box1.xmin , box2.xmin) )
126  {
127  if (box1.xmin < box2.xmin)
128  {
129  PG_RETURN_BOOL(TRUE);
130  }
131  PG_RETURN_BOOL(FALSE);
132  }
133 
134  if ( ! FPeq(box1.ymin , box2.ymin) )
135  {
136  if (box1.ymin < box2.ymin)
137  {
138  PG_RETURN_BOOL(TRUE);
139  }
140  PG_RETURN_BOOL(FALSE);
141  }
142 
143  if ( ! FPeq(box1.xmax , box2.xmax) )
144  {
145  if (box1.xmax < box2.xmax)
146  {
147  PG_RETURN_BOOL(TRUE);
148  }
149  PG_RETURN_BOOL(FALSE);
150  }
151 
152  if ( ! FPeq(box1.ymax , box2.ymax) )
153  {
154  if (box1.ymax < box2.ymax)
155  {
156  PG_RETURN_BOOL(TRUE);
157  }
158  PG_RETURN_BOOL(FALSE);
159  }
160 
161  PG_RETURN_BOOL(TRUE);
162 }
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: