PostGIS  2.2.7dev-r@@SVN_REVISION@@
POINTARRAY* wkt_parser_ptarray_add_coord ( POINTARRAY pa,
POINT  p 
)

Definition at line 251 of file lwin_wkt.c.

References POINT::flags, POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_NDIMS, LW_TRUE, LWDEBUG, POINT::m, POINT4D::m, PARSER_ERROR_MIXDIMS, PARSER_ERROR_OTHER, ptarray_append_point(), ptarray_free(), SET_PARSER_ERROR, POINT::x, POINT4D::x, POINT::y, POINT4D::y, POINT::z, and POINT4D::z.

Referenced by wkt_parser_ptarray_new(), and yyparse().

252 {
253  POINT4D pt;
254  LWDEBUG(4,"entered");
255 
256  /* Error on trouble */
257  if( ! pa )
258  {
260  return NULL;
261  }
262 
263  /* Check that the coordinate has the same dimesionality as the array */
264  if( FLAGS_NDIMS(p.flags) != FLAGS_NDIMS(pa->flags) )
265  {
266  ptarray_free(pa);
268  return NULL;
269  }
270 
271  /* While parsing the point arrays, XYM and XMZ points are both treated as XYZ */
272  pt.x = p.x;
273  pt.y = p.y;
274  if( FLAGS_GET_Z(pa->flags) )
275  pt.z = p.z;
276  if( FLAGS_GET_M(pa->flags) )
277  pt.m = p.m;
278  /* If the destination is XYM, we'll write the third coordinate to m */
279  if( FLAGS_GET_M(pa->flags) && ! FLAGS_GET_Z(pa->flags) )
280  pt.m = p.z;
281 
282  ptarray_append_point(pa, &pt, LW_TRUE); /* Allow duplicate points in array */
283  return pa;
284 }
double x
Definition: lwin_wkt.h:10
double x
Definition: liblwgeom.h:336
double m
Definition: lwin_wkt.h:13
double m
Definition: liblwgeom.h:336
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
double y
Definition: lwin_wkt.h:11
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:1895
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_TRUE, then a duplicate point will not be added.
Definition: ptarray.c:156
uint8_t flags
Definition: liblwgeom.h:353
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
double z
Definition: lwin_wkt.h:12
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:124
double z
Definition: liblwgeom.h:336
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:38
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:125
double y
Definition: liblwgeom.h:336
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:136
uint8_t flags
Definition: lwin_wkt.h:9
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:1901

Here is the call graph for this function:

Here is the caller graph for this function: