PostGIS  2.5.7dev-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.

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

Definition at line 2156 of file lwgeodetic.c.

2157 {
2158  GEOGRAPHIC_POINT g1, g2;
2159  double x1, y1, x2, y2;
2161  /* Convert r to a geodetic point */
2162  x1 = lwpoint_get_x(r);
2163  y1 = lwpoint_get_y(r);
2164  geographic_point_init(x1, y1, &g1);
2166  /* Convert s to a geodetic point */
2167  x2 = lwpoint_get_x(s);
2168  y2 = lwpoint_get_y(s);
2169  geographic_point_init(x2, y2, &g2);
2171  /* Same point, return NaN */
2172  if ( FP_EQUALS(x1, x2) && FP_EQUALS(y1, y2) )
2173  {
2174  return NAN;
2175  }
2177  /* Do the direction calculation */
2178  return spheroid_direction(&g1, &g2, spheroid);
2179 }
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 direction of the geodesic joining two points on the spheroid.
Definition: lwspheroid.c:287
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:53

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: