PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ 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 685 of file lwin_wkb.c.

686 {
687  uint32_t ngeoms = integer_from_wkb_state(s);
688  if (s->error)
689  return NULL;
690  LWCOLLECTION *col = lwcollection_construct_empty(s->lwtype, s->srid, s->has_z, s->has_m);
691  LWGEOM *geom = NULL;
692  uint32_t i;
693 
694  LWDEBUGF(4,"Collection has %d components", ngeoms);
695 
696  /* Empty collection? */
697  if ( ngeoms == 0 )
698  return col;
699 
700  /* Be strict in polyhedral surface closures */
701  if ( s->lwtype == POLYHEDRALSURFACETYPE )
702  s->check |= LW_PARSER_CHECK_ZCLOSURE;
703 
704  s->depth++;
705  if (s->depth >= LW_PARSER_MAX_DEPTH)
706  {
707  lwcollection_free(col);
708  lwerror("Geometry has too many chained collections");
709  return NULL;
710  }
711  for ( i = 0; i < ngeoms; i++ )
712  {
713  geom = lwgeom_from_wkb_state(s);
714  if ( lwcollection_add_lwgeom(col, geom) == NULL )
715  {
716  lwgeom_free(geom);
717  lwgeom_free((LWGEOM *)col);
718  lwerror("Unable to add geometry (%p) to collection (%p)", geom, col);
719  return NULL;
720  }
721  }
722  s->depth--;
723 
724  return col;
725 }
char * s
Definition: cu_in_wkt.c:23
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
#define LW_PARSER_CHECK_ZCLOSURE
Definition: liblwgeom.h:2112
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:114
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
Definition: lwcollection.c:92
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:357
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
Definition: lwcollection.c:188
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
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:735

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: