PostGIS  3.0.6dev-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 676 of file lwin_wkb.c.

677 {
678  uint32_t ngeoms = integer_from_wkb_state(s);
679  if (s->error)
680  return NULL;
681  LWCOLLECTION *col = lwcollection_construct_empty(s->lwtype, s->srid, s->has_z, s->has_m);
682  LWGEOM *geom = NULL;
683  uint32_t i;
684 
685  LWDEBUGF(4,"Collection has %d components", ngeoms);
686 
687  /* Empty collection? */
688  if ( ngeoms == 0 )
689  return col;
690 
691  /* Be strict in polyhedral surface closures */
692  if ( s->lwtype == POLYHEDRALSURFACETYPE )
693  s->check |= LW_PARSER_CHECK_ZCLOSURE;
694 
695  s->depth++;
696  if (s->depth >= LW_PARSER_MAX_DEPTH)
697  {
698  lwcollection_free(col);
699  lwerror("Geometry has too many chained collections");
700  return NULL;
701  }
702  for ( i = 0; i < ngeoms; i++ )
703  {
704  geom = lwgeom_from_wkb_state(s);
705  if ( lwcollection_add_lwgeom(col, geom) == NULL )
706  {
707  lwgeom_free(geom);
708  lwgeom_free((LWGEOM *)col);
709  lwerror("Unable to add geometry (%p) to collection (%p)", geom, col);
710  return NULL;
711  }
712  }
713  s->depth--;
714 
715  return col;
716 }
char * s
Definition: cu_in_wkt.c:23
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
#define LW_PARSER_CHECK_ZCLOSURE
Definition: liblwgeom.h:2058
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:128
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:278
#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:726

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: