PostGIS 3.0.6dev-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 1577 of file gserialized1.c.

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

References G1FLAGS_GET_BBOX, G1FLAGS_NDIMS_BOX, G1FLAGS_SET_BBOX, GSERIALIZED::gflags, lwalloc(), GSERIALIZED::size, SIZE_GET, and SIZE_SET.

Referenced by gserialized_drop_gbox().

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