PostGIS  2.1.10dev-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 87 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, lwgeom_is_empty(), 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().

88 {
89  int hasz = FLAGS_GET_Z(flags);
90  int hasm = FLAGS_GET_M(flags);
91  int i = 0;
92 
93  /* Error on junk */
94  if( ! geom )
95  return LW_FAILURE;
96 
97  FLAGS_SET_Z(geom->flags, hasz);
98  FLAGS_SET_M(geom->flags, hasm);
99 
100  if( ! lwgeom_is_empty(geom) )
101  {
102  if( geom->type == POINTTYPE )
103  {
104  LWPOINT *pt = (LWPOINT*)geom;
105  FLAGS_SET_Z(pt->point->flags, hasz);
106  FLAGS_SET_M(pt->point->flags, hasm);
107  return LW_SUCCESS;
108  }
109  else if ( (geom->type == TRIANGLETYPE) ||
110  (geom->type == CIRCSTRINGTYPE) ||
111  (geom->type == LINETYPE) )
112  {
113  LWLINE *ln = (LWLINE*)geom;
114  FLAGS_SET_Z(ln->points->flags, hasz);
115  FLAGS_SET_M(ln->points->flags, hasm);
116  return LW_SUCCESS;
117  }
118  else if ( geom->type == POLYGONTYPE )
119  {
120  LWPOLY *poly = (LWPOLY*)geom;
121  for ( i = 0; i < poly->nrings; i++ )
122  {
123  FLAGS_SET_Z(poly->rings[i]->flags, hasz);
124  FLAGS_SET_M(poly->rings[i]->flags, hasm);
125  }
126  return LW_SUCCESS;
127  }
128  else if ( geom->type == CURVEPOLYTYPE )
129  {
130  LWCURVEPOLY *poly = (LWCURVEPOLY*)geom;
131  for ( i = 0; i < poly->nrings; i++ )
132  wkt_parser_set_dims(poly->rings[i], flags);
133  return LW_SUCCESS;
134  }
135  else if ( lwtype_is_collection(geom->type) )
136  {
137  LWCOLLECTION *col = (LWCOLLECTION*)geom;
138  for ( i = 0; i < col->ngeoms; i++ )
139  wkt_parser_set_dims(col->geoms[i], flags);
140  return LW_SUCCESS;
141  }
142  else
143  {
144  LWDEBUGF(2,"Unknown geometry type: %d", geom->type);
145  return LW_FAILURE;
146  }
147  }
148  return LW_SUCCESS;
149 }
#define LINETYPE
Definition: liblwgeom.h:61
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
LWGEOM ** rings
Definition: liblwgeom.h:491
#define POLYGONTYPE
Definition: liblwgeom.h:62
uint8_t flags
Definition: liblwgeom.h:353
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define LW_SUCCESS
Definition: liblwgeom.h:55
#define TRIANGLETYPE
Definition: liblwgeom.h:73
POINTARRAY * point
Definition: liblwgeom.h:367
#define LW_FAILURE
Definition: liblwgeom.h:54
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:112
uint8_t flags
Definition: liblwgeom.h:325
LWGEOM ** geoms
Definition: liblwgeom.h:465
POINTARRAY ** rings
Definition: liblwgeom.h:413
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:955
int nrings
Definition: liblwgeom.h:411
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
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:1229
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:113
POINTARRAY * points
Definition: liblwgeom.h:378

Here is the call graph for this function:

Here is the caller graph for this function: