PostGIS  2.4.9dev-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

Definition at line 2152 of file lwgeodetic.c.

Referenced by geography_azimuth().

2153 {
2154  GEOGRAPHIC_POINT g1, g2;
2155  double x1, y1, x2, y2;
2156
2157  /* Convert r to a geodetic point */
2158  x1 = lwpoint_get_x(r);
2159  y1 = lwpoint_get_y(r);
2160  geographic_point_init(x1, y1, &g1);
2161
2162  /* Convert s to a geodetic point */
2163  x2 = lwpoint_get_x(s);
2164  y2 = lwpoint_get_y(s);
2165  geographic_point_init(x2, y2, &g2);
2166
2167  /* Same point, return NaN */
2168  if ( FP_EQUALS(x1, x2) && FP_EQUALS(y1, y2) )
2169  {
2170  return NAN;
2171  }
2172
2173  /* Do the direction calculation */
2174  return spheroid_direction(&g1, &g2, spheroid);
2175 }
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:52
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:180
#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: 