PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ptarray_remove_point()

int ptarray_remove_point ( POINTARRAY pa,
int  where 
)

Remove a point from an existing POINTARRAY.

Zero is the index of the start of the array.

Definition at line 261 of file ptarray.c.

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

Referenced by gbox_to_gml3(), and lwarc_linearize().

262 {
263  size_t ptsize = ptarray_point_size(pa);
264 
265  /* Check for pathology */
266  if( ! pa )
267  {
268  lwerror("ptarray_remove_point: null input");
269  return LW_FAILURE;
270  }
271 
272  /* Error on invalid offset value */
273  if ( where >= pa->npoints || where < 0)
274  {
275  lwerror("ptarray_remove_point: offset out of range (%d)", where);
276  return LW_FAILURE;
277  }
278 
279  /* If the point is any but the last, we need to copy the data back one point */
280  if( where < pa->npoints - 1 )
281  {
282  memmove(getPoint_internal(pa, where), getPoint_internal(pa, where+1), ptsize * (pa->npoints - where - 1));
283  }
284 
285  /* We have one less point */
286  pa->npoints--;
287 
288  return LW_SUCCESS;
289 }
int ptarray_point_size(const POINTARRAY *pa)
Definition: ptarray.c:54
int npoints
Definition: liblwgeom.h:371
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define LW_FAILURE
Definition: liblwgeom.h:79
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1753
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Here is the call graph for this function:
Here is the caller graph for this function: