PostGIS  2.1.10dev-r@@SVN_REVISION@@
POINTARRAY* ptarray_removePoint ( POINTARRAY pa,
uint32_t  which 
)

Remove a point from a pointarray.

Parameters
which- is the offset (starting at 0)
Returns
POINTARRAY is newly allocated

Definition at line 540 of file ptarray.c.

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

Referenced by lwcircstring_removepoint(), and lwline_removepoint().

541 {
542  POINTARRAY *ret;
543  size_t ptsize = ptarray_point_size(pa);
544 
545  LWDEBUGF(3, "pa %x which %d", pa, which);
546 
547 #if PARANOIA_LEVEL > 0
548  if ( which > pa->npoints-1 )
549  {
550  lwerror("ptarray_removePoint: offset (%d) out of range (%d..%d)",
551  which, 0, pa->npoints-1);
552  return NULL;
553  }
554 
555  if ( pa->npoints < 3 )
556  {
557  lwerror("ptarray_removePointe: can't remove a point from a 2-vertex POINTARRAY");
558  }
559 #endif
560 
562  FLAGS_GET_M(pa->flags), pa->npoints-1);
563 
564  /* copy initial part */
565  if ( which )
566  {
567  memcpy(getPoint_internal(ret, 0), getPoint_internal(pa, 0), ptsize*which);
568  }
569 
570  /* copy final part */
571  if ( which < pa->npoints-1 )
572  {
573  memcpy(getPoint_internal(ret, which), getPoint_internal(pa, which+1),
574  ptsize*(pa->npoints-which-1));
575  }
576 
577  return ret;
578 }
int ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:41
int npoints
Definition: liblwgeom.h:327
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
uint8_t flags
Definition: liblwgeom.h:325
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:49
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:107
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1645

Here is the call graph for this function:

Here is the caller graph for this function: