PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ wkt_pointarray_dimensionality()

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

170 {
171  int hasz = FLAGS_GET_Z(flags);
172  int hasm = FLAGS_GET_M(flags);
173  int ndims = 2 + hasz + hasm;
174 
175  /* No dimensionality or array means we go with what we have */
176  if( ! (flags && pa) )
177  return LW_TRUE;
178 
179  LWDEBUGF(5,"dimensionality ndims == %d", ndims);
180  LWDEBUGF(5,"FLAGS_NDIMS(pa->flags) == %d", FLAGS_NDIMS(pa->flags));
181 
182  /*
183  * ndims > 2 implies that the flags have something useful to add,
184  * that there is a 'Z' or an 'M' or both.
185  */
186  if( ndims > 2 )
187  {
188  /* Mismatch implies a problem */
189  if ( FLAGS_NDIMS(pa->flags) != ndims )
190  return LW_FALSE;
191  /* Match means use the explicit dimensionality */
192  else
193  {
194  FLAGS_SET_Z(pa->flags, hasz);
195  FLAGS_SET_M(pa->flags, hasm);
196  }
197  }
198 
199  return LW_TRUE;
200 }
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:130
#define LW_FALSE
Definition: liblwgeom.h:62
uint8_t flags
Definition: liblwgeom.h:353
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:136
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:131
Here is the caller graph for this function: