distance_point.c File Reference

Compute distance in meters for two latitude and longitude points. More...

#include <utils.h>
Include dependency graph for distance_point.c:

Go to the source code of this file.

Functions

double distance_point (double lon0, double lat0, double lon1, double lat1)
 Compute distance in meters for two latitude and longitude points.

Detailed Description

Compute distance in meters for two latitude and longitude points.

Definition in file distance_point.c.


Function Documentation

double distance_point ( double  lon0,
double  lat0,
double  lon1,
double  lat1 
)

Compute distance in meters for two latitude and longitude points.

Parameters:
[in] lon0 First point longitude
[in] lat0 First point latitude
[in] lon1 Second point longitude
[in] lat1 Second point latitude
Returns:
Distance in meters between 2 points.

Definition at line 59 of file distance_point.c.

Referenced by wt_learning().

00060 {
00070   /* Earth equatorial radius, meters, Clarke 1866 ellipsoid */
00071   const double r_earth = 6378206.4;
00072   const double degtorad = M_PI / 180.0;
00073 
00074   double coslt1;
00075   double coslt0;
00076   double sinlt1;
00077   double sinlt0;
00078   double cosl0l1;
00079   double cosc;
00080   
00081   coslt1 = cos(lat1 * degtorad);
00082   sinlt1 = sin(lat1 * degtorad);
00083   coslt0 = cos(lat0 * degtorad);
00084   sinlt0 = sin(lat0 * degtorad);
00085     
00086   cosl0l1 = cos((lon1-lon0) * degtorad);
00087   
00088   /* Cos of angle between points */
00089   cosc = sinlt0 * sinlt1 + coslt0 * coslt1 * cosl0l1;
00090   
00091   /* Restrict range between 1 and -1 */
00092   if (cosc > 1.0)
00093     cosc = 1.0;
00094   else if (cosc < -1.0)
00095     cosc = -1.0;
00096 
00097   return (acos(cosc) * r_earth);
00098 }


Generated on 12 May 2016 for DSCLIM by  doxygen 1.6.1