Changeset 31 for trunk


Ignore:
Timestamp:
Oct 18, 2011, 2:26:26 AM (12 years ago)
Author:
roman
Message:

support for fractional seconds

Location:
trunk/Utilities/GpsLocationConverter
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/GpsLocationConverter/GpsLocationConverter_i.c

    r29 r31  
    77
    88 /* File created by MIDL compiler version 7.00.0555 */
    9 /* at Wed Oct 12 21:18:26 2011
     9/* at Tue Oct 18 12:15:23 2011
    1010 */
    1111/* Compiler settings for GpsLocationConverter.idl:
  • trunk/Utilities/GpsLocationConverter/GpsLocationConverter_i.h

    r29 r31  
    55
    66 /* File created by MIDL compiler version 7.00.0555 */
    7 /* at Wed Oct 12 21:18:26 2011
     7/* at Tue Oct 18 12:15:23 2011
    88 */
    99/* Compiler settings for GpsLocationConverter.idl:
  • trunk/Utilities/GpsLocationConverter/MainDialog.h

    r30 r31  
    103103                        const INT nPartialLatitudeSecond = (INT) fPartialLatitudeSecond;
    104104                        sLatitude.AppendFormat(_T("%02d"), nPartialLatitudeSecond);
    105                         sLatitude.AppendFormat(_T(".%02d "), (INT) ((fPartialLatitudeSecond - nPartialLatitudeSecond) * 100 + 0.5 - 1E-6));
     105                        sLatitude.AppendFormat(_T(".%02d"), (INT) ((fPartialLatitudeSecond - nPartialLatitudeSecond) * 100 + 0.5 - 1E-6));
    106106                        #pragma endregion
    107107                        #pragma region Latitude
     
    116116                        const INT nPartialLongitudeSecond = (INT) fPartialLongitudeSecond;
    117117                        sLongitude.AppendFormat(_T("%02d"), nPartialLongitudeSecond);
    118                         sLongitude.AppendFormat(_T(".%02d "), (INT) ((fPartialLongitudeSecond - nPartialLongitudeSecond) * 100 + 0.5 - 1E-6));
     118                        sLongitude.AppendFormat(_T(".%02d"), (INT) ((fPartialLongitudeSecond - nPartialLongitudeSecond) * 100 + 0.5 - 1E-6));
    119119                        #pragma endregion
    120120                        psTexts[ 8] = sLatitude;
     
    216216                #pragma endregion
    217217                #pragma region Degrees, Minutes and Seconds
    218                 static CAtlStaticRegExp<> g_ExpressionE0(_T("^[\t ]*")
    219                         _T("{[NSCÞ]}") _T("[\t ]*") _T("{[0-9]+}[^0-9]+?{[0-9]+}[^0-9\\.]+?{[0-9]+}")
    220                         _T("[^0-9\\.]+?")
    221                         _T("{[EWÂÇ]}") _T("[\t ]*") _T("{[0-9]+}[^0-9]+?{[0-9]+}[^0-9\\.]+?{[0-9]+}")
    222                         _T(""), FALSE);
    223                 static CAtlStaticRegExp<> g_ExpressionE1(_T("^[\t ]*")
    224                         _T("{[EWÂÇ]}") _T("[\t ]*") _T("{[0-9]+}[^0-9]+?{[0-9]+}[^0-9\\.]+?{[0-9]+}")
    225                         _T("[^0-9\\.]+?")
    226                         _T("{[NSCÞ]}") _T("[\t ]*") _T("{[0-9]+}[^0-9]+?{[0-9]+}[^0-9\\.]+?{[0-9]+}")
    227                         _T(""), FALSE);
    228                 static CAtlStaticRegExp<> g_ExpressionE2(_T("^[\t ]*")
    229                         _T("{[0-9]+}[^0-9]+?{[0-9]+}[^0-9\\.]+?{[0-9]+}") _T("[\t ]*") _T("{[NSCÞ]}")
    230                         _T("[^0-9\\.]+?")
    231                         _T("{[0-9]+}[^0-9]+?{[0-9]+}[^0-9\\.]+?{[0-9]+}") _T("[\t ]*") _T("{[EWÂÇ]}")
    232                         _T(""), FALSE);
    233                 static CAtlStaticRegExp<> g_ExpressionE3(_T("^[\t ]*")
    234                         _T("{[0-9]+}[^0-9]+?{[0-9]+}[^0-9\\.]+?{[0-9]+}") _T("[\t ]*") _T("{[EWÂÇ]}")
    235                         _T("[^0-9\\.]+?")
    236                         _T("{[0-9]+}[^0-9]+?{[0-9]+}[^0-9\\.]+?{[0-9]+}") _T("[\t ]*") _T("{[NSCÞ]}")
    237                         _T(""), FALSE);
     218#define LATITUDE_SYMBOL         _T("{[NSCÞ]}")
     219#define LONGITUDE_SYMBOL        _T("{[EWÂÇ]}")
     220#define VALUE                           _T("{[0-9]+}[^0-9]+?{[0-9]+}[^0-9\\.]+?{[0-9]+(\\.([0-9]+)?)?}")
     221#define OPTIONAL_WHITESPACE     _T("[\t ]*")
     222#define SEPARATOR                       _T("[^0-9\\.]+?")
     223                static CAtlStaticRegExp<> g_ExpressionE0(_T("^") OPTIONAL_WHITESPACE LATITUDE_SYMBOL OPTIONAL_WHITESPACE VALUE SEPARATOR LONGITUDE_SYMBOL OPTIONAL_WHITESPACE VALUE _T(""), FALSE);
     224                static CAtlStaticRegExp<> g_ExpressionE1(_T("^") OPTIONAL_WHITESPACE LONGITUDE_SYMBOL OPTIONAL_WHITESPACE VALUE SEPARATOR LATITUDE_SYMBOL OPTIONAL_WHITESPACE VALUE  _T(""), FALSE);
     225                static CAtlStaticRegExp<> g_ExpressionE2(_T("^") OPTIONAL_WHITESPACE VALUE OPTIONAL_WHITESPACE LATITUDE_SYMBOL SEPARATOR VALUE OPTIONAL_WHITESPACE LONGITUDE_SYMBOL _T(""), FALSE);
     226                static CAtlStaticRegExp<> g_ExpressionE3(_T("^") OPTIONAL_WHITESPACE VALUE OPTIONAL_WHITESPACE LONGITUDE_SYMBOL SEPARATOR VALUE OPTIONAL_WHITESPACE LATITUDE_SYMBOL _T(""), FALSE);
     227#undef LATITUDE_SYMBOL
     228#undef LONGITUDE_SYMBOL
     229#undef VALUE
     230#undef OPTIONAL_WHITESPACE
     231#undef SEPARATOR
    238232                INT nLayoutE = -1;
    239233                if(g_ExpressionE0.Match(sText, &MatchContext))
     
    258252                        INT nLatitudeDegrees, nLongitudeDegrees;
    259253                        INT nLatitudeMinutes, nLongitudeMinutes;
    260                         INT nLatitudeSeconds, nLongitudeSeconds;
     254                        DOUBLE fLatitudeSeconds, fLongitudeSeconds;
    261255                        if(FALSE ||
    262256                                !AtlStringToInteger(MatchContext.GetMatchString(g_pnMap[nLayoutE][1]), nLatitudeDegrees) ||
    263257                                !AtlStringToInteger(MatchContext.GetMatchString(g_pnMap[nLayoutE][2]), nLatitudeMinutes) ||
    264                                 !AtlStringToInteger(MatchContext.GetMatchString(g_pnMap[nLayoutE][3]), nLatitudeSeconds) ||
     258                                !AtlStringToDouble(MatchContext.GetMatchString(g_pnMap[nLayoutE][3]), fLatitudeSeconds) ||
    265259                                !AtlStringToInteger(MatchContext.GetMatchString(g_pnMap[nLayoutE][5]), nLongitudeDegrees) ||
    266260                                !AtlStringToInteger(MatchContext.GetMatchString(g_pnMap[nLayoutE][6]), nLongitudeMinutes) ||
    267                                 !AtlStringToInteger(MatchContext.GetMatchString(g_pnMap[nLayoutE][7]), nLongitudeSeconds) ||
     261                                !AtlStringToDouble(MatchContext.GetMatchString(g_pnMap[nLayoutE][7]), fLongitudeSeconds) ||
    268262                                FALSE)
    269263                                return FALSE;
     
    271265                        if(nLatitudeMinutes >= 60 || nLongitudeMinutes >= 60)
    272266                                return FALSE;
    273                         _A(nLatitudeSeconds >= 0 && nLongitudeSeconds >= 0);
    274                         if(nLatitudeSeconds >= 60 || nLongitudeSeconds >= 60)
    275                                 return FALSE;
    276                         const DOUBLE fLatitude = nLatitudeSign * (nLatitudeDegrees + (nLatitudeMinutes + nLatitudeSeconds / 60.0) / 60.0);
    277                         const DOUBLE fLongitude = nLongitudeSign * (nLongitudeDegrees + (nLongitudeMinutes + nLongitudeSeconds / 60.0) / 60.0);
     267                        _A(fLatitudeSeconds >= 0 && fLongitudeSeconds >= 0);
     268                        if(fLatitudeSeconds >= 60 || fLongitudeSeconds >= 60)
     269                                return FALSE;
     270                        const DOUBLE fLatitude = nLatitudeSign * (nLatitudeDegrees + (nLatitudeMinutes + fLatitudeSeconds / 60.0) / 60.0);
     271                        const DOUBLE fLongitude = nLongitudeSign * (nLongitudeDegrees + (nLongitudeMinutes + fLongitudeSeconds / 60.0) / 60.0);
    278272                        SetLocation(fLatitude, fLongitude);
    279273                        return TRUE;
Note: See TracChangeset for help on using the changeset viewer.