]> granicus.if.org Git - postgis/commitdiff
Add an SRID to box3d to allow lossless casts.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 2 Mar 2012 23:35:32 +0000 (23:35 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 2 Mar 2012 23:35:32 +0000 (23:35 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9390 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/g_box.c
liblwgeom/liblwgeom.h.in
postgis/lwgeom_box3d.c
postgis/postgis.sql.in.c

index 5200b7b45d77279837aed5d7d1b56c435855c855..eff95f7a4dfd09f0e314c46faa5916e43e6d5c2e 100644 (file)
@@ -50,6 +50,7 @@ BOX3D* box3d_from_gbox(const GBOX *gbox)
                b->zmin = b->zmax = 0.0;
        }
 
+       b->srid = SRID_UNKNOWN;
        return b;       
 }
 
index 9b7ae80f50ac0cc9a506d6147541c50fed7abacc..76326a9ba6940c586cc8727cdbf482d45f867f1f 100644 (file)
@@ -250,6 +250,7 @@ typedef struct
 {
        double xmin, ymin, zmin;
        double xmax, ymax, zmax;
+       int32_t srid;
 }
 BOX3D;
 
index 73e9a98078803a3239a277784d42587cf271adea..5f816e9d3a0b7a81313655618547378151607e25 100644 (file)
@@ -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);
 }
index c4beb8a2e7a4cefaa6280ddb3e852f7129759a88..bd5d9e03d31275d9925961a960d2f43f668dbfe3 100644 (file)
@@ -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
 );