PostGIS  2.2.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

Definition at line 2050 of file lwgeodetic.c.

Referenced by geography_azimuth().

2051 {
2052  GEOGRAPHIC_POINT g1, g2;
2053  double x1, y1, x2, y2;
2054
2055  /* Convert r to a geodetic point */
2056  x1 = lwpoint_get_x(r);
2057  y1 = lwpoint_get_y(r);
2058  geographic_point_init(x1, y1, &g1);
2059
2060  /* Convert s to a geodetic point */
2061  x2 = lwpoint_get_x(s);
2062  y2 = lwpoint_get_y(s);
2063  geographic_point_init(x2, y2, &g2);
2064
2065  /* Same point, return NaN */
2066  if ( FP_EQUALS(x1, x2) && FP_EQUALS(y1, y2) )
2067  {
2068  return NAN;
2069  }
2070
2071  /* Do the direction calculation */
2072  return spheroid_direction(&g1, &g2, spheroid);
2073 }
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:268
#define NAN
Definition: lwgeodetic.h:22
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:32
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:50
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
Definition: lwgeodetic.c:156
#define FP_EQUALS(A, B)
double lwpoint_get_y(const LWPOINT *point)
Definition: lwpoint.c:60
Here is the call graph for this function:
Here is the caller graph for this function: