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

◆ sphere_project()

int sphere_project ( const GEOGRAPHIC_POINT r,
double  distance,
double  azimuth,
GEOGRAPHIC_POINT n 
)

Given a starting location r, a distance and an azimuth to the new point, compute the location of the projected point on the unit sphere.

Definition at line 1268 of file lwgeodetic.c.

1269{
1270 double d = distance;
1271 double lat1 = r->lat;
1272 double lon1 = r->lon;
1273 double lat2, lon2;
1274
1275 lat2 = asin(sin(lat1)*cos(d) + cos(lat1)*sin(d)*cos(azimuth));
1276
1277 /* If we're going straight up or straight down, we don't need to calculate the longitude */
1278 /* TODO: this isn't quite true, what if we're going over the pole? */
1279 if ( FP_EQUALS(azimuth, M_PI) || FP_EQUALS(azimuth, 0.0) )
1280 {
1281 lon2 = r->lon;
1282 }
1283 else
1284 {
1285 lon2 = lon1 + atan2(sin(azimuth)*sin(d)*cos(lat1), cos(d)-sin(lat1)*sin(lat2));
1286 }
1287
1288 if ( isnan(lat2) || isnan(lon2) )
1289 return LW_FAILURE;
1290
1291 n->lat = lat2;
1292 n->lon = lon2;
1293
1294 return LW_SUCCESS;
1295}
char * r
Definition cu_in_wkt.c:24
#define LW_FAILURE
Definition liblwgeom.h:96
#define LW_SUCCESS
Definition liblwgeom.h:97
#define FP_EQUALS(A, B)
static double distance(double x1, double y1, double x2, double y2)
Definition lwtree.c:1032

References distance(), FP_EQUALS, GEOGRAPHIC_POINT::lat, GEOGRAPHIC_POINT::lon, LW_FAILURE, LW_SUCCESS, and r.

Referenced by circ_center_spherical(), interpolate_point4d_spheroid(), and test_sphere_project().

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