PostGIS  2.1.10dev-r@@SVN_REVISION@@
int getPoint3dm_p ( const POINTARRAY pa,
int  n,
POINT3DM op 
)

Definition at line 355 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(), and lwpoint_getPoint3dm_p().

356 {
357  uint8_t *ptr;
358  int zmflag;
359 
360 #if PARANOIA_LEVEL > 0
361  if ( ! pa ) return 0;
362 
363  if ( (n<0) || (n>=pa->npoints))
364  {
365  lwerror("%d out of numpoint range (%d)", n, pa->npoints);
366  return 0; /*error */
367  }
368 #endif
369 
370  LWDEBUGF(2, "getPoint3dm_p(%d) called on array of %d-dimensions / %u pts",
371  n, FLAGS_NDIMS(pa->flags), pa->npoints);
372 
373 
374  /* Get a pointer to nth point offset and zmflag */
375  ptr=getPoint_internal(pa, n);
376  zmflag=FLAGS_GET_ZM(pa->flags);
377 
378  /*
379  * if input POINTARRAY has the M and NO Z,
380  * we can issue a single memcpy
381  */
382  if ( zmflag == 1 )
383  {
384  memcpy(op, ptr, sizeof(POINT3DM));
385  return 1;
386  }
387 
388  /*
389  * Otherwise copy the 2d part and
390  * initialize M to NO_M_VALUE
391  */
392  memcpy(op, ptr, sizeof(POINT2D));
393 
394  /*
395  * Then, if input has Z skip it and
396  * copy next double, otherwise initialize
397  * M to NO_M_VALUE
398  */
399  if ( zmflag == 3 )
400  {
401  ptr+=sizeof(POINT3DZ);
402  memcpy(&(op->m), ptr, sizeof(double));
403  }
404  else
405  {
406  op->m=NO_M_VALUE;
407  }
408 
409  return 1;
410 }
int npoints
Definition: liblwgeom.h:327
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:119
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
double m
Definition: liblwgeom.h:302
uint8_t flags
Definition: liblwgeom.h:325
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1645
#define NO_M_VALUE
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:118

Here is the call graph for this function:

Here is the caller graph for this function: