PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ lwgeom_azumith_spheroid()

double lwgeom_azumith_spheroid ( const LWPOINT r,
const LWPOINT s,
const SPHEROID spheroid 
)

Calculate the bearing between two points on a spheroid.

Calculate the bearing between two points on a spheroid.

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

Definition at line 2069 of file lwgeodetic.c.

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

Referenced by geography_azimuth().

2070 {
2071  GEOGRAPHIC_POINT g1, g2;
2072  double x1, y1, x2, y2;
2073 
2074  /* Convert r to a geodetic point */
2075  x1 = lwpoint_get_x(r);
2076  y1 = lwpoint_get_y(r);
2077  geographic_point_init(x1, y1, &g1);
2078 
2079  /* Convert s to a geodetic point */
2080  x2 = lwpoint_get_x(s);
2081  y2 = lwpoint_get_y(s);
2082  geographic_point_init(x2, y2, &g2);
2083 
2084  /* Same point, return NaN */
2085  if ( FP_EQUALS(x1, x2) && FP_EQUALS(y1, y2) )
2086  {
2087  return NAN;
2088  }
2089 
2090  /* Do the direction calculation */
2091  return spheroid_direction(&g1, &g2, spheroid);
2092 }
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: