PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwcollection_from_gserialized2_buffer()

static LWCOLLECTION* lwcollection_from_gserialized2_buffer ( uint8_t *  data_ptr,
lwflags_t  lwflags,
size_t *  size 
)
static

Definition at line 1418 of file gserialized2.c.

1419 {
1420  uint32_t type;
1421  uint8_t *start_ptr = data_ptr;
1422  LWCOLLECTION *collection;
1423  uint32_t ngeoms = 0;
1424  uint32_t i = 0;
1425 
1426  assert(data_ptr);
1427 
1428  type = gserialized2_get_uint32_t(data_ptr);
1429  data_ptr += 4; /* Skip past the type. */
1430 
1431  collection = (LWCOLLECTION*)lwalloc(sizeof(LWCOLLECTION));
1432  collection->srid = SRID_UNKNOWN; /* Default */
1433  collection->bbox = NULL;
1434  collection->type = type;
1435  collection->flags = lwflags;
1436 
1437  ngeoms = gserialized2_get_uint32_t(data_ptr);
1438  collection->ngeoms = ngeoms; /* Zero => empty geometry */
1439  data_ptr += 4; /* Skip past the ngeoms. */
1440 
1441  if (ngeoms > 0)
1442  {
1443  collection->geoms = lwalloc(sizeof(LWGEOM*) * ngeoms);
1444  collection->maxgeoms = ngeoms;
1445  }
1446  else
1447  {
1448  collection->geoms = NULL;
1449  collection->maxgeoms = 0;
1450  }
1451 
1452  /* Sub-geometries are never de-serialized with boxes (#1254) */
1453  FLAGS_SET_BBOX(lwflags, 0);
1454 
1455  for (i = 0; i < ngeoms; i++)
1456  {
1457  uint32_t subtype = gserialized2_get_uint32_t(data_ptr);
1458  size_t subsize = 0;
1459 
1460  if (!lwcollection_allows_subtype(type, subtype))
1461  {
1462  lwerror("Invalid subtype (%s) for collection type (%s)", lwtype_name(subtype), lwtype_name(type));
1463  lwfree(collection);
1464  return NULL;
1465  }
1466  collection->geoms[i] = lwgeom_from_gserialized2_buffer(data_ptr, lwflags, &subsize);
1467  data_ptr += subsize;
1468  }
1469 
1470  if (size)
1471  *size = data_ptr - start_ptr;
1472 
1473  return collection;
1474 }
static uint32_t gserialized2_get_uint32_t(const uint8_t *loc)
Definition: gserialized2.c:129
static LWGEOM * lwgeom_from_gserialized2_buffer(uint8_t *data_ptr, lwflags_t lwflags, size_t *size)
#define FLAGS_SET_BBOX(flags, value)
Definition: liblwgeom.h:188
void lwfree(void *mem)
Definition: lwutil.c:242
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
void * lwalloc(size_t size)
Definition: lwutil.c:227
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition: lwutil.c:471
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:229
int lwcollection_allows_subtype(int collectiontype, int subtype)
Check if subtype is allowed in collectiontype.
Definition: lwcollection.c:523
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
type
Definition: ovdump.py:42
lwflags_t flags
Definition: liblwgeom.h:563
uint32_t ngeoms
Definition: liblwgeom.h:566
uint32_t maxgeoms
Definition: liblwgeom.h:567
uint8_t type
Definition: liblwgeom.h:564
GBOX * bbox
Definition: liblwgeom.h:560
LWGEOM ** geoms
Definition: liblwgeom.h:561
int32_t srid
Definition: liblwgeom.h:562

References LWCOLLECTION::bbox, LWCOLLECTION::flags, FLAGS_SET_BBOX, LWCOLLECTION::geoms, gserialized2_get_uint32_t(), lwalloc(), lwcollection_allows_subtype(), lwerror(), lwflags(), lwfree(), lwgeom_from_gserialized2_buffer(), lwtype_name(), LWCOLLECTION::maxgeoms, LWCOLLECTION::ngeoms, LWCOLLECTION::srid, SRID_UNKNOWN, LWCOLLECTION::type, and ovdump::type.

Referenced by lwgeom_from_gserialized2_buffer().

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