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

Definition at line 238 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().

239 {
240  POINT4D pt;
241  LWDEBUG(4,"entered");
242 
243  /* Error on trouble */
244  if( ! pa )
245  {
247  return NULL;
248  }
249 
250  /* Check that the coordinate has the same dimesionality as the array */
251  if( FLAGS_NDIMS(p.flags) != FLAGS_NDIMS(pa->flags) )
252  {
253  ptarray_free(pa);
255  return NULL;
256  }
257 
258  /* While parsing the point arrays, XYM and XMZ points are both treated as XYZ */
259  pt.x = p.x;
260  pt.y = p.y;
261  if( FLAGS_GET_Z(pa->flags) )
262  pt.z = p.z;
263  if( FLAGS_GET_M(pa->flags) )
264  pt.m = p.m;
265  /* If the destination is XYM, we'll write the third coordinate to m */
266  if( FLAGS_GET_M(pa->flags) && ! FLAGS_GET_Z(pa->flags) )
267  pt.m = p.z;
268 
269  ptarray_append_point(pa, &pt, LW_TRUE); /* Allow duplicate points in array */
270  return pa;
271 }
double x
Definition: lwin_wkt.h:10
double x
Definition: liblwgeom.h:308
double m
Definition: lwin_wkt.h:13
double m
Definition: liblwgeom.h:308
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:315
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
double y
Definition: lwin_wkt.h:11
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:1732
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:141
uint8_t flags
Definition: liblwgeom.h:325
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
double z
Definition: lwin_wkt.h:12
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
double z
Definition: liblwgeom.h:308
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:38
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
double y
Definition: liblwgeom.h:308
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:118
uint8_t flags
Definition: lwin_wkt.h:9
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:1738

Here is the call graph for this function:

Here is the caller graph for this function: