PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwcollection_from_gserialized1_buffer()

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

Definition at line 1345 of file gserialized1.c.

1346{
1347 uint32_t type;
1348 uint8_t *start_ptr = data_ptr;
1349 LWCOLLECTION *collection;
1350 uint32_t ngeoms = 0;
1351 uint32_t i = 0;
1352
1353 assert(data_ptr);
1354
1355 type = gserialized1_get_uint32_t(data_ptr);
1356 data_ptr += 4; /* Skip past the type. */
1357
1358 collection = (LWCOLLECTION*)lwalloc(sizeof(LWCOLLECTION));
1359 collection->srid = SRID_UNKNOWN; /* Default */
1360 collection->bbox = NULL;
1361 collection->type = type;
1362 collection->flags = lwflags;
1363
1364 ngeoms = gserialized1_get_uint32_t(data_ptr);
1365 collection->ngeoms = ngeoms; /* Zero => empty geometry */
1366 data_ptr += 4; /* Skip past the ngeoms. */
1367
1368 if ( ngeoms > 0 )
1369 {
1370 collection->geoms = lwalloc(sizeof(LWGEOM*) * ngeoms);
1371 collection->maxgeoms = ngeoms;
1372 }
1373 else
1374 {
1375 collection->geoms = NULL;
1376 collection->maxgeoms = 0;
1377 }
1378
1379 /* Sub-geometries are never de-serialized with boxes (#1254) */
1381
1382 for ( i = 0; i < ngeoms; i++ )
1383 {
1384 uint32_t subtype = gserialized1_get_uint32_t(data_ptr);
1385 size_t subsize = 0;
1386
1387 if ( ! lwcollection_allows_subtype(type, subtype) )
1388 {
1389 lwerror("Invalid subtype (%s) for collection type (%s)", lwtype_name(subtype), lwtype_name(type));
1390 lwfree(collection);
1391 return NULL;
1392 }
1393 collection->geoms[i] = lwgeom_from_gserialized1_buffer(data_ptr, lwflags, &subsize);
1394 data_ptr += subsize;
1395 }
1396
1397 if ( size )
1398 *size = data_ptr - start_ptr;
1399
1400 return collection;
1401}
static LWGEOM * lwgeom_from_gserialized1_buffer(uint8_t *data_ptr, lwflags_t lwflags, size_t *size)
static uint32_t gserialized1_get_uint32_t(const uint8_t *loc)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
#define FLAGS_SET_BBOX(flags, value)
Definition liblwgeom.h:188
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:242
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.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition lwutil.c:190
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, gserialized1_get_uint32_t(), lwalloc(), lwcollection_allows_subtype(), lwerror(), lwflags(), lwfree(), lwgeom_from_gserialized1_buffer(), lwtype_name(), LWCOLLECTION::maxgeoms, LWCOLLECTION::ngeoms, LWCOLLECTION::srid, SRID_UNKNOWN, and LWCOLLECTION::type.

Referenced by lwgeom_from_gserialized1_buffer().

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