extern void lwgeom_drop_srid(LWGEOM *lwgeom);
/**
-* Compute a bbox if not already computed
-*/
+ * Compute a bbox if not already computed
+ *
+ * After calling this function lwgeom->bbox is only
+ * NULL if the geometry is empty.
+ */
extern void lwgeom_add_bbox(LWGEOM *lwgeom);
+/**
+ * Get a non-empty geometry bounding box, computing and
+ * caching it if not already there
+ *
+ * NOTE: empty geometries don't have a bounding box so
+ * you'd still get a NULL for them.
+ */
+extern const GBOX *lwgeom_get_bbox(const LWGEOM *lwgeom);
+
/**
* Determine whether a LWGEOM can contain sub-geometries or not
*/
lwgeom_calculate_gbox(lwgeom, lwgeom->bbox);
}
+const GBOX *
+lwgeom_get_bbox(const LWGEOM *lwg)
+{
+ /* add it if not already there */
+ lwgeom_add_bbox((LWGEOM *)lwg);
+ return lwg->bbox;
+}
+
+
/**
* Calculate the gbox for this goemetry, a cartesian box or
* geodetic box, depending on how it is flagged.
static size_t pointArray_GMLsize(POINTARRAY *pa, int precision);
-static const GBOX *
-lwgeom_get_bbox(const LWGEOM *lwg)
-{
- /* if ( ! lwg->bbox ) lwnotice("Adding a bbox"); */
- lwgeom_add_bbox((LWGEOM *)lwg); /* adds one if not already there */
- return lwg->bbox;
-}
-
static char *
gbox_to_gml2(const GBOX *bbox, const char *srs, int precision, const char *prefix)
{