PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ ptarray_merge()

POINTARRAY* ptarray_merge ( POINTARRAY pa1,
POINTARRAY pa2 
)

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

Warning: this function free the two inputs POINTARRAY

Returns
POINTARRAY is newly allocated

Definition at line 612 of file ptarray.c.

613 {
614  POINTARRAY *pa;
615  size_t ptsize = ptarray_point_size(pa1);
616 
617  if (FLAGS_GET_ZM(pa1->flags) != FLAGS_GET_ZM(pa2->flags))
618  lwerror("ptarray_cat: Mixed dimension");
619 
620  pa = ptarray_construct( FLAGS_GET_Z(pa1->flags),
621  FLAGS_GET_M(pa1->flags),
622  pa1->npoints + pa2->npoints);
623 
624  memcpy( getPoint_internal(pa, 0),
625  getPoint_internal(pa1, 0),
626  ptsize*(pa1->npoints));
627 
628  memcpy( getPoint_internal(pa, pa1->npoints),
629  getPoint_internal(pa2, 0),
630  ptsize*(pa2->npoints));
631 
632  ptarray_free(pa1);
633  ptarray_free(pa2);
634 
635  return pa;
636 }
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:165
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:166
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:180
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static size_t ptarray_point_size(const POINTARRAY *pa)
Definition: lwinline.h:56
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: lwinline.h:75
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:51
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:327
lwflags_t flags
Definition: liblwgeom.h:431
uint32_t npoints
Definition: liblwgeom.h:427

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().

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