From 3db67120b2e24200222b377ef5a75d10c8eef67d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 1 Apr 2005 15:48:21 +0000 Subject: MacOS compiler fixes. Oleg's fix for the bilinear interpolation. Geoid-separation code integrated for test but not for production. --- Makefile.am | 1 + TODO | 22 +--------------------- drivers.c | 1 + geoid.c | 6 ++++-- gpsd.c | 2 +- sirf.c | 8 ++++++-- 6 files changed, 14 insertions(+), 26 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2ab88d74..fa49ead8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -62,6 +62,7 @@ libgps_la_SOURCES = \ libgps.c \ packet.c \ gpsutils.c \ + geoid.c \ sirf.c \ report.c diff --git a/TODO b/TODO index 80121927..215f5ece 100644 --- a/TODO +++ b/TODO @@ -34,27 +34,7 @@ the receive FIFO. You'll have to experiment. ** Supply geoidal separation for SiRF packet 2 -Peter H. Dana : -> The classic bi-linear interpolation method is published in Table 5.3 -> of DMA TR8350.2 Supplement B (page 5.3) -> -> Np(lat, lon) = a0 +a1*X + a2*Y +a3*X*Y -> -> a0 = N1 -> a1 = N2-N1 -> a2 = N4-N1 -> a3=N1+N3-N2-N4 -> -> X= (lon-lon1)/(lon2-lon1) -> Y = (lat-lat1)/(lat2-lat1) -> Whre -> N1 (lat1, lon1) , N2 (lat1, lon2), N3( lat2,lon2), N4 (lat2, lon1) are known -> geoid heights -> -> Rather than deal with interpolation from a table, most folks use the EGM96 -> coefficients and the formulas for direct computation of N at any point shown -> in NIMA TR8350.2 -> http://earth-info.nga.mil/GandG/tr8350_2.html +It's there for testing now. ** Hotplug interface problems diff --git a/drivers.c b/drivers.c index 0ac24e9c..fa8c023f 100644 --- a/drivers.c +++ b/drivers.c @@ -92,6 +92,7 @@ struct gps_type_t fv18 = { nmea_parse_input, /* how to interpret a packet */ nmea_write_rtcm, /* write RTCM data straight */ NULL, /* no speed switcher */ + NULL, /* no mode switcher */ NULL, /* no wrapup */ 1, /* updates every second */ }; diff --git a/geoid.c b/geoid.c index f709dd55..e119eb1d 100644 --- a/geoid.c +++ b/geoid.c @@ -5,6 +5,7 @@ */ #include +#include "gpsd.h" static double bilinear(double x1, double y1, double x2, double y2, double x, double y, double z11, double z12, double z21, double z22) { @@ -16,7 +17,7 @@ static double bilinear(double x1, double y1, double x2, double y2, double x, dou delta=(y2-y1)*(x2-x1); - return (z22*(y-y1)*(x-x1)+z21*(y2-y)*(x-x1)+z12*(y-y1)*(x2-x)+z11*(y2-y)*(x2-x))/delta; + return (z22*(y-y1)*(x-x1)+z12*(y2-y)*(x-x1)+z21*(y-y1)*(x2-x)+z11*(y2-y)*(x2-x))/delta; } double wgs84_separation(double lat, double lon) @@ -63,6 +64,7 @@ double wgs84_separation(double lat, double lon) ); } +#ifdef TESTMAIN #include #include @@ -95,4 +97,4 @@ int main(int argc, char **argv) return 0; } - +#endif /* TESTMAIN */ diff --git a/gpsd.c b/gpsd.c index 4ff6daf8..cdbf3849 100644 --- a/gpsd.c +++ b/gpsd.c @@ -900,8 +900,8 @@ int main(int argc, char *argv[]) for (cfd = 0; cfd < FD_SETSIZE; cfd++) { /* some listeners may be in watcher mode */ if (IS_WATCHER(cfd)) { - device->poll_times[cfd] = timestamp(); char cmds[4] = ""; + device->poll_times[cfd] = timestamp(); if (changed &~ ONLINE_SET) { if (changed & LATLON_SET) strcat(cmds, "o"); diff --git a/sirf.c b/sirf.c index daa13ba0..82355dfd 100644 --- a/sirf.c +++ b/sirf.c @@ -106,7 +106,7 @@ static int sirf_to_nmea(int ttyfd, int speed) * * SiRF message 2 (Measure Navigation Data Out) gives us everything we want * except PDOP, VDOP, and altitude with respect to MSL. SiRF message 41 - * (Geodetic Navigation Information) adds MSLfix.altitude, but many of its + * (Geodetic Navigation Information) adds MSL altitude, but many of its * other fields are garbage in firmware versions before 232. So...we * use all the data from message 2 *except* altitude, which we get from * message 41. @@ -166,8 +166,11 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len) phi = atan2(z + e_2*b*pow(sin(theta),3),p - e2*a*pow(cos(theta),3)); n = a / sqrt(1.0 - e2*pow(sin(phi),2)); h = p / cos(phi) - n; + gpsd_report(4, "Height above ellipsoid: %f\n", h); session->gpsdata.fix.latitude = phi * RAD_2_DEG; session->gpsdata.fix.longitude = lambda * RAD_2_DEG; + gpsd_report(4, "Height with interpolated correction: %f\n", + h+wgs84_separation(session->gpsdata.fix.latitude, session->gpsdata.fix.longitude)); /* velocity computation */ vnorth = -vx*sin(phi)*cos(lambda)-vy*sin(phi)*sin(lambda)+vz*cos(phi); veast = -vx*sin(lambda)+vy*cos(lambda); @@ -400,7 +403,8 @@ int sirf_parse(struct gps_device_t *session, unsigned char *buf, int len) /* skip 4 bytes of altitude from ellipsoid */ mask = TIME_SET | LATLON_SET | STATUS_SET | MODE_SET; } - session->gpsdata.fix.altitude = getl(31)*1e-2; + session->gpsdata.fix.altitude = getl(35)*1e-2; + gpsd_report(4, "Height above MSL: %f\n", session->gpsdata.fix.altitude); if (session->driverstate & SIRF_GE_232) { /* skip 1 byte of map datum */ session->gpsdata.fix.speed = getw(36)*1e-2; -- cgit v1.2.1