PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ gserialized1_drop_gbox()

GSERIALIZED * gserialized1_drop_gbox ( GSERIALIZED g)

Remove the bounding box from a GSERIALIZED.

Returns a freshly allocated GSERIALIZED every time.

Definition at line 1578 of file gserialized1.c.

1579{
1580 int g_ndims = G1FLAGS_NDIMS_BOX(g->gflags);
1581 size_t box_size = 2 * g_ndims * sizeof(float);
1582 size_t g_out_size = LWSIZE_GET(g->size) - box_size;
1583 GSERIALIZED *g_out = lwalloc(g_out_size);
1584
1585 /* Copy the contents while omitting the box */
1586 if ( G1FLAGS_GET_BBOX(g->gflags) )
1587 {
1588 uint8_t *outptr = (uint8_t*)g_out;
1589 uint8_t *inptr = (uint8_t*)g;
1590 /* Copy the header (size+type) of g into place */
1591 memcpy(outptr, inptr, 8);
1592 outptr += 8;
1593 inptr += 8 + box_size;
1594 /* Copy parts after the box into place */
1595 memcpy(outptr, inptr, g_out_size - 8);
1596 G1FLAGS_SET_BBOX(g_out->gflags, 0);
1597 LWSIZE_SET(g_out->size, g_out_size);
1598 }
1599 /* No box? Nothing to do but copy and return. */
1600 else
1601 {
1602 memcpy(g_out, g, g_out_size);
1603 }
1604
1605 return g_out;
1606}
#define G1FLAGS_SET_BBOX(gflags, value)
#define G1FLAGS_GET_BBOX(gflags)
#define G1FLAGS_NDIMS_BOX(gflags)
#define LWSIZE_GET(varsize)
Macro for reading the size from the GSERIALIZED size attribute.
Definition liblwgeom.h:324
void * lwalloc(size_t size)
Definition lwutil.c:227
#define LWSIZE_SET(varsize, len)
Definition liblwgeom.h:325
uint32_t size
Definition liblwgeom.h:444
uint8_t gflags
Definition liblwgeom.h:446

References G1FLAGS_GET_BBOX, G1FLAGS_NDIMS_BOX, G1FLAGS_SET_BBOX, GSERIALIZED::gflags, lwalloc(), LWSIZE_GET, LWSIZE_SET, and GSERIALIZED::size.

Referenced by gserialized_drop_gbox().

Here is the call graph for this function:
Here is the caller graph for this function: