]> granicus.if.org Git - postgis/commitdiff
PG_LWGEOM_construct() moved from lwgeom_api.c to lwgeom_pg.c.
authorSandro Santilli <strk@keybit.net>
Fri, 4 Mar 2005 09:03:32 +0000 (09:03 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 4 Mar 2005 09:03:32 +0000 (09:03 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@1476 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/lwgeom_api.c
lwgeom/lwgeom_pg.c

index c4d6c3e064b2b22556023232024e56faf0d5a00b..ed0c6ebccfd81ee9e817761a86fd895f3b4f8a4c 100644 (file)
@@ -1823,72 +1823,6 @@ pglwgeom_setSRID(PG_LWGEOM *lwgeom, int32 newSRID)
        return result;
 }
 
-PG_LWGEOM *
-PG_LWGEOM_construct(uchar *ser, int SRID, int wantbbox)
-{
-       int size;
-       uchar *iptr, *optr, *eptr;
-       int wantsrid = 0;
-       BOX2DFLOAT4 box;
-       PG_LWGEOM *result;
-
-       /* COMPUTE_BBOX FOR_COMPLEX_GEOMS */
-       if ( is_worth_caching_serialized_bbox(ser) ) 
-       {
-               // if ( ! wantbbox ) elog(NOTICE, "PG_LWGEOM_construct forced wantbbox=1 due to rule FOR_COMPLEX_GEOMS");
-               wantbbox=1;
-       }
-
-       size = lwgeom_size(ser);
-       eptr = ser+size; // end of subgeom
-
-       iptr = ser+1; // skip type
-       if ( lwgeom_hasSRID(ser[0]) )
-       {
-               iptr += 4; // skip SRID
-               size -= 4;
-       }
-       if ( lwgeom_hasBBOX(ser[0]) )
-       {
-               iptr += sizeof(BOX2DFLOAT4); // skip BBOX
-               size -= sizeof(BOX2DFLOAT4);
-       }
-
-       if ( SRID != -1 )
-       {
-               wantsrid = 1;
-               size += 4;
-       }
-       if ( wantbbox )
-       {
-               size += sizeof(BOX2DFLOAT4);
-               getbox2d_p(ser, &box);
-       }
-
-       size+=4; // size header
-
-       result = lwalloc(size);
-       result->size = size;
-
-       result->type = lwgeom_makeType_full(
-               TYPE_HASZ(ser[0]), TYPE_HASM(ser[0]),
-               wantsrid, lwgeom_getType(ser[0]), wantbbox);
-       optr = result->data;
-       if ( wantbbox )
-       {
-               memcpy(optr, &box, sizeof(BOX2DFLOAT4));
-               optr += sizeof(BOX2DFLOAT4);
-       }
-       if ( wantsrid )
-       {
-               memcpy(optr, &SRID, 4);
-               optr += 4;
-       }
-       memcpy(optr, iptr, eptr-iptr);
-
-       return result;
-}
-
 void
 pfree_exploded(LWGEOM_EXPLODED *exploded)
 {
index eba680ca4161a6dc420d0c4a6ea1ddf81a879226..8719bafa39d79a49ef0c1d6020f522b4878367a7 100644 (file)
@@ -159,3 +159,70 @@ getGeometryOID()
 
        return OID;
 }
+
+PG_LWGEOM *
+PG_LWGEOM_construct(uchar *ser, int SRID, int wantbbox)
+{
+       int size;
+       uchar *iptr, *optr, *eptr;
+       int wantsrid = 0;
+       BOX2DFLOAT4 box;
+       PG_LWGEOM *result;
+
+       /* COMPUTE_BBOX FOR_COMPLEX_GEOMS */
+       if ( is_worth_caching_serialized_bbox(ser) ) 
+       {
+               // if ( ! wantbbox ) elog(NOTICE, "PG_LWGEOM_construct forced wantbbox=1 due to rule FOR_COMPLEX_GEOMS");
+               wantbbox=1;
+       }
+
+       size = lwgeom_size(ser);
+       eptr = ser+size; // end of subgeom
+
+       iptr = ser+1; // skip type
+       if ( lwgeom_hasSRID(ser[0]) )
+       {
+               iptr += 4; // skip SRID
+               size -= 4;
+       }
+       if ( lwgeom_hasBBOX(ser[0]) )
+       {
+               iptr += sizeof(BOX2DFLOAT4); // skip BBOX
+               size -= sizeof(BOX2DFLOAT4);
+       }
+
+       if ( SRID != -1 )
+       {
+               wantsrid = 1;
+               size += 4;
+       }
+       if ( wantbbox )
+       {
+               size += sizeof(BOX2DFLOAT4);
+               getbox2d_p(ser, &box);
+       }
+
+       size+=4; // size header
+
+       result = lwalloc(size);
+       result->size = size;
+
+       result->type = lwgeom_makeType_full(
+               TYPE_HASZ(ser[0]), TYPE_HASM(ser[0]),
+               wantsrid, lwgeom_getType(ser[0]), wantbbox);
+       optr = result->data;
+       if ( wantbbox )
+       {
+               memcpy(optr, &box, sizeof(BOX2DFLOAT4));
+               optr += sizeof(BOX2DFLOAT4);
+       }
+       if ( wantsrid )
+       {
+               memcpy(optr, &SRID, 4);
+               optr += 4;
+       }
+       memcpy(optr, iptr, eptr-iptr);
+
+       return result;
+}
+