PostGIS  2.2.8dev-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 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, 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  switch( geom->type )
101  {
102  case POINTTYPE:
103  {
104  LWPOINT *pt = (LWPOINT*)geom;
105  if ( pt->point )
106  {
107  FLAGS_SET_Z(pt->point->flags, hasz);
108  FLAGS_SET_M(pt->point->flags, hasm);
109  }
110  break;
111  }
112  case TRIANGLETYPE:
113  case CIRCSTRINGTYPE:
114  case LINETYPE:
115  {
116  LWLINE *ln = (LWLINE*)geom;
117  if ( ln->points )
118  {
119  FLAGS_SET_Z(ln->points->flags, hasz);
120  FLAGS_SET_M(ln->points->flags, hasm);
121  }
122  break;
123  }
124  case POLYGONTYPE:
125  {
126  LWPOLY *poly = (LWPOLY*)geom;
127  for ( i = 0; i < poly->nrings; i++ )
128  {
129  if( poly->rings[i] )
130  {
131  FLAGS_SET_Z(poly->rings[i]->flags, hasz);
132  FLAGS_SET_M(poly->rings[i]->flags, hasm);
133  }
134  }
135  break;
136  }
137  case CURVEPOLYTYPE:
138  {
139  LWCURVEPOLY *poly = (LWCURVEPOLY*)geom;
140  for ( i = 0; i < poly->nrings; i++ )
141  wkt_parser_set_dims(poly->rings[i], flags);
142  break;
143  }
144  default:
145  {
146  if ( lwtype_is_collection(geom->type) )
147  {
148  LWCOLLECTION *col = (LWCOLLECTION*)geom;
149  for ( i = 0; i < col->ngeoms; i++ )
150  wkt_parser_set_dims(col->geoms[i], flags);
151  return LW_SUCCESS;
152  }
153  else
154  {
155  LWDEBUGF(2,"Unknown geometry type: %d", geom->type);
156  return LW_FAILURE;
157  }
158  }
159  }
160 
161  return LW_SUCCESS;
162 }
#define LINETYPE
Definition: liblwgeom.h:71
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:519
#define POLYGONTYPE
Definition: liblwgeom.h:72
uint8_t flags
Definition: liblwgeom.h:381
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define LW_SUCCESS
Definition: liblwgeom.h:65
#define TRIANGLETYPE
Definition: liblwgeom.h:83
POINTARRAY * point
Definition: liblwgeom.h:395
#define LW_FAILURE
Definition: liblwgeom.h:64
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:130
uint8_t flags
Definition: liblwgeom.h:353
LWGEOM ** geoms
Definition: liblwgeom.h:493
POINTARRAY ** rings
Definition: liblwgeom.h:441
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition: lwgeom.c:999
int nrings
Definition: liblwgeom.h:439
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:124
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
uint8_t type
Definition: liblwgeom.h:380
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:131
POINTARRAY * points
Definition: liblwgeom.h:406
Here is the call graph for this function:
Here is the caller graph for this function: