PostGIS  2.1.10dev-r@@SVN_REVISION@@
static int wkt_pointarray_dimensionality ( POINTARRAY pa,
uint8_t  flags 
)
static

Read the dimensionality from a flag, if provided.

Then check that the dimensionality matches that of the pointarray. If the dimension counts match, ensure the pointarray is using the right "Z" or "M".

Definition at line 156 of file lwin_wkt.c.

References POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, FLAGS_SET_M, FLAGS_SET_Z, LW_FALSE, LW_TRUE, and LWDEBUGF.

Referenced by wkt_parser_circularstring_new(), wkt_parser_linestring_new(), wkt_parser_point_new(), and wkt_parser_triangle_new().

157 {
158  int hasz = FLAGS_GET_Z(flags);
159  int hasm = FLAGS_GET_M(flags);
160  int ndims = 2 + hasz + hasm;
161 
162  /* No dimensionality or array means we go with what we have */
163  if( ! (flags && pa) )
164  return LW_TRUE;
165 
166  LWDEBUGF(5,"dimensionality ndims == %d", ndims);
167  LWDEBUGF(5,"FLAGS_NDIMS(pa->flags) == %d", FLAGS_NDIMS(pa->flags));
168 
169  /*
170  * ndims > 2 implies that the flags have something useful to add,
171  * that there is a 'Z' or an 'M' or both.
172  */
173  if( ndims > 2 )
174  {
175  /* Mismatch implies a problem */
176  if ( FLAGS_NDIMS(pa->flags) != ndims )
177  return LW_FALSE;
178  /* Match means use the explicit dimensionality */
179  else
180  {
181  FLAGS_SET_Z(pa->flags, hasz);
182  FLAGS_SET_M(pa->flags, hasm);
183  }
184  }
185 
186  return LW_TRUE;
187 }
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:112
#define LW_FALSE
Definition: liblwgeom.h:52
uint8_t flags
Definition: liblwgeom.h:325
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:118
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:113

Here is the caller graph for this function: