diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-03-29 07:39:37 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-03-29 07:39:37 -0400 |
commit | 41160f7fa55bc99a3e7a57a957dcae22f33069cb (patch) | |
tree | b662e373d2d1859550fcc384ca1e021cef6b5484 /gpsdclient.c | |
parent | 8da7e0a37e3de6e09151e9f07959ccc7d8cbfa0c (diff) | |
download | gpsd-41160f7fa55bc99a3e7a57a957dcae22f33069cb.tar.gz |
splint-clean the Maidenhead translator and make it available for cgps.
All regression tests pass.
Diffstat (limited to 'gpsdclient.c')
-rw-r--r-- | gpsdclient.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gpsdclient.c b/gpsdclient.c index cd52835f..db016174 100644 --- a/gpsdclient.c +++ b/gpsdclient.c @@ -175,4 +175,32 @@ void gpsd_source_spec(const char *arg, struct fixsource_t *source) /*@ +observertrans -statictrans +mustfreeonly +branchstate +kepttrans @*/ +char *latlon2maidenhead(double n, double e) +/* lat/lon to Maidenhead (from QGrid - http://users.pandora.be/on4qz/qgrid/) */ +{ + static char buf[7]; + + int t1; + e=e+180.0; + t1=(int)(e/20); + buf[0]=(char)t1+'A'; + e-=(float)t1*20.0; + t1=(int)e/2; + buf[2]=(char)t1+'0'; + e-=(float)t1*2; + buf[4]=(char)(int)(e*12.0+0.5)+'A'; + + n=n+90.0; + t1=(int)(n/10.0); + buf[1]=(char)t1+'A'; + n-=(float)t1*10.0; + buf[3]=(char)n+'0'; + n-=(int)n; + n*=24; // convert to 24 division + buf[5]=(char)(int)(n+0.5)+'A'; + buf[6] = '\0'; + + return buf; +} + /* gpsclient.c ends here */ |