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

Definition at line 165 of file lwgeom_btree.c.

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

166 {
167  GSERIALIZED *geom1 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
168  GSERIALIZED *geom2 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
169  GBOX box1;
170  GBOX box2;
171  bool empty1, empty2;
172  bool result;
173 
174  POSTGIS_DEBUG(2, "lwgeom_eq called");
175 
176  if (gserialized_get_srid(geom1) != gserialized_get_srid(geom2))
177  {
179  "Operation on two GEOMETRIES with different SRIDs\n");
180  PG_FREE_IF_COPY(geom1, 0);
181  PG_FREE_IF_COPY(geom2, 1);
182  PG_RETURN_NULL();
183  }
184 
185  gbox_init(&box1);
186  gbox_init(&box2);
187 
188  empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
189  empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
190  PG_FREE_IF_COPY(geom1, 0);
191  PG_FREE_IF_COPY(geom2, 1);
192 
193  if ( empty1 != empty2 )
194  {
195  result = FALSE;
196  }
197  else if ( ! (FPeq(box1.xmin, box2.xmin) && FPeq(box1.ymin, box2.ymin) &&
198  FPeq(box1.xmax, box2.xmax) && FPeq(box1.ymax, box2.ymax)) )
199  {
200  result = FALSE;
201  }
202  else
203  {
204  result = TRUE;
205  }
206 
207  PG_RETURN_BOOL(result);
208 }
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
char ** result
Definition: liblwgeom.h:218
#define LW_FAILURE
Definition: liblwgeom.h:54
double ymin
Definition: liblwgeom.h:250
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:34
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: