PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ wkt_parser_ptarray_add_coord()

POINTARRAY* wkt_parser_ptarray_add_coord ( POINTARRAY pa,
POINT  p 
)

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

266 {
267  POINT4D pt;
268  LWDEBUG(4,"entered");
269 
270  /* Error on trouble */
271  if( ! pa )
272  {
274  return NULL;
275  }
276 
277  /* Check that the coordinate has the same dimesionality as the array */
278  if( FLAGS_NDIMS(p.flags) != FLAGS_NDIMS(pa->flags) )
279  {
280  ptarray_free(pa);
282  return NULL;
283  }
284 
285  /* While parsing the point arrays, XYM and XMZ points are both treated as XYZ */
286  pt.x = p.x;
287  pt.y = p.y;
288  if( FLAGS_GET_Z(pa->flags) )
289  pt.z = p.z;
290  if( FLAGS_GET_M(pa->flags) )
291  pt.m = p.m;
292  /* If the destination is XYM, we'll write the third coordinate to m */
293  if( FLAGS_GET_M(pa->flags) && ! FLAGS_GET_Z(pa->flags) )
294  pt.m = p.z;
295 
296  ptarray_append_point(pa, &pt, LW_TRUE); /* Allow duplicate points in array */
297  return pa;
298 }
double x
Definition: lwin_wkt.h:35
double x
Definition: liblwgeom.h:354
double m
Definition: lwin_wkt.h:38
double m
Definition: liblwgeom.h:354
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:328
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
double y
Definition: lwin_wkt.h:36
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:2030
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_FALSE, then a duplicate point will not be added.
Definition: ptarray.c:156
uint8_t flags
Definition: liblwgeom.h:371
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
double z
Definition: lwin_wkt.h:37
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
double z
Definition: liblwgeom.h:354
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:52
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
double y
Definition: liblwgeom.h:354
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:151
uint8_t flags
Definition: lwin_wkt.h:34
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:2036
Here is the call graph for this function:
Here is the caller graph for this function: