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

Definition at line 168 of file lwgeom_btree.c.

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

169 {
170  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
171  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
172  GBOX box1;
173  GBOX box2;
174  bool empty1, empty2;
175  bool result;
176 
177  POSTGIS_DEBUG(2, "lwgeom_eq called");
178 
180 
181  gbox_init(&box1);
182  gbox_init(&box2);
183 
184  empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
185  empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
186 
187  PG_FREE_IF_COPY(geom1, 0);
188  PG_FREE_IF_COPY(geom2, 1);
189 
190  if ( empty1 != empty2 )
191  {
192  result = FALSE;
193  }
194  else if ( ! (FPeq(box1.xmin, box2.xmin) && FPeq(box1.ymin, box2.ymin) &&
195  FPeq(box1.xmax, box2.xmax) && FPeq(box1.ymax, box2.ymax)) )
196  {
197  result = FALSE;
198  }
199  else
200  {
201  result = TRUE;
202  }
203 
204  PG_RETURN_BOOL(result);
205 }
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
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:51
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: