PostGIS 3.0.6dev-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 1689 of file gserialized2.c.

1690{
1691 int g_ndims = G2FLAGS_NDIMS_BOX(g->gflags);
1692 size_t box_size = 2 * g_ndims * sizeof(float);
1693 size_t g_out_size = SIZE_GET(g->size) - box_size;
1694 GSERIALIZED *g_out = lwalloc(g_out_size);
1695
1696 /* Copy the contents while omitting the box */
1697 if (G2FLAGS_GET_BBOX(g->gflags))
1698 {
1699 uint8_t *outptr = (uint8_t*)g_out;
1700 uint8_t *inptr = (uint8_t*)g;
1701 /* Copy the header (size+type) of g into place */
1702 memcpy(outptr, inptr, 8); outptr += 8; inptr += 8;
1703 /* Copy extended flags, if there are any */
1705 {
1706 memcpy(outptr, inptr, 8); outptr += 8; inptr += 8;
1707 }
1708 /* Advance past box */
1709 inptr += box_size;
1710 /* Copy parts after the box into place */
1711 memcpy(outptr, inptr, g_out_size - 8);
1712 G2FLAGS_SET_BBOX(g_out->gflags, 0);
1713 SIZE_SET(g_out->size, g_out_size);
1714 }
1715 /* No box? Nothing to do but copy and return. */
1716 else
1717 {
1718 memcpy(g_out, g, g_out_size);
1719 }
1720
1721 return g_out;
1722}
#define G2FLAGS_NDIMS_BOX(gflags)
#define G2FLAGS_GET_BBOX(gflags)
#define G2FLAGS_GET_EXTENDED(gflags)
#define G2FLAGS_SET_BBOX(gflags, value)
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 G2FLAGS_GET_BBOX, G2FLAGS_GET_EXTENDED, G2FLAGS_NDIMS_BOX, G2FLAGS_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: