} 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
*/
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
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);
// 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
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)
{