PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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.

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 2032 of file lwgeodetic.c.

2033{
2034 GEOGRAPHIC_POINT g1, g2;
2035 double x1, y1, x2, y2, az;
2036
2037 /* Convert r to a geodetic point */
2038 x1 = lwpoint_get_x(r);
2039 y1 = lwpoint_get_y(r);
2040 geographic_point_init(x1, y1, &g1);
2041
2042 /* Convert s to a geodetic point */
2043 x2 = lwpoint_get_x(s);
2044 y2 = lwpoint_get_y(s);
2045 geographic_point_init(x2, y2, &g2);
2046
2047 /* Same point, return NaN */
2048 if ( FP_EQUALS(x1, x2) && FP_EQUALS(y1, y2) )
2049 {
2050 return NAN;
2051 }
2052
2053 /* Do the direction calculation */
2054 az = spheroid_direction(&g1, &g2, spheroid);
2055 /* Ensure result is positive */
2056 return az < -0 ? 2*M_PI + az : az;
2057 // return az;
2058}
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: