PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ wkt_parser_collection_finalize()

LWGEOM* wkt_parser_collection_finalize ( int  lwtype,
LWGEOM geom,
char *  dimensionality 
)

Definition at line 805 of file lwin_wkt.c.

806 {
807  uint8_t flags = wkt_dimensionality(dimensionality);
808  int flagdims = FLAGS_NDIMS(flags);
809 
810  /* No geometry means it is empty */
811  if( ! geom )
812  {
814  }
815 
816  /* There are 'Z' or 'M' tokens in the signature */
817  if ( flagdims > 2 )
818  {
820  uint32_t i;
821 
822  for ( i = 0 ; i < col->ngeoms; i++ )
823  {
824  LWGEOM *subgeom = col->geoms[i];
825  if ( FLAGS_NDIMS(flags) != FLAGS_NDIMS(subgeom->flags) &&
826  ! lwgeom_is_empty(subgeom) )
827  {
828  lwgeom_free(geom);
830  return NULL;
831  }
832 
833  if ( lwtype == COLLECTIONTYPE &&
834  ( (FLAGS_GET_Z(flags) != FLAGS_GET_Z(subgeom->flags)) ||
835  (FLAGS_GET_M(flags) != FLAGS_GET_M(subgeom->flags)) ) &&
836  ! lwgeom_is_empty(subgeom) )
837  {
838  lwgeom_free(geom);
840  return NULL;
841  }
842  }
843 
844  /* Harmonize the collection dimensionality */
845  if( LW_FAILURE == wkt_parser_set_dims(geom, flags) )
846  {
847  lwgeom_free(geom);
849  return NULL;
850  }
851  }
852 
853  /* Set the collection type */
854  geom->type = lwtype;
855 
856  return geom;
857 }
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:2031
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:300
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94
#define LW_FAILURE
Definition: liblwgeom.h:79
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:2037
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
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:1393
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:224
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
static uint8_t wkt_dimensionality(char *dimensionality)
Definition: lwin_wkt.c:75
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:52
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:101
uint32_t ngeoms
Definition: liblwgeom.h:510
LWGEOM ** geoms
Definition: liblwgeom.h:512
uint8_t type
Definition: liblwgeom.h:399
uint8_t flags
Definition: liblwgeom.h:400
unsigned int uint32_t
Definition: uthash.h:78
unsigned char uint8_t
Definition: uthash.h:79

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().

Here is the call graph for this function: