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

◆ gserialized2_drop_gbox()

GSERIALIZED * gserialized2_drop_gbox ( GSERIALIZED g)

Remove the bounding box from a GSERIALIZED.

Returns a freshly allocated GSERIALIZED every time.

Definition at line 1636 of file gserialized2.c.

1637{
1638 int g_ndims = G2FLAGS_NDIMS_BOX(g->gflags);
1639 size_t box_size = 2 * g_ndims * sizeof(float);
1640 size_t g_out_size = LWSIZE_GET(g->size) - box_size;
1641 GSERIALIZED *g_out = lwalloc(g_out_size);
1642
1643 /* Copy the contents while omitting the box */
1644 if (G2FLAGS_GET_BBOX(g->gflags))
1645 {
1646 uint8_t *outptr = (uint8_t*)g_out;
1647 uint8_t *inptr = (uint8_t*)g;
1648 /* Copy the header (size+type) of g into place */
1649 memcpy(outptr, inptr, 8); outptr += 8; inptr += 8;
1650 /* Copy extended flags, if there are any */
1652 {
1653 memcpy(outptr, inptr, 8); outptr += 8; inptr += 8;
1654 }
1655 /* Advance past box */
1656 inptr += box_size;
1657 /* Copy parts after the box into place */
1658 memcpy(outptr, inptr, g_out_size - 8);
1659 G2FLAGS_SET_BBOX(g_out->gflags, 0);
1660 LWSIZE_SET(g_out->size, g_out_size);
1661 }
1662 /* No box? Nothing to do but copy and return. */
1663 else
1664 {
1665 memcpy(g_out, g, g_out_size);
1666 }
1667
1668 return g_out;
1669}
#define G2FLAGS_NDIMS_BOX(gflags)
#define G2FLAGS_GET_BBOX(gflags)
#define G2FLAGS_GET_EXTENDED(gflags)
#define G2FLAGS_SET_BBOX(gflags, value)
#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 G2FLAGS_GET_BBOX, G2FLAGS_GET_EXTENDED, G2FLAGS_NDIMS_BOX, G2FLAGS_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: