PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ getPoint3dm_p()

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

Definition at line 268 of file lwgeom_api.c.

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

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: