PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ getPoint3dm_p()

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

Definition at line 369 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().

370 {
371  uint8_t *ptr;
372  int zmflag;
373 
374 #if PARANOIA_LEVEL > 0
375  if ( ! pa ) return 0;
376 
377  if ( (n<0) || (n>=pa->npoints))
378  {
379  lwerror("%d out of numpoint range (%d)", n, pa->npoints);
380  return 0; /*error */
381  }
382 #endif
383 
384  LWDEBUGF(2, "getPoint3dm_p(%d) called on array of %d-dimensions / %u pts",
385  n, FLAGS_NDIMS(pa->flags), pa->npoints);
386 
387 
388  /* Get a pointer to nth point offset and zmflag */
389  ptr=getPoint_internal(pa, n);
390  zmflag=FLAGS_GET_ZM(pa->flags);
391 
392  /*
393  * if input POINTARRAY has the M and NO Z,
394  * we can issue a single memcpy
395  */
396  if ( zmflag == 1 )
397  {
398  memcpy(op, ptr, sizeof(POINT3DM));
399  return 1;
400  }
401 
402  /*
403  * Otherwise copy the 2d part and
404  * initialize M to NO_M_VALUE
405  */
406  memcpy(op, ptr, sizeof(POINT2D));
407 
408  /*
409  * Then, if input has Z skip it and
410  * copy next double, otherwise initialize
411  * M to NO_M_VALUE
412  */
413  if ( zmflag == 3 )
414  {
415  ptr+=sizeof(POINT3DZ);
416  memcpy(&(op->m), ptr, sizeof(double));
417  }
418  else
419  {
420  op->m=NO_M_VALUE;
421  }
422 
423  return 1;
424 }
int npoints
Definition: liblwgeom.h:355
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:137
double m
Definition: liblwgeom.h:330
uint8_t flags
Definition: liblwgeom.h:353
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:55
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:136
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
Here is the call graph for this function:
Here is the caller graph for this function: