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 530 of file ptarray.c.
531{
535
536 LWDEBUGF(3,
"pa %p p %p size %zu where %u",
537 pa, p, pdims, where);
538
539 if ( pdims < 2 || pdims > 4 )
540 {
541 lwerror(
"ptarray_addPoint: point dimension out of range (%zu)",
542 pdims);
543 return NULL;
544 }
545
547 {
548 lwerror(
"ptarray_addPoint: offset out of range (%d)",
549 where);
550 return NULL;
551 }
552
553 LWDEBUG(3,
"called with a point");
554
555 pbuf.
x = pbuf.
y = pbuf.
z = pbuf.
m = 0.0;
556 memcpy((uint8_t *)&pbuf, p, pdims*sizeof(double));
557
558 LWDEBUG(3,
"initialized point buffer");
559
562
563
564 if ( where )
565 {
567 }
568
570
572 {
576 }
577
578 return ret;
579}
#define FLAGS_GET_Z(flags)
#define FLAGS_GET_M(flags)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
static size_t ptarray_point_size(const POINTARRAY *pa)
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...
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().