PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ getPoint3dz_p()

int getPoint3dz_p ( const POINTARRAY pa,
int  n,
POINT3DZ op 
)

Definition at line 214 of file lwgeom_api.c.

References POINTARRAY::flags, FLAGS_GET_Z, FLAGS_NDIMS, getPoint_internal(), LWDEBUGF, lwerror(), lwnotice(), 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(), lwmpoint_extract_points_3d(), lwpoint_getPoint3dz_p(), pt_in_ring_3d(), ptarray_length(), and ptarray_to_SFCGAL().

215 {
216  uint8_t *ptr;
217 
218  if ( ! pa )
219  {
220  lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
221  return 0;
222  }
223 
224  if ( (n<0) || (n>=pa->npoints))
225  {
226  lwnotice("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
227  return 0;
228  }
229 
230  LWDEBUGF(2, "getPoint3dz_p called on array of %d-dimensions / %u pts",
231  FLAGS_NDIMS(pa->flags), pa->npoints);
232 
233  /* Get a pointer to nth point offset */
234  ptr=getPoint_internal(pa, n);
235 
236  /*
237  * if input POINTARRAY has the Z, it is always
238  * at third position so make a single copy
239  */
240  if ( FLAGS_GET_Z(pa->flags) )
241  {
242  memcpy(op, ptr, sizeof(POINT3DZ));
243  }
244 
245  /*
246  * Otherwise copy the 2d part and initialize
247  * Z to NO_Z_VALUE
248  */
249  else
250  {
251  memcpy(op, ptr, sizeof(POINT2D));
252  op->z=NO_Z_VALUE;
253  }
254 
255  return 1;
256 
257 }
double z
Definition: liblwgeom.h:334
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
int npoints
Definition: liblwgeom.h:371
uint8_t flags
Definition: liblwgeom.h:369
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1753
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
#define NO_Z_VALUE
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:152
unsigned char uint8_t
Definition: uthash.h:79
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Here is the call graph for this function:
Here is the caller graph for this function: