PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ getPoint3dm_p()

int getPoint3dm_p ( const POINTARRAY pa,
uint32_t  n,
POINT3DM point 
)

Definition at line 268 of file lwgeom_api.c.

269 {
270  uint8_t *ptr;
271  int zmflag;
272 
273  if ( ! pa )
274  {
275  lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
276  return 0;
277  }
278 
279  if ( n>=pa->npoints )
280  {
281  lwerror("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
282  return 0;
283  }
284 
285  LWDEBUGF(2, "getPoint3dm_p(%d) called on array of %d-dimensions / %u pts",
286  n, FLAGS_NDIMS(pa->flags), pa->npoints);
287 
288 
289  /* Get a pointer to nth point offset and zmflag */
290  ptr=getPoint_internal(pa, n);
291  zmflag=FLAGS_GET_ZM(pa->flags);
292 
293  /*
294  * if input POINTARRAY has the M and NO Z,
295  * we can issue a single memcpy
296  */
297  if ( zmflag == 1 )
298  {
299  memcpy(op, ptr, sizeof(POINT3DM));
300  return 1;
301  }
302 
303  /*
304  * Otherwise copy the 2d part and
305  * initialize M to NO_M_VALUE
306  */
307  memcpy(op, ptr, sizeof(POINT2D));
308 
309  /*
310  * Then, if input has Z skip it and
311  * copy next double, otherwise initialize
312  * M to NO_M_VALUE
313  */
314  if ( zmflag == 3 )
315  {
316  ptr+=sizeof(POINT3DZ);
317  memcpy(&(op->m), ptr, sizeof(double));
318  }
319  else
320  {
321  op->m=NO_M_VALUE;
322  }
323 
324  return 1;
325 }
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:193
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:194
#define NO_M_VALUE
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: lwinline.h:67
lwflags_t flags
Definition: liblwgeom.h:417
uint32_t npoints
Definition: liblwgeom.h:413

References POINTARRAY::flags, FLAGS_GET_ZM, FLAGS_NDIMS, getPoint_internal(), LWDEBUGF, lwerror(), POINT3DM::m, NO_M_VALUE, and POINTARRAY::npoints.

Referenced by getPoint3dm(), lwline_is_trajectory(), and lwpoint_getPoint3dm_p().

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