PostGIS  2.3.7dev-r@@SVN_REVISION@@
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.

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

102 {
103  int hasz = FLAGS_GET_Z(flags);
104  int hasm = FLAGS_GET_M(flags);
105  int 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 LINETYPE
Definition: liblwgeom.h:85
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
LWGEOM ** rings
Definition: liblwgeom.h:534
#define POLYGONTYPE
Definition: liblwgeom.h:86
uint8_t flags
Definition: liblwgeom.h:396
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define LW_SUCCESS
Definition: liblwgeom.h:79
#define TRIANGLETYPE
Definition: liblwgeom.h:97
POINTARRAY * point
Definition: liblwgeom.h:410
#define LW_FAILURE
Definition: liblwgeom.h:78
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:145
uint8_t flags
Definition: liblwgeom.h:368
LWGEOM ** geoms
Definition: liblwgeom.h:508
POINTARRAY ** rings
Definition: liblwgeom.h:456
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:1012
int nrings
Definition: liblwgeom.h:454
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
uint8_t type
Definition: liblwgeom.h:395
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:146
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: