PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWGEOM* wkt_parser_collection_finalize ( int  lwtype,
LWGEOM col,
char *  dimensionality 
)

Definition at line 752 of file lwin_wkt.c.

References COLLECTIONTYPE, LWGEOM::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, LW_FAILURE, lwcollection_as_lwgeom(), lwcollection_construct_empty(), lwgeom_free(), PARSER_ERROR_MIXDIMS, PARSER_ERROR_OTHER, SET_PARSER_ERROR, SRID_UNKNOWN, LWGEOM::type, wkt_dimensionality(), and wkt_parser_set_dims().

Referenced by yyparse().

753 {
754  uint8_t flags = wkt_dimensionality(dimensionality);
755  int flagdims = FLAGS_NDIMS(flags);
756 
757  /* No geometry means it is empty */
758  if( ! col )
759  {
761  }
762 
763  /* There are 'Z' or 'M' tokens in the signature */
764  if ( flagdims > 2 )
765  {
766  /* If the number of dimensions are not consistent, we have a problem. */
767  if( flagdims != FLAGS_NDIMS(col->flags) )
768  {
769  lwgeom_free(col);
771  return NULL;
772  }
773 
774  /* For GEOMETRYCOLLECTION, the exact type of the dimensions must match too */
775  if( lwtype == COLLECTIONTYPE &&
776  ( (FLAGS_GET_Z(flags) != FLAGS_GET_Z(col->flags)) ||
777  (FLAGS_GET_M(flags) != FLAGS_GET_M(col->flags)) ) )
778  {
779  lwgeom_free(col);
781  return NULL;
782  }
783 
784  /* Harmonize the collection dimensionality */
785  if( LW_FAILURE == wkt_parser_set_dims(col, flags) )
786  {
787  lwgeom_free(col);
789  return NULL;
790  }
791  }
792 
793  /* Set the collection type */
794  col->type=lwtype;
795 
796  return col;
797 }
static int wkt_parser_set_dims(LWGEOM *geom, uint8_t flags)
Force the dimensionality of a geometry to match the dimensionality of a set of flags (usually derived...
Definition: lwin_wkt.c:87
uint8_t flags
Definition: liblwgeom.h:353
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:1732
#define LW_FAILURE
Definition: liblwgeom.h:54
static uint8_t wkt_dimensionality(char *dimensionality)
Definition: lwin_wkt.c:61
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:154
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:38
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
uint8_t type
Definition: liblwgeom.h:352
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:118
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:1738
#define COLLECTIONTYPE
Definition: liblwgeom.h:66
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:219

Here is the call graph for this function:

Here is the caller graph for this function: