PostGIS  2.5.7dev-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 645 of file lwin_wkb.c.

646 {
648  LWCOLLECTION *col = lwcollection_construct_empty(s->lwtype, s->srid, s->has_z, s->has_m);
649  LWGEOM *geom = NULL;
650  uint32_t i;
651 
652  LWDEBUGF(4,"Collection has %d components", ngeoms);
653 
654  /* Empty collection? */
655  if ( ngeoms == 0 )
656  return col;
657 
658  /* Be strict in polyhedral surface closures */
659  if ( s->lwtype == POLYHEDRALSURFACETYPE )
660  s->check |= LW_PARSER_CHECK_ZCLOSURE;
661 
662  s->depth++;
663  if (s->depth >= LW_PARSER_MAX_DEPTH)
664  {
665  lwcollection_free(col);
666  lwerror("Geometry has too many chained collections");
667  return NULL;
668  }
669  for ( i = 0; i < ngeoms; i++ )
670  {
671  geom = lwgeom_from_wkb_state(s);
672  if ( lwcollection_add_lwgeom(col, geom) == NULL )
673  {
674  lwgeom_free(geom);
675  lwgeom_free((LWGEOM *)col);
676  lwerror("Unable to add geometry (%p) to collection (%p)", geom, col);
677  return NULL;
678  }
679  }
680  s->depth--;
681 
682  return col;
683 }
char * s
Definition: cu_in_wkt.c:23
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_PARSER_CHECK_ZCLOSURE
Definition: liblwgeom.h:2003
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:356
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
Definition: lwcollection.c:187
#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:275
#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:693
unsigned int uint32_t
Definition: uthash.h:78

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: