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

◆ lwcollection_from_wkb_state()

static LWCOLLECTION * lwcollection_from_wkb_state ( wkb_parse_state s)
static

POLYHEDRALSURFACETYPE.

COLLECTION, MULTIPOINTTYPE, MULTILINETYPE, MULTIPOLYGONTYPE, COMPOUNDTYPE, MULTICURVETYPE, MULTISURFACETYPE, TINTYPE

Definition at line 693 of file lwin_wkb.c.

694{
695 uint32_t ngeoms = integer_from_wkb_state(s);
696 if (s->error)
697 return NULL;
698 LWCOLLECTION *col = lwcollection_construct_empty(s->lwtype, s->srid, s->has_z, s->has_m);
699 LWGEOM *geom = NULL;
700 uint32_t i;
701
702 LWDEBUGF(4,"Collection has %d components", ngeoms);
703
704 /* Empty collection? */
705 if ( ngeoms == 0 )
706 return col;
707
708 /* Be strict in polyhedral surface closures */
709 if ( s->lwtype == POLYHEDRALSURFACETYPE )
710 s->check |= LW_PARSER_CHECK_ZCLOSURE;
711
712 s->depth++;
713 if (s->depth >= LW_PARSER_MAX_DEPTH)
714 {
716 lwerror("Geometry has too many chained collections");
717 return NULL;
718 }
719 for ( i = 0; i < ngeoms; i++ )
720 {
721 geom = lwgeom_from_wkb_state(s);
722 if ( lwcollection_add_lwgeom(col, geom) == NULL )
723 {
724 lwgeom_free(geom);
725 lwgeom_free((LWGEOM *)col);
726 lwerror("Unable to add geometry (%p) to collection (%p)", (void *) geom, (void *) col);
727 return NULL;
728 }
729 }
730 s->depth--;
731
732 return col;
733}
char * s
Definition cu_in_wkt.c:23
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
#define LW_PARSER_CHECK_ZCLOSURE
Definition liblwgeom.h:2147
#define POLYHEDRALSURFACETYPE
Definition liblwgeom.h:114
void lwcollection_free(LWCOLLECTION *col)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static uint32_t integer_from_wkb_state(wkb_parse_state *s)
Int32 Read 4-byte integer and advance the parse state forward.
Definition lwin_wkb.c:285
#define LW_PARSER_MAX_DEPTH
Max depth in a geometry.
Definition lwin_wkb.c:34
LWGEOM * lwgeom_from_wkb_state(wkb_parse_state *s)
Internal function declarations.
Definition lwin_wkb.c:743

References integer_from_wkb_state(), LW_PARSER_CHECK_ZCLOSURE, LW_PARSER_MAX_DEPTH, lwcollection_add_lwgeom(), lwcollection_construct_empty(), lwcollection_free(), LWDEBUGF, lwerror(), lwgeom_free(), lwgeom_from_wkb_state(), POLYHEDRALSURFACETYPE, and s.

Referenced by lwgeom_from_wkb_state().

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