PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ getPoint3dm_p()

int getPoint3dm_p ( const POINTARRAY pa,
int  n,
POINT3DM op 
)

Definition at line 382 of file lwgeom_api.c.

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

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

383 {
384  uint8_t *ptr;
385  int zmflag;
386 
387 #if PARANOIA_LEVEL > 0
388  if ( ! pa ) return 0;
389 
390  if ( (n<0) || (n>=pa->npoints))
391  {
392  lwerror("%d out of numpoint range (%d)", n, pa->npoints);
393  return 0; /*error */
394  }
395 #endif
396 
397  LWDEBUGF(2, "getPoint3dm_p(%d) called on array of %d-dimensions / %u pts",
398  n, FLAGS_NDIMS(pa->flags), pa->npoints);
399 
400 
401  /* Get a pointer to nth point offset and zmflag */
402  ptr=getPoint_internal(pa, n);
403  zmflag=FLAGS_GET_ZM(pa->flags);
404 
405  /*
406  * if input POINTARRAY has the M and NO Z,
407  * we can issue a single memcpy
408  */
409  if ( zmflag == 1 )
410  {
411  memcpy(op, ptr, sizeof(POINT3DM));
412  return 1;
413  }
414 
415  /*
416  * Otherwise copy the 2d part and
417  * initialize M to NO_M_VALUE
418  */
419  memcpy(op, ptr, sizeof(POINT2D));
420 
421  /*
422  * Then, if input has Z skip it and
423  * copy next double, otherwise initialize
424  * M to NO_M_VALUE
425  */
426  if ( zmflag == 3 )
427  {
428  ptr+=sizeof(POINT3DZ);
429  memcpy(&(op->m), ptr, sizeof(double));
430  }
431  else
432  {
433  op->m=NO_M_VALUE;
434  }
435 
436  return 1;
437 }
int npoints
Definition: liblwgeom.h:370
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:152
double m
Definition: liblwgeom.h:345
uint8_t flags
Definition: liblwgeom.h:368
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1706
#define NO_M_VALUE
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:151
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
Here is the call graph for this function:
Here is the caller graph for this function: