]> granicus.if.org Git - postgis/commitdiff
Add a public lwgeom_get_bbox function (#1324)
authorSandro Santilli <strk@keybit.net>
Fri, 9 Dec 2011 14:37:16 +0000 (14:37 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 9 Dec 2011 14:37:16 +0000 (14:37 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8335 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/liblwgeom.h.in
liblwgeom/lwgeom.c
liblwgeom/lwout_gml.c

index 1a522853a20645ef14dff1cfae74344dcb9516c2..ca3e20597939fe936c505ecae79fcb4d5d2b5f1d 100644 (file)
@@ -653,10 +653,22 @@ extern void lwgeom_drop_bbox(LWGEOM *lwgeom);
 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 
 */
index 20bab78f299933600396260b51be92acbdc508b6..da3904552ad5217fe76ea1d6c9802419f49e0b89 100644 (file)
@@ -551,6 +551,15 @@ lwgeom_add_bbox(LWGEOM *lwgeom)
        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.
index df7b83f42733a5b5798aad86446a74d0f1f89ebe..79046a597081718fd89b66c7a6a057671349ce94 100644 (file)
@@ -53,14 +53,6 @@ static size_t pointArray_toGML3(POINTARRAY *pa, char *buf, int precision, int op
 
 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)
 {