diff options
author | Chris Kuethe <chris.kuethe@gmail.com> | 2010-02-27 23:46:26 +0000 |
---|---|---|
committer | Chris Kuethe <chris.kuethe@gmail.com> | 2010-02-27 23:46:26 +0000 |
commit | b17ebd3203edd937b446c1a588e42e78db4772a4 (patch) | |
tree | 98f1a121ddea16af6ed03f54e2b34cffe7c0ad76 /geoid.c | |
parent | 879212380d50d9a7c7b372f5bfd34759be71f84c (diff) | |
download | gpsd-b17ebd3203edd937b446c1a588e42e78db4772a4.tar.gz |
Use the Vincenty formula rather than the Haversine formula for earth_distance.
Vincenty is much better behaved with small distances. This is a translation of
http://www.movable-type.co.uk/scripts/latlong-vincenty.html
While I'm here, put a couple of WGS84 constants into a header.
Diffstat (limited to 'geoid.c')
-rw-r--r-- | geoid.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -90,9 +90,8 @@ void ecef_to_wgs84fix(struct gps_data_t *gpsdata, /* fill in WGS84 position/velocity fields from ECEF coordinates */ { double lambda,phi,p,theta,n,h,vnorth,veast,heading; - const double a = 6378137; /* equatorial radius */ - const double f = 1 / 298.257223563; /* flattening */ - const double b = a * (1 - f); /* polar radius */ + const double a = WGS84A; /* equatorial radius */ + const double b = WGS84B; /* polar radius */ const double e2 = (a*a - b*b) / (a*a); const double e_2 = (a*a - b*b) / (b*b); |