PostGIS  3.4.0dev-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 1635 of file gserialized2.c.

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