PostGIS 3.7.0dev-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 1346 of file gserialized1.c.

1347{
1348 uint32_t type;
1349 uint8_t *start_ptr = data_ptr;
1350 LWCOLLECTION *collection;
1351 uint32_t ngeoms = 0;
1352 uint32_t i = 0;
1353
1354 assert(data_ptr);
1355
1356 type = gserialized1_get_uint32_t(data_ptr);
1357 data_ptr += 4; /* Skip past the type. */
1358
1359 collection = (LWCOLLECTION*)lwalloc(sizeof(LWCOLLECTION));
1360 collection->srid = SRID_UNKNOWN; /* Default */
1361 collection->bbox = NULL;
1362 collection->type = type;
1363 collection->flags = lwflags;
1364
1365 ngeoms = gserialized1_get_uint32_t(data_ptr);
1366 collection->ngeoms = ngeoms; /* Zero => empty geometry */
1367 data_ptr += 4; /* Skip past the ngeoms. */
1368
1369 if ( ngeoms > 0 )
1370 {
1371 collection->geoms = lwalloc(sizeof(LWGEOM*) * ngeoms);
1372 collection->maxgeoms = ngeoms;
1373 }
1374 else
1375 {
1376 collection->geoms = NULL;
1377 collection->maxgeoms = 0;
1378 }
1379
1380 /* Sub-geometries are never de-serialized with boxes (#1254) */
1382
1383 for ( i = 0; i < ngeoms; i++ )
1384 {
1385 uint32_t subtype = gserialized1_get_uint32_t(data_ptr);
1386 size_t subsize = 0;
1387
1388 if ( ! lwcollection_allows_subtype(type, subtype) )
1389 {
1390 lwerror("Invalid subtype (%s) for collection type (%s)", lwtype_name(subtype), lwtype_name(type));
1391 lwfree(collection);
1392 return NULL;
1393 }
1394 collection->geoms[i] = lwgeom_from_gserialized1_buffer(data_ptr, lwflags, &subsize);
1395 data_ptr += subsize;
1396 }
1397
1398 if ( size )
1399 *size = data_ptr - start_ptr;
1400
1401 return collection;
1402}
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:174
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:248
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition lwutil.c:477
#define SRID_UNKNOWN
Unknown SRID value.
Definition liblwgeom.h:215
int lwcollection_allows_subtype(int collectiontype, int subtype)
Check if subtype is allowed in collectiontype.
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
lwflags_t flags
Definition liblwgeom.h:577
uint32_t ngeoms
Definition liblwgeom.h:580
uint32_t maxgeoms
Definition liblwgeom.h:581
uint8_t type
Definition liblwgeom.h:578
GBOX * bbox
Definition liblwgeom.h:574
LWGEOM ** geoms
Definition liblwgeom.h:575
int32_t srid
Definition liblwgeom.h:576

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: