00001 /***************************************************************************** 00002 * 00003 * $RCSfile: UpdatePosition_8c-source.html,v $ 00004 * 00005 * GPS4Palm Position Update Function - 00006 * converts Position from NMEA Message String to Lat/Lon 00007 * Floating Point Values 00008 * 00009 * This program is Copyright (C) 03/2003 Matthias Prinke 00010 * <matthias.prinke@surfeu.de> and covered by GNU's GPL. 00011 * In particular, this program is free software and comes WITHOUT 00012 * ANY WARRANTY. 00013 * 00014 * $Author: mp $ 00015 * 00016 * $Date: 2007-10-08 20:40:35 $ 00017 * 00018 * $Revision: 1.7.2.1 $ 00019 * 00020 * $Log: UpdatePosition_8c-source.html,v $ 00020 * Revision 1.7.2.1 2007-10-08 20:40:35 mp 00020 * updated for gps4palm V0.9.5 beta 00020 * 00021 * Revision 1.1.1.1 2003-07-14 18:59:29 mp 00022 * Imported GPS4Palm to CVS revision control. 00023 * 00024 * 00025 ****************************************************************************/ 00026 #include <PalmOS.h> 00027 00028 // TBD: only MapForm 00029 static 00030 void UpdatePosition(Char *message, double *p_lat, double *p_lon) 00031 { 00032 Char s[20]; /* string buffer */ 00033 Char tmp[8]; 00034 Char *pt_pos; /* decimal point pos. */ 00035 double lat; 00036 double lon; 00037 00038 // 4 is N or S for Lat direction, 3 is lat 00039 if (GetField(message, 4, s) && 00040 GetField(message, 3, s + StrLen(s))) { 00041 00042 // find position of decimal point 00043 pt_pos = StrStr(s, "."); 00044 00045 // degrees 00046 StrNCopy(tmp, pt_pos - 4, 2); 00047 lat = (double)StrAToI(tmp); 00048 00049 // minutes 00050 StrNCopy(tmp, pt_pos - 2, 2); 00051 lat += (double)StrAToI(tmp)/60.0; 00052 00053 // seconds 00054 lat += (double)StrAToI(pt_pos+1)/3600.0; 00055 00056 lat *= (s[0] == 'S') ? -1 : 1; 00057 00058 *p_lat = lat; 00059 } 00060 00061 00062 // 6 is E or W for Lon direction, 5 is lon 00063 if (GetField(message, 6, s) && 00064 GetField(message, 5, s + StrLen(s))) { 00065 00066 // find position of decimal point 00067 pt_pos = StrStr(s, "."); 00068 00069 // degrees 00070 StrNCopy(tmp, pt_pos - 5, 3); 00071 lon = (double)StrAToI(tmp); 00072 00073 // minutes 00074 StrNCopy(tmp, pt_pos - 2, 2); 00075 lon += (double)StrAToI(tmp)/60.0; 00076 00077 // seconds 00078 lon += (double)StrAToI(pt_pos+1)/3600.0; 00079 00080 lon *= (s[0] == 'W') ? -1 : 1; 00081 00082 *p_lon = lon; 00083 } 00084 }