PostGIS  2.5.0dev-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 252 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().

253 {
254  if ( ! p )
255  {
256  lwerror("Null input geometry.");
257  return 0.0;
258  }
259 
260  if ( ! ( ordinate == 'X' || ordinate == 'Y' || ordinate == 'Z' || ordinate == 'M' ) )
261  {
262  lwerror("Cannot extract %c ordinate.", ordinate);
263  return 0.0;
264  }
265 
266  if ( ordinate == 'X' )
267  return p->x;
268  if ( ordinate == 'Y' )
269  return p->y;
270  if ( ordinate == 'Z' )
271  return p->z;
272  if ( ordinate == 'M' )
273  return p->m;
274 
275  /* X */
276  return p->x;
277 
278 }
double x
Definition: liblwgeom.h:351
double m
Definition: liblwgeom.h:351
double z
Definition: liblwgeom.h:351
double y
Definition: liblwgeom.h:351
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: