From: Sandro Santilli Date: Thu, 16 Sep 2004 09:05:10 +0000 (+0000) Subject: Added getbox2d_internal X-Git-Tag: pgis_1_0_0RC1~447 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ca19a49cf1feae587c090a6d791d310e3e3456de;p=postgis Added getbox2d_internal git-svn-id: http://svn.osgeo.org/postgis/trunk@824 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/lwgeom.h b/lwgeom/lwgeom.h index a3c217163..5ca6b3876 100644 --- a/lwgeom/lwgeom.h +++ b/lwgeom/lwgeom.h @@ -542,10 +542,17 @@ extern BOX3D *combine_boxes(BOX3D *b1, BOX3D *b2); // otherwise we need to compute it. // WARNING! the EMPTY geom will result in a random BOX2D returned extern BOX2DFLOAT4 getbox2d(char *serialized_form); + // this function writes to 'box' and returns 0 if serialized_form // does not have a bounding box (empty geom) extern int getbox2d_p(char *serialized_form, BOX2DFLOAT4 *box); +// this function returns a pointer to the 'internal' bounding +// box of a serialized-form geometry. If the geometry does +// not have an embedded bounding box the function returns NULL. +// READ-ONLY! +extern const BOX2DFLOAT4 * getbox2d_internal(char *serialized_form); + // Expand given box of 'd' units in all directions void expand_box2d(BOX2DFLOAT4 *box, double d); void expand_box3d(BOX3D *box, double d); diff --git a/lwgeom/lwgeom_api.c b/lwgeom/lwgeom_api.c index 45582b186..e134c9ce6 100644 --- a/lwgeom/lwgeom_api.c +++ b/lwgeom/lwgeom_api.c @@ -374,7 +374,6 @@ BOX2DFLOAT4 getbox2d(char *serialized_form) return result; } - // same as getbox2d, but modifies box instead of returning result on the stack int getbox2d_p(char *serialized_form, BOX2DFLOAT4 *box) @@ -409,6 +408,21 @@ getbox2d_p(char *serialized_form, BOX2DFLOAT4 *box) return 1; } +// this function returns a pointer to the 'internal' bounding +// box of a serialized-form geometry. If the geometry does +// not have an embedded bounding box the function returns NULL. +// READ-ONLY! +const BOX2DFLOAT4 * +getbox2d_internal(char *serialized_form) +{ + unsigned char type = (unsigned char) serialized_form[0]; + + // No embedded bounding box ... + if (!lwgeom_hasBBOX(type)) return NULL; + + return (BOX2DFLOAT4 *)(serialized_form+1); +} + //************************************************************************ // POINTARRAY support functions