PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ wkt_parser_set_dims()

static int wkt_parser_set_dims ( LWGEOM geom,
uint8_t  flags 
)
static

Force the dimensionality of a geometry to match the dimensionality of a set of flags (usually derived from a ZM WKT tag).

Definition at line 101 of file lwin_wkt.c.

102 {
103  int hasz = FLAGS_GET_Z(flags);
104  int hasm = FLAGS_GET_M(flags);
105  uint32_t i = 0;
106 
107  /* Error on junk */
108  if( ! geom )
109  return LW_FAILURE;
110 
111  FLAGS_SET_Z(geom->flags, hasz);
112  FLAGS_SET_M(geom->flags, hasm);
113 
114  switch( geom->type )
115  {
116  case POINTTYPE:
117  {
118  LWPOINT *pt = (LWPOINT*)geom;
119  if ( pt->point )
120  {
121  FLAGS_SET_Z(pt->point->flags, hasz);
122  FLAGS_SET_M(pt->point->flags, hasm);
123  }
124  break;
125  }
126  case TRIANGLETYPE:
127  case CIRCSTRINGTYPE:
128  case LINETYPE:
129  {
130  LWLINE *ln = (LWLINE*)geom;
131  if ( ln->points )
132  {
133  FLAGS_SET_Z(ln->points->flags, hasz);
134  FLAGS_SET_M(ln->points->flags, hasm);
135  }
136  break;
137  }
138  case POLYGONTYPE:
139  {
140  LWPOLY *poly = (LWPOLY*)geom;
141  for ( i = 0; i < poly->nrings; i++ )
142  {
143  if( poly->rings[i] )
144  {
145  FLAGS_SET_Z(poly->rings[i]->flags, hasz);
146  FLAGS_SET_M(poly->rings[i]->flags, hasm);
147  }
148  }
149  break;
150  }
151  case CURVEPOLYTYPE:
152  {
153  LWCURVEPOLY *poly = (LWCURVEPOLY*)geom;
154  for ( i = 0; i < poly->nrings; i++ )
155  wkt_parser_set_dims(poly->rings[i], flags);
156  break;
157  }
158  default:
159  {
160  if ( lwtype_is_collection(geom->type) )
161  {
162  LWCOLLECTION *col = (LWCOLLECTION*)geom;
163  for ( i = 0; i < col->ngeoms; i++ )
164  wkt_parser_set_dims(col->geoms[i], flags);
165  return LW_SUCCESS;
166  }
167  else
168  {
169  LWDEBUGF(2,"Unknown geometry type: %d", geom->type);
170  return LW_FAILURE;
171  }
172  }
173  }
174 
175  return LW_SUCCESS;
176 }
#define LW_FAILURE
Definition: liblwgeom.h:79
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define LINETYPE
Definition: liblwgeom.h:86
#define LW_SUCCESS
Definition: liblwgeom.h:80
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:1093
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:147
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:146
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
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
LWGEOM ** rings
Definition: liblwgeom.h:538
uint32_t nrings
Definition: liblwgeom.h:536
uint8_t type
Definition: liblwgeom.h:399
uint8_t flags
Definition: liblwgeom.h:400
POINTARRAY * points
Definition: liblwgeom.h:425
POINTARRAY * point
Definition: liblwgeom.h:414
POINTARRAY ** rings
Definition: liblwgeom.h:460
uint32_t nrings
Definition: liblwgeom.h:458
uint8_t flags
Definition: liblwgeom.h:372
unsigned int uint32_t
Definition: uthash.h:78

References CIRCSTRINGTYPE, CURVEPOLYTYPE, POINTARRAY::flags, LWGEOM::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_SET_M, FLAGS_SET_Z, LWCOLLECTION::geoms, LINETYPE, LW_FAILURE, LW_SUCCESS, LWDEBUGF, lwtype_is_collection(), LWCOLLECTION::ngeoms, LWPOLY::nrings, LWCURVEPOLY::nrings, LWPOINT::point, LWLINE::points, POINTTYPE, POLYGONTYPE, LWPOLY::rings, LWCURVEPOLY::rings, TRIANGLETYPE, and LWGEOM::type.

Referenced by wkt_parser_collection_finalize(), wkt_parser_curvepolygon_finalize(), and wkt_parser_polygon_finalize().

Here is the call graph for this function:
Here is the caller graph for this function: