PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ ptarray_merge()

POINTARRAY* ptarray_merge ( POINTARRAY pa1,

Merge two given POINTARRAY and returns a pointer on the new aggregate one.

Warning: this function free the two inputs POINTARRAY

POINTARRAY is newly allocated

Definition at line 603 of file ptarray.c.

References POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_GET_ZM, getPoint_internal(), lwerror(), POINTARRAY::npoints, ptarray_construct(), ptarray_free(), and ptarray_point_size().

Referenced by parse_gml_data().

604 {
605  POINTARRAY *pa;
606  size_t ptsize = ptarray_point_size(pa1);
608  if (FLAGS_GET_ZM(pa1->flags) != FLAGS_GET_ZM(pa2->flags))
609  lwerror("ptarray_cat: Mixed dimension");
611  pa = ptarray_construct( FLAGS_GET_Z(pa1->flags),
612  FLAGS_GET_M(pa1->flags),
613  pa1->npoints + pa2->npoints);
615  memcpy( getPoint_internal(pa, 0),
616  getPoint_internal(pa1, 0),
617  ptsize*(pa1->npoints));
619  memcpy( getPoint_internal(pa, pa1->npoints),
620  getPoint_internal(pa2, 0),
621  ptsize*(pa2->npoints));
623  ptarray_free(pa1);
624  ptarray_free(pa2);
626  return pa;
627 }
int ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
int npoints
Definition: liblwgeom.h:370
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:152
uint8_t flags
Definition: liblwgeom.h:368
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition: ptarray.c:62
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:139
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1706
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
Here is the call graph for this function:
Here is the caller graph for this function: