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

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

46 {
47  GSERIALIZED *geom1 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
48  GSERIALIZED *geom2 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
49  GBOX box1;
50  GBOX box2;
51 
52  POSTGIS_DEBUG(2, "lwgeom_lt called");
53 
54  if (gserialized_get_srid(geom1) != gserialized_get_srid(geom2))
55  {
57  "Operation on two GEOMETRIES with different SRIDs\n");
58  PG_FREE_IF_COPY(geom1, 0);
59  PG_FREE_IF_COPY(geom2, 1);
60  PG_RETURN_NULL();
61  }
62 
63  POSTGIS_DEBUG(3, "lwgeom_lt passed getSRID test");
64 
65  gserialized_get_gbox_p(geom1, &box1);
66  gserialized_get_gbox_p(geom2, &box2);
67 
68  PG_FREE_IF_COPY(geom1, 0);
69  PG_FREE_IF_COPY(geom2, 1);
70 
71  POSTGIS_DEBUG(3, "lwgeom_lt getbox2d_p passed");
72 
73  if ( ! FPeq(box1.xmin , box2.xmin) )
74  {
75  if (box1.xmin < box2.xmin)
76  PG_RETURN_BOOL(TRUE);
77  }
78 
79  if ( ! FPeq(box1.ymin , box2.ymin) )
80  {
81  if (box1.ymin < box2.ymin)
82  PG_RETURN_BOOL(TRUE);
83  }
84 
85  if ( ! FPeq(box1.xmax , box2.xmax) )
86  {
87  if (box1.xmax < box2.xmax)
88  PG_RETURN_BOOL(TRUE);
89  }
90 
91  if ( ! FPeq(box1.ymax , box2.ymax) )
92  {
93  if (box1.ymax < box2.ymax)
94  PG_RETURN_BOOL(TRUE);
95  }
96 
97  PG_RETURN_BOOL(FALSE);
98 }
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: