PostGIS  2.5.7dev-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 261 of file ptarray.c.

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

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: