PostGIS  2.5.7dev-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.

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 }
#define PARSER_ERROR_MIXDIMS
Definition: liblwgeom.h:2031
#define PARSER_ERROR_OTHER
Definition: liblwgeom.h:2037
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:328
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,...
Definition: ptarray.c:156
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define SET_PARSER_ERROR(errno)
Definition: lwin_wkt.c:52
double m
Definition: liblwgeom.h:355
double x
Definition: liblwgeom.h:355
double z
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355
uint8_t flags
Definition: liblwgeom.h:372
double y
Definition: lwin_wkt.h:36
double m
Definition: lwin_wkt.h:38
double z
Definition: lwin_wkt.h:37
double x
Definition: lwin_wkt.h:35
uint8_t flags
Definition: lwin_wkt.h:34

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

Referenced by wkt_parser_ptarray_new().

Here is the call graph for this function:
Here is the caller graph for this function: