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