PostGIS  3.3.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
azimuth - azimuth in radians.

Definition at line 2024 of file lwgeodetic.c.

2025 {
2026  GEOGRAPHIC_POINT g1, g2;
2027  double x1, y1, x2, y2, az;
2028 
2029  /* Convert r to a geodetic point */
2030  x1 = lwpoint_get_x(r);
2031  y1 = lwpoint_get_y(r);
2032  geographic_point_init(x1, y1, &g1);
2033 
2034  /* Convert s to a geodetic point */
2035  x2 = lwpoint_get_x(s);
2036  y2 = lwpoint_get_y(s);
2037  geographic_point_init(x2, y2, &g2);
2038 
2039  /* Same point, return NaN */
2040  if ( FP_EQUALS(x1, x2) && FP_EQUALS(y1, y2) )
2041  {
2042  return NAN;
2043  }
2044 
2045  /* Do the direction calculation */
2046  az = spheroid_direction(&g1, &g2, spheroid);
2047  /* Ensure result is positive */
2048  return az < -0 ? 2*M_PI + az : az;
2049  // return az;
2050 }
char * s
Definition: cu_in_wkt.c:23
char * r
Definition: cu_in_wkt.c:24
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:63
double lwpoint_get_y(const LWPOINT *point)
Definition: lwpoint.c:76
#define FP_EQUALS(A, B)
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
Definition: lwgeodetic.c:180
#define NAN
Definition: lwgeodetic.h:37
double spheroid_direction(const GEOGRAPHIC_POINT *r, const GEOGRAPHIC_POINT *s, const SPHEROID *spheroid)
Computes the forward azimuth of the geodesic joining two points on the spheroid, using the inverse ge...
Definition: lwspheroid.c:105
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:54

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

Referenced by geography_azimuth().

Here is the call graph for this function:
Here is the caller graph for this function: