PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwcollection_from_gserialized_buffer()

static LWCOLLECTION* lwcollection_from_gserialized_buffer ( uint8_t data_ptr,
uint8_t  g_flags,
size_t *  g_size 
)
static

Definition at line 1432 of file g_serialized.c.

1433 {
1434  uint32_t type;
1435  uint8_t *start_ptr = data_ptr;
1436  LWCOLLECTION *collection;
1437  uint32_t ngeoms = 0;
1438  uint32_t i = 0;
1439 
1440  assert(data_ptr);
1441 
1442  type = gserialized_get_uint32_t(data_ptr);
1443  data_ptr += 4; /* Skip past the type. */
1444 
1445  collection = (LWCOLLECTION*)lwalloc(sizeof(LWCOLLECTION));
1446  collection->srid = SRID_UNKNOWN; /* Default */
1447  collection->bbox = NULL;
1448  collection->type = type;
1449  collection->flags = g_flags;
1450 
1451  ngeoms = gserialized_get_uint32_t(data_ptr);
1452  collection->ngeoms = ngeoms; /* Zero => empty geometry */
1453  data_ptr += 4; /* Skip past the ngeoms. */
1454 
1455  if ( ngeoms > 0 )
1456  {
1457  collection->geoms = lwalloc(sizeof(LWGEOM*) * ngeoms);
1458  collection->maxgeoms = ngeoms;
1459  }
1460  else
1461  {
1462  collection->geoms = NULL;
1463  collection->maxgeoms = 0;
1464  }
1465 
1466  /* Sub-geometries are never de-serialized with boxes (#1254) */
1467  FLAGS_SET_BBOX(g_flags, 0);
1468 
1469  for ( i = 0; i < ngeoms; i++ )
1470  {
1471  uint32_t subtype = gserialized_get_uint32_t(data_ptr);
1472  size_t subsize = 0;
1473 
1474  if ( ! lwcollection_allows_subtype(type, subtype) )
1475  {
1476  lwerror("Invalid subtype (%s) for collection type (%s)", lwtype_name(subtype), lwtype_name(type));
1477  lwfree(collection);
1478  return NULL;
1479  }
1480  collection->geoms[i] = lwgeom_from_gserialized_buffer(data_ptr, g_flags, &subsize);
1481  data_ptr += subsize;
1482  }
1483 
1484  if ( g_size )
1485  *g_size = data_ptr - start_ptr;
1486 
1487  return collection;
1488 }
static uint32_t gserialized_get_uint32_t(const uint8_t *loc)
Definition: g_serialized.c:35
static LWGEOM * lwgeom_from_gserialized_buffer(uint8_t *data_ptr, uint8_t g_flags, size_t *g_size)
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:148
void lwfree(void *mem)
Definition: lwutil.c:244
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
int lwcollection_allows_subtype(int collectiontype, int subtype)
Check if subtype is allowed in collectiontype.
Definition: lwcollection.c:534
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
tuple g_size
Definition: genraster.py:41
type
Definition: ovdump.py:41
uint32_t ngeoms
Definition: liblwgeom.h:510
uint32_t maxgeoms
Definition: liblwgeom.h:511
uint8_t type
Definition: liblwgeom.h:506
GBOX * bbox
Definition: liblwgeom.h:508
uint8_t flags
Definition: liblwgeom.h:507
LWGEOM ** geoms
Definition: liblwgeom.h:512
int32_t srid
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

References LWCOLLECTION::bbox, LWCOLLECTION::flags, FLAGS_SET_BBOX, genraster::g_size, LWCOLLECTION::geoms, gserialized_get_uint32_t(), lwalloc(), lwcollection_allows_subtype(), lwerror(), lwfree(), lwgeom_from_gserialized_buffer(), lwtype_name(), LWCOLLECTION::maxgeoms, LWCOLLECTION::ngeoms, LWCOLLECTION::srid, SRID_UNKNOWN, LWCOLLECTION::type, and ovdump::type.

Referenced by lwgeom_from_gserialized_buffer().

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