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

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

149 {
150  GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
151  GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
152  GBOX box1;
153  GBOX box2;
154  bool empty1, empty2;
155  bool result;
156 
157  POSTGIS_DEBUG(2, "lwgeom_eq called");
158 
160 
161  gbox_init(&box1);
162  gbox_init(&box2);
163 
164  empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE );
165  empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE );
166  PG_FREE_IF_COPY(geom1, 0);
167  PG_FREE_IF_COPY(geom2, 1);
168 
169  if ( empty1 != empty2 )
170  {
171  result = FALSE;
172  }
173  else if ( ! (FPeq(box1.xmin, box2.xmin) && FPeq(box1.ymin, box2.ymin) &&
174  FPeq(box1.xmax, box2.xmax) && FPeq(box1.ymax, box2.ymax)) )
175  {
176  result = FALSE;
177  }
178  else
179  {
180  result = TRUE;
181  }
182 
183  PG_RETURN_BOOL(result);
184 }
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:371
double xmax
Definition: liblwgeom.h:277
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
#define LW_FAILURE
Definition: liblwgeom.h:64
double ymin
Definition: liblwgeom.h:278
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:36
double xmin
Definition: liblwgeom.h:276
double ymax
Definition: liblwgeom.h:279
#define FALSE
Definition: dbfopen.c:168
#define FPeq(A, B)
Definition: box2d.c:11
#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:69

Here is the call graph for this function: