PostGIS  2.2.7dev-r@@SVN_REVISION@@
double lwpoint_get_ordinate ( const POINT4D p,
char  ordinate 
)

Given a POINT4D and an ordinate number, return the value of the ordinate.

Parameters
pinput point
ordinatenumber (1=x, 2=y, 3=z, 4=m)
Returns
d value at that ordinate

Definition at line 238 of file lwlinearreferencing.c.

References lwerror(), POINT4D::m, POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by lwline_clip_to_ordinate_range(), lwmpoint_clip_to_ordinate_range(), lwpoint_clip_to_ordinate_range(), point_interpolate(), and test_lwpoint_get_ordinate().

239 {
240  if ( ! p )
241  {
242  lwerror("Null input geometry.");
243  return 0.0;
244  }
245 
246  if ( ! ( ordinate == 'X' || ordinate == 'Y' || ordinate == 'Z' || ordinate == 'M' ) )
247  {
248  lwerror("Cannot extract %c ordinate.", ordinate);
249  return 0.0;
250  }
251 
252  if ( ordinate == 'X' )
253  return p->x;
254  if ( ordinate == 'Y' )
255  return p->y;
256  if ( ordinate == 'Z' )
257  return p->z;
258  if ( ordinate == 'M' )
259  return p->m;
260 
261  /* X */
262  return p->x;
263 
264 }
double x
Definition: liblwgeom.h:336
double m
Definition: liblwgeom.h:336
double z
Definition: liblwgeom.h:336
double y
Definition: liblwgeom.h:336
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74

Here is the call graph for this function:

Here is the caller graph for this function: