diff --git a/YSFGateway/APRSWriter.cpp b/YSFGateway/APRSWriter.cpp index 87d3cd8..121419a 100644 --- a/YSFGateway/APRSWriter.cpp +++ b/YSFGateway/APRSWriter.cpp @@ -95,35 +95,10 @@ void CAPRSWriter::write(const unsigned char* source, const char* type, unsigned longitude = (tempLong - longitude) * 60.0 + longitude * 100.0; char lat[20U]; - if (latitude >= 1000.0F) - ::sprintf(lat, "%.2lf", latitude); - else if (latitude >= 100.0F) - ::sprintf(lat, "0%.2lf", latitude); - else if (latitude >= 10.0F) - ::sprintf(lat, "00%.2lf", latitude); - else - ::sprintf(lat, "000%.2lf", latitude); + ::sprintf(lat, "%04.2lf", latitude); char lon[20U]; - if (longitude >= 10000.0F) - ::sprintf(lon, "%.2lf", longitude); - else if (longitude >= 1000.0F) - ::sprintf(lon, "0%.2lf", longitude); - else if (longitude >= 100.0F) - ::sprintf(lon, "00%.2lf", longitude); - else if (longitude >= 10.0F) - ::sprintf(lon, "000%.2lf", longitude); - else - ::sprintf(lon, "0000%.2lf", longitude); - - // Convert commas to periods in the latitude, longitude and frequencies - p = ::strchr(lat, ','); - if (p != NULL) - *p = '.'; - - p = ::strchr(lon, ','); - if (p != NULL) - *p = '.'; + ::sprintf(lon, "%05.2lf", longitude); char symbol; switch (radio) { @@ -214,39 +189,10 @@ void CAPRSWriter::sendIdFrames() longitude = (tempLong - longitude) * 60.0 + longitude * 100.0; char lat[20U]; - if (latitude >= 1000.0F) - ::sprintf(lat, "%.2lf", latitude); - else if (latitude >= 100.0F) - ::sprintf(lat, "0%.2lf", latitude); - else if (latitude >= 10.0F) - ::sprintf(lat, "00%.2lf", latitude); - else - ::sprintf(lat, "000%.2lf", latitude); + ::sprintf(lat, "%04.2lf", latitude); char lon[20U]; - if (longitude >= 10000.0F) - ::sprintf(lon, "%.2lf", longitude); - else if (longitude >= 1000.0F) - ::sprintf(lon, "0%.2lf", longitude); - else if (longitude >= 100.0F) - ::sprintf(lon, "00%.2lf", longitude); - else if (longitude >= 10.0F) - ::sprintf(lon, "000%.2lf", longitude); - else - ::sprintf(lon, "0000%.2lf", longitude); - - // Convert commas to periods in the latitude, longitude and frequencies - char* p = ::strchr(lat, ','); - if (p != NULL) - *p = '.'; - - p = ::strchr(lon, ','); - if (p != NULL) - *p = '.'; - - p = ::strchr(desc, ','); - if (p != NULL) - *p = '.'; + ::sprintf(lon, "%05.2lf", longitude); std::string server = m_callsign; int pos = server.find_first_of('-'); diff --git a/YSFGateway/YSFGateway.cpp b/YSFGateway/YSFGateway.cpp index d9f625c..6938d39 100644 --- a/YSFGateway/YSFGateway.cpp +++ b/YSFGateway/YSFGateway.cpp @@ -97,6 +97,8 @@ int CYSFGateway::run() return 1; } + setlocale(LC_ALL, "C"); + ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); if (!ret) { ::fprintf(stderr, "YSFGateway: unable to open the log file\n");