]> granicus.if.org Git - postgis/commitdiff
Added compute_serialized_bbox_p() to always recomputed a geometry bounding box
authorSandro Santilli <strk@keybit.net>
Thu, 30 Dec 2004 15:58:27 +0000 (15:58 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 30 Dec 2004 15:58:27 +0000 (15:58 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@1197 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/liblwgeom.h
lwgeom/lwgeom_api.c

index 00e880d7644aeddc29bd3e43fb61196ba39ec142..d31f9f450ece8b0a87e9c0b7ad32bc7ea6086a49 100644 (file)
@@ -391,9 +391,9 @@ typedef struct {
 } PG_LWGEOM;
 
 /*
- * Construct a full LWGEOM type (including size header)
+ * Construct a full PG_LWGEOM type (including size header)
  * from a serialized form.
- * The constructed LWGEOM object will be allocated using palloc
+ * The constructed PG_LWGEOM object will be allocated using palloc
  * and the serialized form will be copied.
  * If you specify a SRID other then -1 it will be set.
  * If you request bbox (wantbbox=1) it will be extracted or computed
@@ -401,6 +401,12 @@ typedef struct {
  */
 extern PG_LWGEOM *PG_LWGEOM_construct(char *serialized, int SRID, int wantbbox);
 
+/*
+ * Compute bbox of serialized geom
+ */
+extern int compute_serialized_bbox_p(char *serialized_form, BOX2DFLOAT4 *box);
+
+
 /*
  * Evaluate with an heuristic if the provided PG_LWGEOM is worth
  * caching a bbox
@@ -883,8 +889,6 @@ extern float LWGEOM_Maxf(float a, float b);
 extern double LWGEOM_Mind(double a, double b);
 extern double LWGEOM_Maxd(double a, double b);
 
-extern BOX3D *lw_geom_getBB_simple(char *serialized_form);
-
 extern float  nextDown_f(double d);
 extern float  nextUp_f(double d);
 extern double nextDown_d(float d);
index 2cfa3eb64e3d3f1f3437d64678ea2fda0a329b0c..41ca75648d4a99e03d63bb0840262476b39b5ea8 100644 (file)
@@ -19,7 +19,7 @@
 // This is an implementation of the functions defined in lwgeom.h
 
 //forward decs
-extern  BOX3D *lw_geom_getBB_simple(char *serialized_form);
+extern BOX3D *lw_geom_getBB_simple(char *serialized_form);
 #ifdef DEBUG_EXPLODED
 void checkexplodedsize(char *srl, LWGEOM_EXPLODED *exploded, int alloced, char wantbbox);
 #endif
@@ -1439,6 +1439,26 @@ lw_geom_getBB(char *serialized_form)
          return result;
 }
 
+// Compute bounding box of a serialized LWGEOM, even if it is
+// already cached. The computed BOX2DFLOAT4 is stored at
+// the given location, the function returns 0 is the geometry
+// does not have a bounding box (EMPTY GEOM)
+int
+compute_serialized_bbox_p(char *serialized_form, BOX2DFLOAT4 *out)
+{
+         LWGEOM_INSPECTED *inspected = lwgeom_inspect(serialized_form);
+
+         BOX3D *result = lw_geom_getBB_inspected(inspected);
+         if ( ! result ) return 0;
+         out->xmin = result->xmin;
+         out->xmax = result->xmax;
+         out->ymin = result->ymin;
+         out->ymax = result->ymax;
+         lwfree(result);
+
+         return 1;
+}
+
 //dont forget to lwfree() result
 BOX3D *lw_geom_getBB_simple(char *serialized_form)
 {