PostGIS  2.3.6-r@@SVN_REVISION@@
static GEOSGeometry* geos_envelope_surrogate ( const LWGEOM g)
static

Definition at line 61 of file lwgeom_geos_cluster.c.

References getPoint2d_cp(), lwgeom_as_lwpoint(), lwgeom_get_bbox(), lwgeom_get_type(), lwgeom_is_empty(), make_geos_point(), make_geos_segment(), POINTTYPE, POINT2D::x, GBOX::xmax, GBOX::xmin, POINT2D::y, GBOX::ymax, and GBOX::ymin.

Referenced by make_strtree().

62 {
63  if (lwgeom_is_empty(g))
64  return GEOSGeom_createEmptyPolygon();
65 
66  if (lwgeom_get_type(g) == POINTTYPE) {
67  const POINT2D* pt = getPoint2d_cp(lwgeom_as_lwpoint(g)->point, 0);
68  return make_geos_point(pt->x, pt->y);
69  } else {
70  const GBOX* box = lwgeom_get_bbox(g);
71  if (!box)
72  return NULL;
73 
74  return make_geos_segment(box->xmin, box->ymin, box->xmax, box->ymax);
75  }
76 }
GEOSGeometry * make_geos_segment(double x1, double y1, double x2, double y2)
uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
Definition: lwgeom.c:842
double xmax
Definition: liblwgeom.h:292
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:93
GEOSGeometry * make_geos_point(double x, double y)
double x
Definition: liblwgeom.h:327
double ymin
Definition: liblwgeom.h:293
double xmin
Definition: liblwgeom.h:291
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
Definition: lwgeom_api.c:485
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
Definition: lwgeom.c:653
double ymax
Definition: liblwgeom.h:294
double y
Definition: liblwgeom.h:327
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1310

Here is the call graph for this function:

Here is the caller graph for this function: