PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ 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 1637 of file gserialized2.c.

1638 {
1639  int g_ndims = G2FLAGS_NDIMS_BOX(g->gflags);
1640  size_t box_size = 2 * g_ndims * sizeof(float);
1641  size_t g_out_size = LWSIZE_GET(g->size) - box_size;
1642  GSERIALIZED *g_out = lwalloc(g_out_size);
1643 
1644  /* Copy the contents while omitting the box */
1645  if (G2FLAGS_GET_BBOX(g->gflags))
1646  {
1647  uint8_t *outptr = (uint8_t*)g_out;
1648  uint8_t *inptr = (uint8_t*)g;
1649  /* Copy the header (size+type) of g into place */
1650  memcpy(outptr, inptr, 8); outptr += 8; inptr += 8;
1651  /* Copy extended flags, if there are any */
1652  if (G2FLAGS_GET_EXTENDED(g->gflags))
1653  {
1654  memcpy(outptr, inptr, 8); outptr += 8; inptr += 8;
1655  }
1656  /* Advance past box */
1657  inptr += box_size;
1658  /* Copy parts after the box into place */
1659  memcpy(outptr, inptr, g_out_size - 8);
1660  G2FLAGS_SET_BBOX(g_out->gflags, 0);
1661  LWSIZE_SET(g_out->size, g_out_size);
1662  }
1663  /* No box? Nothing to do but copy and return. */
1664  else
1665  {
1666  memcpy(g_out, g, g_out_size);
1667  }
1668 
1669  return g_out;
1670 }
#define G2FLAGS_NDIMS_BOX(gflags)
Definition: gserialized2.h:38
#define G2FLAGS_GET_BBOX(gflags)
Definition: gserialized2.h:24
#define G2FLAGS_GET_EXTENDED(gflags)
Definition: gserialized2.h:26
#define G2FLAGS_SET_BBOX(gflags, value)
Definition: gserialized2.h:31
#define LWSIZE_GET(varsize)
Macro for reading the size from the GSERIALIZED size attribute.
Definition: liblwgeom.h:339
#define LWSIZE_SET(varsize, len)
Definition: liblwgeom.h:340
void * lwalloc(size_t size)
Definition: lwutil.c:227
uint32_t size
Definition: liblwgeom.h:459
uint8_t gflags
Definition: liblwgeom.h:461

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: