From: Paul Ramsey Date: Fri, 2 Mar 2012 23:35:32 +0000 (+0000) Subject: Add an SRID to box3d to allow lossless casts. X-Git-Tag: 2.0.0beta2~37 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=496cb3223ab0b593e5196eca8149f4c7d7e4b46a;p=postgis Add an SRID to box3d to allow lossless casts. git-svn-id: http://svn.osgeo.org/postgis/trunk@9390 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/g_box.c b/liblwgeom/g_box.c index 5200b7b45..eff95f7a4 100644 --- a/liblwgeom/g_box.c +++ b/liblwgeom/g_box.c @@ -50,6 +50,7 @@ BOX3D* box3d_from_gbox(const GBOX *gbox) b->zmin = b->zmax = 0.0; } + b->srid = SRID_UNKNOWN; return b; } diff --git a/liblwgeom/liblwgeom.h.in b/liblwgeom/liblwgeom.h.in index 9b7ae80f5..76326a9ba 100644 --- a/liblwgeom/liblwgeom.h.in +++ b/liblwgeom/liblwgeom.h.in @@ -250,6 +250,7 @@ typedef struct { double xmin, ymin, zmin; double xmax, ymax, zmax; + int32_t srid; } BOX3D; diff --git a/postgis/lwgeom_box3d.c b/postgis/lwgeom_box3d.c index 73e9a9807..5f816e9d3 100644 --- a/postgis/lwgeom_box3d.c +++ b/postgis/lwgeom_box3d.c @@ -101,6 +101,7 @@ Datum BOX3D_in(PG_FUNCTION_ARGS) box->zmin = box->zmax; box->zmax = tmp; } + box->srid = SRID_UNKNOWN; PG_RETURN_POINTER(box); } @@ -242,6 +243,7 @@ Datum BOX3D_to_LWGEOM(PG_FUNCTION_ARGS) } + gserialized_set_srid(result, box->srid); PG_RETURN_POINTER(result); } @@ -291,7 +293,9 @@ Datum LWGEOM_to_BOX3D(PG_FUNCTION_ARGS) PG_RETURN_NULL(); result = box3d_from_gbox(&gbox); + result->srid = lwgeom->srid; + lwgeom_free(lwgeom); PG_RETURN_POINTER(result); } @@ -350,6 +354,7 @@ Datum BOX3D_combine(PG_FUNCTION_ARGS) LWGEOM *lwgeom = NULL; BOX3D *result = NULL; GBOX gbox; + int32_t srid; int rv; /* Can't do anything with null inputs */ @@ -364,9 +369,10 @@ Datum BOX3D_combine(PG_FUNCTION_ARGS) PG_RETURN_POINTER(result); } - /* Deserialize geometry and *calculate( the box */ - /* We can't use the cached box because it's fload, we *must* calculate */ + /* Deserialize geometry and *calculate* the box */ + /* We can't use the cached box because it's float, we *must* calculate */ lwgeom = lwgeom_from_gserialized(geom); + srid = lwgeom->srid; rv = lwgeom_calculate_gbox(lwgeom, &gbox); lwgeom_free(lwgeom); @@ -387,6 +393,7 @@ Datum BOX3D_combine(PG_FUNCTION_ARGS) { PG_FREE_IF_COPY(geom, 1); result = box3d_from_gbox(&gbox); + result->srid = srid; PG_RETURN_POINTER(result); } @@ -397,6 +404,7 @@ Datum BOX3D_combine(PG_FUNCTION_ARGS) result->xmin = Min(box->xmin, gbox.xmin); result->ymin = Min(box->ymin, gbox.ymin); result->zmin = Min(box->zmin, gbox.zmin); + result->srid = srid; PG_FREE_IF_COPY(geom, 1); PG_RETURN_POINTER(result); @@ -434,5 +442,7 @@ Datum BOX3D_construct(PG_FUNCTION_ARGS) result->ymin = minp.y; result->zmin = minp.z; + result->srid = minpoint->srid; + PG_RETURN_POINTER(result); } diff --git a/postgis/postgis.sql.in.c b/postgis/postgis.sql.in.c index c4beb8a2e..bd5d9e03d 100644 --- a/postgis/postgis.sql.in.c +++ b/postgis/postgis.sql.in.c @@ -156,7 +156,7 @@ CREATE OR REPLACE FUNCTION box3d_out(box3d) CREATE TYPE box3d ( alignment = double, - internallength = 48, + internallength = 52, input = box3d_in, output = box3d_out );