PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ lwgeom_azumith_spheroid()

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.

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

Definition at line 2061 of file lwgeodetic.c.

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

Referenced by geography_azimuth().

2062 {
2063  GEOGRAPHIC_POINT g1, g2;
2064  double x1, y1, x2, y2;
2065 
2066  /* Convert r to a geodetic point */
2067  x1 = lwpoint_get_x(r);
2068  y1 = lwpoint_get_y(r);
2069  geographic_point_init(x1, y1, &g1);
2070 
2071  /* Convert s to a geodetic point */
2072  x2 = lwpoint_get_x(s);
2073  y2 = lwpoint_get_y(s);
2074  geographic_point_init(x2, y2, &g2);
2075 
2076  /* Same point, return NaN */
2077  if ( FP_EQUALS(x1, x2) && FP_EQUALS(y1, y2) )
2078  {
2079  return NAN;
2080  }
2081 
2082  /* Do the direction calculation */
2083  return spheroid_direction(&g1, &g2, spheroid);
2084 }
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:73
Here is the call graph for this function:
Here is the caller graph for this function: