PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ getPoint3dz_p()

int getPoint3dz_p ( const POINTARRAY pa,
uint32_t  n,
POINT3DZ point 
)

Definition at line 216 of file lwgeom_api.c.

217 {
218  uint8_t *ptr;
219 
220  if ( ! pa )
221  {
222  lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
223  return 0;
224  }
225 
226  //assert(n < pa->npoints); --causes point emtpy/point empty to crash
227  if ( n>=pa->npoints )
228  {
229  lwnotice("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
230  return 0;
231  }
232 
233  LWDEBUGF(2, "getPoint3dz_p called on array of %d-dimensions / %u pts",
234  FLAGS_NDIMS(pa->flags), pa->npoints);
235 
236  /* Get a pointer to nth point offset */
237  ptr=getPoint_internal(pa, n);
238 
239  /*
240  * if input POINTARRAY has the Z, it is always
241  * at third position so make a single copy
242  */
243  if ( FLAGS_GET_Z(pa->flags) )
244  {
245  memcpy(op, ptr, sizeof(POINT3DZ));
246  }
247 
248  /*
249  * Otherwise copy the 2d part and initialize
250  * Z to NO_Z_VALUE
251  */
252  else
253  {
254  memcpy(op, ptr, sizeof(POINT2D));
255  op->z=NO_Z_VALUE;
256  }
257 
258  return 1;
259 
260 }
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:180
#define FLAGS_NDIMS(flags)
Definition: liblwgeom.h:194
#define NO_Z_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
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
Definition: lwinline.h:77
lwflags_t flags
Definition: liblwgeom.h:446
uint32_t npoints
Definition: liblwgeom.h:442

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_point_tri(), lw_dist3d_pt_ptarray(), lw_dist3d_ptarray_poly(), lw_dist3d_ptarray_ptarray(), lw_dist3d_ptarray_tri(), lwline_measured_from_lwline(), lwpoint_getPoint3dz_p(), pt_in_ring_3d(), ptarray_length(), and ptarray_to_SFCGAL().

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