PostGIS  2.2.8dev-r@@SVN_REVISION@@

## ◆ 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 1262 of file lwgeodetic.c.

Referenced by circ_center_spherical(), and test_sphere_project().

1263 {
1264  double d = distance;
1265  double lat1 = r->lat;
1266  double lon1 = r->lon;
1267  double lat2, lon2;
1268
1269  lat2 = asin(sin(lat1)*cos(d) + cos(lat1)*sin(d)*cos(azimuth));
1270
1271  /* If we're going straight up or straight down, we don't need to calculate the longitude */
1272  /* TODO: this isn't quite true, what if we're going over the pole? */
1273  if ( FP_EQUALS(azimuth, M_PI) || FP_EQUALS(azimuth, 0.0) )
1274  {
1275  lon2 = r->lon;
1276  }
1277  else
1278  {
1279  lon2 = lon1 + atan2(sin(azimuth)*sin(d)*cos(lat1), cos(d)-sin(lat1)*sin(lat2));
1280  }
1281
1282  if ( isnan(lat2) || isnan(lon2) )
1283  return LW_FAILURE;
1284
1285  n->lat = lat2;
1286  n->lon = lon2;
1287
1288  return LW_SUCCESS;
1289 }
#define LW_SUCCESS
Definition: liblwgeom.h:65
#define LW_FAILURE
Definition: liblwgeom.h:64
Datum distance(PG_FUNCTION_ARGS)
#define FP_EQUALS(A, B)
Here is the call graph for this function:
Here is the caller graph for this function: