PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ getPoint3dm_p()

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

Definition at line 269 of file lwgeom_api.c.

270 {
271  uint8_t *ptr;
272  int zmflag;
273 
274  if (!pa)
275  {
276  lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
277  return LW_FALSE;
278  }
279 
280  if (n >= pa->npoints)
281  {
282  lwerror("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
283  return LW_FALSE;
284  }
285 
286  /* Get a pointer to nth point offset and zmflag */
287  ptr = getPoint_internal(pa, n);
288  zmflag = FLAGS_GET_ZM(pa->flags);
289 
290  /*
291  * if input POINTARRAY has the M and NO Z,
292  * we can issue a single memcpy
293  */
294  if (zmflag == 1)
295  {
296  memcpy(op, ptr, sizeof(POINT3DM));
297  return LW_TRUE;
298  }
299 
300  /*
301  * Otherwise copy the 2d part and
302  * initialize M to NO_M_VALUE
303  */
304  memcpy(op, ptr, sizeof(POINT2D));
305 
306  /*
307  * Then, if input has Z skip it and
308  * copy next double, otherwise initialize
309  * M to NO_M_VALUE
310  */
311  if (zmflag == 3)
312  {
313  ptr += sizeof(POINT3DZ);
314  memcpy(&(op->m), ptr, sizeof(double));
315  }
316  else
317  op->m = NO_M_VALUE;
318 
319  return LW_TRUE;
320 }
#define LW_FALSE
Definition: liblwgeom.h:108
#define FLAGS_GET_ZM(flags)
Definition: liblwgeom.h:194
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:107
#define NO_M_VALUE
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:77
lwflags_t flags
Definition: liblwgeom.h:445
uint32_t npoints
Definition: liblwgeom.h:441

References POINTARRAY::flags, FLAGS_GET_ZM, getPoint_internal(), LW_FALSE, LW_TRUE, 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: