PostGIS  2.4.9dev-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 183 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().

184 {
185  int hasz = FLAGS_GET_Z(flags);
186  int hasm = FLAGS_GET_M(flags);
187  int ndims = 2 + hasz + hasm;
188 
189  /* No dimensionality or array means we go with what we have */
190  if( ! (flags && pa) )
191  return LW_TRUE;
192 
193  LWDEBUGF(5,"dimensionality ndims == %d", ndims);
194  LWDEBUGF(5,"FLAGS_NDIMS(pa->flags) == %d", FLAGS_NDIMS(pa->flags));
195 
196  /*
197  * ndims > 2 implies that the flags have something useful to add,
198  * that there is a 'Z' or an 'M' or both.
199  */
200  if( ndims > 2 )
201  {
202  /* Mismatch implies a problem */
203  if ( FLAGS_NDIMS(pa->flags) != ndims )
204  return LW_FALSE;
205  /* Match means use the explicit dimensionality */
206  else
207  {
208  FLAGS_SET_Z(pa->flags, hasz);
209  FLAGS_SET_M(pa->flags, hasm);
210  }
211  }
212 
213  return LW_TRUE;
214 }
#define FLAGS_SET_Z(flags, value)
Definition: liblwgeom.h:146
#define LW_FALSE
Definition: liblwgeom.h:77
uint8_t flags
Definition: liblwgeom.h:369
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
#define FLAGS_SET_M(flags, value)
Definition: liblwgeom.h:147
Here is the caller graph for this function: