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

Definition at line 305 of file lwgeom_api.c.

References POINTARRAY::flags, FLAGS_GET_Z, FLAGS_NDIMS, getPoint_internal(), LWDEBUGF, NO_Z_VALUE, POINTARRAY::npoints, and POINT3DZ::z.

Referenced by BOX3D_construct(), define_plane(), getPoint3dz(), lw_dist3d_point_line(), lw_dist3d_point_point(), lw_dist3d_point_poly(), lw_dist3d_pt_ptarray(), lw_dist3d_ptarray_poly(), lw_dist3d_ptarray_ptarray(), LWGEOM_z_point(), lwline_measured_from_lwline(), lwpoint_getPoint3dz_p(), pt_in_ring_3d(), ptarray_length(), and ptarray_to_SFCGAL().

306 {
307  uint8_t *ptr;
308 
309 #if PARANOIA_LEVEL > 0
310  if ( ! pa ) return 0;
311 
312  if ( (n<0) || (n>=pa->npoints))
313  {
314  LWDEBUGF(4, "%d out of numpoint range (%d)", n, pa->npoints);
315  return 0; /*error */
316  }
317 #endif
318 
319  LWDEBUGF(2, "getPoint3dz_p called on array of %d-dimensions / %u pts",
320  FLAGS_NDIMS(pa->flags), pa->npoints);
321 
322  /* Get a pointer to nth point offset */
323  ptr=getPoint_internal(pa, n);
324 
325  /*
326  * if input POINTARRAY has the Z, it is always
327  * at third position so make a single copy
328  */
329  if ( FLAGS_GET_Z(pa->flags) )
330  {
331  memcpy(op, ptr, sizeof(POINT3DZ));
332  }
333 
334  /*
335  * Otherwise copy the 2d part and initialize
336  * Z to NO_Z_VALUE
337  */
338  else
339  {
340  memcpy(op, ptr, sizeof(POINT2D));
341  op->z=NO_Z_VALUE;
342  }
343 
344  return 1;
345 
346 }
double z
Definition: liblwgeom.h:290
int npoints
Definition: liblwgeom.h:327
uint8_t flags
Definition: liblwgeom.h:325
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1645
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:106
#define NO_Z_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: