PostGIS  2.5.0dev-r@@SVN_REVISION@@
double lwgeom_azumith_spheroid ( const LWPOINT r,
const LWPOINT s,
const SPHEROID spheroid 

Calculate a bearing (azimuth) given a source and destination point.

Calculate the bearing between two points on a spheroid.

r- location of first point.
s- location of second point.
spheroid- spheroid definition.
azimuth - azimuth in radians.

Definition at line 2065 of file lwgeodetic.c.

References FP_EQUALS, geographic_point_init(), lwpoint_get_x(), lwpoint_get_y(), NAN, and spheroid_direction().

Referenced by geography_azimuth().

2066 {
2067  GEOGRAPHIC_POINT g1, g2;
2068  double x1, y1, x2, y2;
2070  /* Convert r to a geodetic point */
2071  x1 = lwpoint_get_x(r);
2072  y1 = lwpoint_get_y(r);
2073  geographic_point_init(x1, y1, &g1);
2075  /* Convert s to a geodetic point */
2076  x2 = lwpoint_get_x(s);
2077  y2 = lwpoint_get_y(s);
2078  geographic_point_init(x2, y2, &g2);
2080  /* Same point, return NaN */
2081  if ( FP_EQUALS(x1, x2) && FP_EQUALS(y1, y2) )
2082  {
2083  return NAN;
2084  }
2086  /* Do the direction calculation */
2087  return spheroid_direction(&g1, &g2, spheroid);
2088 }
double spheroid_direction(const GEOGRAPHIC_POINT *r, const GEOGRAPHIC_POINT *s, const SPHEROID *spheroid)
Computes the direction of the geodesic joining two points on the spheroid.
Definition: lwspheroid.c:282
#define NAN
Definition: lwgeodetic.h:37
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:47
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:63
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
Definition: lwgeodetic.c:171
#define FP_EQUALS(A, B)
double lwpoint_get_y(const LWPOINT *point)
Definition: lwpoint.c:76

Here is the call graph for this function:

Here is the caller graph for this function: