PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ getPoint3dm_p()

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

Definition at line 267 of file lwgeom_api.c.

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

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

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

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