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

Definition at line 791 of file lwin_wkt.c.

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

Referenced by yyparse().

792 {
793  uint8_t flags = wkt_dimensionality(dimensionality);
794  int flagdims = FLAGS_NDIMS(flags);
795 
796  /* No geometry means it is empty */
797  if( ! geom )
798  {
800  }
801 
802  /* There are 'Z' or 'M' tokens in the signature */
803  if ( flagdims > 2 )
804  {
806  int i;
807 
808  for ( i = 0 ; i < col->ngeoms; i++ )
809  {
810  LWGEOM *subgeom = col->geoms[i];
811  if ( FLAGS_NDIMS(flags) != FLAGS_NDIMS(subgeom->flags) &&
812  ! lwgeom_is_empty(subgeom) )
813  {
814  lwgeom_free(geom);
816  return NULL;
817  }
818 
819  if ( lwtype == COLLECTIONTYPE &&
820  ( (FLAGS_GET_Z(flags) != FLAGS_GET_Z(subgeom->flags)) ||
821  (FLAGS_GET_M(flags) != FLAGS_GET_M(subgeom->flags)) ) &&
822  ! lwgeom_is_empty(subgeom) )
823  {
824  lwgeom_free(geom);
826  return NULL;
827  }
828  }
829 
830  /* Harmonize the collection dimensionality */
831  if( LW_FAILURE == wkt_parser_set_dims(geom, flags) )
832  {
833  lwgeom_free(geom);
835  return NULL;
836  }
837  }
838 
839  /* Set the collection type */
840  geom->type = lwtype;
841 
842  return geom;
843 }
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:381
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:1895
#define LW_FAILURE
Definition: liblwgeom.h:64
LWGEOM ** geoms
Definition: liblwgeom.h:493
static uint8_t wkt_dimensionality(char *dimensionality)
Definition: lwin_wkt.c:61
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:172
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:143
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:38
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
uint8_t type
Definition: liblwgeom.h:380
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1297
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:136
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:1901
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
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: