Add a point in a pointarray.
- Parameters
-
pa | the source POINTARRAY |
p | the point to add |
pdims | number of ordinates in p (2..4) |
where | to insert the point. 0 prepends, pa->npoints appends |
- Returns
- a newly constructed POINTARRAY using a newly allocated buffer for the actual points, or NULL on error.
Definition at line 504 of file ptarray.c.
References POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint_internal(), LWDEBUG, LWDEBUGF, lwerror(), POINT4D::m, POINTARRAY::npoints, ptarray_construct(), ptarray_point_size(), POINT4D::x, POINT4D::y, and POINT4D::z.
Referenced by lwcircstring_addpoint(), LWGEOM2GEOS(), lwline_make_geos_friendly(), ptarray_close2d(), and ring_make_geos_friendly().
510 LWDEBUGF(3,
"pa %x p %x size %d where %d",
511 pa, p, pdims, where);
513 if ( pdims < 2 || pdims > 4 )
515 lwerror(
"ptarray_addPoint: point dimension out of range (%d)",
522 lwerror(
"ptarray_addPoint: offset out of range (%d)",
527 LWDEBUG(3,
"called with a %dD point");
529 pbuf.
x = pbuf.
y = pbuf.
z = pbuf.
m = 0.0;
530 memcpy((
uint8_t *)&pbuf, p, pdims*
sizeof(
double));
532 LWDEBUG(3,
"initialized point buffer");
537 if ( where == -1 ) where = pa->
npoints;
int ptarray_point_size(const POINTARRAY *pa)
#define LWDEBUG(level, msg)
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...
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
#define FLAGS_GET_M(flags)
#define LWDEBUGF(level, msg,...)
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.