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

https://accesd.desjardins.ca/coast*

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

Definition at line 2170 of file lwgeodetic.c.

2171 {
2172  GEOGRAPHIC_POINT g1, g2;
2173  double x1, y1, x2, y2, az;
2174 
2175  /* Convert r to a geodetic point */
2176  x1 = lwpoint_get_x(r);
2177  y1 = lwpoint_get_y(r);
2178  geographic_point_init(x1, y1, &g1);
2179 
2180  /* Convert s to a geodetic point */
2181  x2 = lwpoint_get_x(s);
2182  y2 = lwpoint_get_y(s);
2183  geographic_point_init(x2, y2, &g2);
2184 
2185  /* Same point, return NaN */
2186  if ( FP_EQUALS(x1, x2) && FP_EQUALS(y1, y2) )
2187  {
2188  return NAN;
2189  }
2190 
2191  /* Do the direction calculation */
2192  az = spheroid_direction(&g1, &g2, spheroid);
2193  /* Ensure result is positive */
2194  return az < -0 ? 2*M_PI + az : az;
2195  // return az;
2196 }
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(), and lwgeom_project_spheroid_lwpoint().

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