PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ ptarray_remove_point()

int ptarray_remove_point ( POINTARRAY pa,
uint32_t  where 
)

Remove a point from an existing POINTARRAY.

Zero is the index of the start of the array.

Definition at line 251 of file ptarray.c.

252 {
253  /* Check for pathology */
254  if( ! pa )
255  {
256  lwerror("ptarray_remove_point: null input");
257  return LW_FAILURE;
258  }
259 
260  /* Error on invalid offset value */
261  if ( where >= pa->npoints )
262  {
263  lwerror("ptarray_remove_point: offset out of range (%d)", where);
264  return LW_FAILURE;
265  }
266 
267  /* If the point is any but the last, we need to copy the data back one point */
268  if (where < pa->npoints - 1)
269  memmove(getPoint_internal(pa, where),
270  getPoint_internal(pa, where + 1),
271  ptarray_point_size(pa) * (pa->npoints - where - 1));
272 
273  /* We have one less point */
274  pa->npoints--;
275 
276  return LW_SUCCESS;
277 }
#define LW_FAILURE
Definition: liblwgeom.h:110
#define LW_SUCCESS
Definition: liblwgeom.h:111
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static size_t ptarray_point_size(const POINTARRAY *pa)
Definition: lwinline.h:48
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: lwinline.h:67
uint32_t npoints
Definition: liblwgeom.h:413

References getPoint_internal(), LW_FAILURE, LW_SUCCESS, lwerror(), POINTARRAY::npoints, and ptarray_point_size().

Referenced by gbox_to_gml3(), and lwarc_linearize().

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