Skip to content

Commit

Permalink
v0.4.0
Browse files Browse the repository at this point in the history
**[v0.4.0]**
- [update] Updated to Qt 5.7.
- [update] Updated QMapControl to version 0.9.7.9.
- [update] Updated QCustomPlot to version 1.3.2.
- [new] The diagram's x axis now show elapsed time instead of absoulte
time.
- [fix] Corrected timezone problem in NMEA and GPX parser.
  • Loading branch information
BourgeoisLab committed Jul 9, 2016
1 parent 41019b7 commit d403efc
Show file tree
Hide file tree
Showing 37 changed files with 1,476 additions and 725 deletions.
2 changes: 1 addition & 1 deletion GPXLab.doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = GPXLab
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = v0.3.0
PROJECT_NUMBER = v0.4.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
5 changes: 4 additions & 1 deletion GPXLab/GPXLab.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
greaterThan(QT_MAJOR_VERSION, 4): cache()

ORGANISATION = BourgeoisLab
TARGET = GPXLab
VERSION = 0.3.0.0
VERSION = 0.4.0.0
TEMPLATE = app

DEFINES += ORGANISATION=\\\"$$ORGANISATION\\\" TARGET=\\\"$$TARGET\\\" VERSION=\\\"$$VERSION\\\"

win32:RC_ICONS += gpxlab.ico

MOC_DIR = tmp
Expand Down
8 changes: 6 additions & 2 deletions GPXLab/commands/pointeditcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void PointEditCommand::redo()
if (dValue)
{
// temporary copy old values
double tmpValue[numProperties];
double *tmpValue = new double[numProperties];
for (i = 0; i < numProperties; ++i)
tmpValue[i] = gpxmw->getTrackPointPropertyAsDouble(trkpt, property[i]);

Expand All @@ -89,11 +89,13 @@ void PointEditCommand::redo()
// store old values
for (i = 0; i < numProperties; ++i)
dValue[i] = tmpValue[i];

delete[] tmpValue;
}
else
{
// temporary copy old values
QString tmpValue[numProperties];
QString *tmpValue = new QString[numProperties];
for (i = 0; i < numProperties; ++i)
tmpValue[i] = gpxmw->getTrackPointPropertyAsString(trkpt, property[i]);

Expand All @@ -103,6 +105,8 @@ void PointEditCommand::redo()
// store old values
for (i = 0; i < numProperties; ++i)
sValue[i] = tmpValue[i];

delete[] tmpValue;
}
}
}
4 changes: 2 additions & 2 deletions GPXLab/commands/pointeditcommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
* @brief Edit point property command
*
* @author Frederic Bourgeois <bourgeoislab@gmail.com>
* @version 1.1
* @date 4 Jan 2015
* @version 1.2
* @date 9 Jul 2016
*/
class PointEditCommand : public QUndoCommand
{
Expand Down
4 changes: 2 additions & 2 deletions GPXLab/dialogs/dialog_about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Dialog_about::Dialog_about(QWidget *parent) :
{
ui->setupUi(this);

ui->labelMain->setText(GPXLab::appName + " " + GPXLab::appVersion);
ui->labelCopyright->setText("© 2014 - 2015 " + GPXLab::organisationName);
ui->labelMain->setText(GPXLab::appName + " v" + GPXLab::appVersion);
ui->labelCopyright->setText("© 2014 - 2016 " + GPXLab::organisationName);
ui->labelLinkHomepage->setOpenExternalLinks(true);
ui->labelLinkSourceCode->setOpenExternalLinks(true);
ui->labelLinkRelease->setOpenExternalLinks(true);
Expand Down
4 changes: 2 additions & 2 deletions GPXLab/dialogs/dialog_about.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class Dialog_about;
* @brief About dialogue
*
* @author Frederic Bourgeois <bourgeoislab@gmail.com>
* @version 1.2
* @date 4 Feb 2015
* @version 1.3
* @date 9 Jul 2016
*/
class Dialog_about : public QDialog
{
Expand Down
3 changes: 2 additions & 1 deletion GPXLab/dialogs/dialog_srtm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Dialog_srtm::Dialog_srtm(const GPX_wrapper *gpxmw, QWidget *parent) :

// add original curve
ui->widgetPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
ui->widgetPlot->xAxis->setDateTimeFormat("d.M.yyyy\nH:mm:ss");
ui->widgetPlot->xAxis->setDateTimeFormat("H:mm");
ui->widgetPlot->xAxis->setDateTimeSpec(Qt::UTC);
ui->widgetPlot->yAxis->setLabel("Altitude [m]");
ui->widgetPlot->addGraph();
ui->widgetPlot->addGraph();
Expand Down
4 changes: 2 additions & 2 deletions GPXLab/dialogs/dialog_srtm.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class Dialog_srtm;
* @see GPX_model and SRTM
*
* @author Frederic Bourgeois <bourgeoislab@gmail.com>
* @version 1.2
* @date 4 Jan 2015
* @version 1.3
* @date 15 Feb 2015
*/
class Dialog_srtm : public QDialog
{
Expand Down
46 changes: 42 additions & 4 deletions GPXLab/gpx_model/gpxfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ static int gExtensionPrevState = PARSING_NONE;
static int gExtensionLevelDepth = 0;
static bool gExtensionDoubleOpen = false;

static void SYS_setenv(const char *name, const char *value)
{
#ifdef WIN32
char str[128];
sprintf(str, "%s=%s", name, value);
putenv(str);
#else
setenv(name, value, 1);
#endif
}

static void SYS_unsetenv(const char *name)
{
#ifdef WIN32
char str[128];
sprintf(str, "%s=", name);
putenv(str);
#else
unsetenv(name);
#endif
}

static int getChar(void* ptr)
{
return ((ifstream*)((T_uXml*)ptr)->fp)->get();
Expand All @@ -74,7 +96,7 @@ static time_t strToTime(const string str)
timeinfo.tm_min = atoi(str.substr(14, 2).c_str());
timeinfo.tm_sec = atoi(str.substr(17, 2).c_str());
timeinfo.tm_isdst = 0;
return mktime(&timeinfo) - timezone;
return mktime(&timeinfo);
}

static int strToMilliseconds(const string str)
Expand Down Expand Up @@ -721,6 +743,8 @@ static void closeTag(void* pXml, char* pTag)

GPX_model::retCode_e GPXFile::load(ifstream* fp, GPX_model* gpxm, bool overwriteMetadata)
{
int ret;
char *tz;
T_uXml uXML;

UXML_init(&uXML);
Expand All @@ -739,9 +763,23 @@ GPX_model::retCode_e GPXFile::load(ifstream* fp, GPX_model* gpxm, bool overwrite
gOverwriteMetadata = overwriteMetadata;
gExtensionVector = NULL;

if (UXML_parseFile(&uXML) != 0)
return GPX_model::GPXM_ERR_FAILED;
// set timezone temporary to UTC
tz = getenv("TZ");
SYS_setenv("TZ", "UTC");
tzset();

// parse file
ret = UXML_parseFile(&uXML);

// change back timezone
if (tz)
SYS_setenv("TZ", tz);
else
SYS_unsetenv("TZ");
tzset();

if (ret != 0)
return GPX_model::GPXM_ERR_FAILED;
return GPX_model::GPXM_OK;
}

Expand Down Expand Up @@ -1004,7 +1042,7 @@ GPX_model::retCode_e GPXFile::save(ofstream* fp, const GPX_model* gpxm)
writeLink(fp, 2, &*link);
writeLineIndent(fp, 2);
writeStr(fp, "<number>", false);
sprintf(gBuffer, "%d", trk->metadata.number);
sprintf(gBuffer, "%zu", trk->metadata.number);
writeStr(fp, gBuffer, false);
writeStr(fp, "</number>");
if (!trk->metadata.type.empty())
Expand Down
4 changes: 2 additions & 2 deletions GPXLab/gpx_model/gpxfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ using namespace std;
* @see http://www.topografix.com/gpx.asp
*
* @author Frederic Bourgeois <bourgeoislab@gmail.com>
* @version 1.2
* @date 4 Jan 2015
* @version 1.3
* @date 9 Jul 2016
*/
namespace GPXFile
{
Expand Down
44 changes: 39 additions & 5 deletions GPXLab/gpx_model/nmeafile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@
static bool hasDate = false;
static int tm_mday = 0, tm_mon = 0, tm_year = 0;

static void SYS_setenv(const char *name, const char *value)
{
#ifdef WIN32
char str[128];
sprintf(str, "%s=%s", name, value);
putenv(str);
#else
setenv(name, value, 1);
#endif
}

static void SYS_unsetenv(const char *name)
{
#ifdef WIN32
char str[128];
sprintf(str, "%s=", name);
putenv(str);
#else
unsetenv(name);
#endif
}

static int parse_hex(char c)
{
if (c < '0')
Expand Down Expand Up @@ -122,7 +144,7 @@ static int parseNMEA(GPX_wptType *pWp, const char *pNmea)
timeinfo.tm_mon = tm_mon;
timeinfo.tm_year = tm_year;
timeinfo.tm_isdst = 0;
pWp->timestamp = mktime(&timeinfo) - timezone;
pWp->timestamp = mktime(&timeinfo);
p = strchr(p, '.') + 1;
pWp->millisecond = atoi(p);

Expand Down Expand Up @@ -209,7 +231,7 @@ static int parseNMEA(GPX_wptType *pWp, const char *pNmea)
timeinfo.tm_mday = tm_mday;
timeinfo.tm_mon = tm_mon;
timeinfo.tm_year = tm_year;
pWp->timestamp = mktime(&timeinfo) - timezone;
pWp->timestamp = mktime(&timeinfo);
return 0;
}

Expand Down Expand Up @@ -244,7 +266,7 @@ static int parseNMEA(GPX_wptType *pWp, const char *pNmea)
timeinfo.tm_mday = itime / 10000;
timeinfo.tm_mon = (itime % 10000) / 100 - 1;
timeinfo.tm_year = 100 + (itime % 100);
pWp->timestamp = mktime(&timeinfo) - timezone;
pWp->timestamp = mktime(&timeinfo);
tm_mday = timeinfo.tm_mday;
tm_mon = timeinfo.tm_mon;
tm_year = timeinfo.tm_year;
Expand Down Expand Up @@ -322,6 +344,11 @@ GPX_model::retCode_e NMEAFile::load(ifstream* fp, GPX_model* gpxm, const string&
char buffer[NMEA_MAXLENGTH];
bool hasComputedMissingDate = false;

// set timezone temporary to UTC
char *tz = getenv("TZ");
SYS_setenv("TZ", "UTC");
tzset();

hasDate = false;
tm_mday = 1;
tm_mon = 0;
Expand All @@ -344,7 +371,7 @@ GPX_model::retCode_e NMEAFile::load(ifstream* fp, GPX_model* gpxm, const string&
timeinfo->tm_mon = tm_mon;
timeinfo->tm_year = tm_year;
timeinfo->tm_isdst = 0;
itrkpt->timestamp = mktime(timeinfo) - timezone;
itrkpt->timestamp = mktime(timeinfo);
}

// add date to last point
Expand All @@ -355,7 +382,7 @@ GPX_model::retCode_e NMEAFile::load(ifstream* fp, GPX_model* gpxm, const string&
timeinfo->tm_mon = tm_mon;
timeinfo->tm_year = tm_year;
timeinfo->tm_isdst = 0;
trkpt_last.timestamp = mktime(timeinfo) - timezone;
trkpt_last.timestamp = mktime(timeinfo);
}

hasComputedMissingDate = true;
Expand All @@ -374,6 +401,13 @@ GPX_model::retCode_e NMEAFile::load(ifstream* fp, GPX_model* gpxm, const string&
}
}

// change back timezone
if (tz)
SYS_setenv("TZ", tz);
else
SYS_unsetenv("TZ");
tzset();

// add last track point
trkseg.trkpt.push_back(trkpt_last);

Expand Down
4 changes: 2 additions & 2 deletions GPXLab/gpx_model/nmeafile.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ using namespace std;
* @see http://www.gpsinformation.org/dale/nmea.htm
*
* @author Frederic Bourgeois <bourgeoislab@gmail.com>
* @version 1.1
* @date 4 Jan 2015
* @version 1.2
* @date 15 Feb 2015
*/
namespace NMEAFile
{
Expand Down
6 changes: 3 additions & 3 deletions GPXLab/gpx_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ GPX_model::retCode_e GPX_wrapper::setTrackPointProperty(int trackNumber, int tra
trkpt->fix = 0.0;
break;
case sat:
trkpt->sat = (int)value;
trkpt->sat = (int)value[i];
break;
case timestamp:
trkpt->timestamp = (time_t)value[i];
Expand Down Expand Up @@ -1146,7 +1146,7 @@ GPX_model::retCode_e GPX_wrapper::generateDiagramValues(int trackNumber, int tra
{
for (trkpt = trkseg->trkpt.begin(); trkpt != trkseg->trkpt.end(); trkpt++)
{
timeValues.append(trkpt->timestamp);
timeValues.append(trkpt->elapsedTime);
altitudeValues.append(trkpt->altitude);
curveMainValues.append(getTrackPointPropertyAsDouble(&*trkpt, curveMain));
curveSecondaryValues.append(getTrackPointPropertyAsDouble(&*trkpt, curveSecondary));
Expand All @@ -1161,7 +1161,7 @@ GPX_model::retCode_e GPX_wrapper::generateDiagramValues(int trackNumber, int tra
// track segment
for (trkpt = gpxm->trk[trackNumber].trkseg[trackSegmentNumber].trkpt.begin(); trkpt != gpxm->trk[trackNumber].trkseg[trackSegmentNumber].trkpt.end(); trkpt++)
{
timeValues.append(trkpt->timestamp);
timeValues.append(trkpt->elapsedTime);
altitudeValues.append(trkpt->altitude);
curveMainValues.append(getTrackPointPropertyAsDouble(&*trkpt, curveMain));
curveSecondaryValues.append(getTrackPointPropertyAsDouble(&*trkpt, curveSecondary));
Expand Down
4 changes: 2 additions & 2 deletions GPXLab/gpx_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
* @see GPX_Model
*
* @author Frederic Bourgeois <bourgeoislab@gmail.com>
* @version 1.2
* @date 5 Feb 2015
* @version 1.4
* @date 9 Jul 2016
*/
class GPX_wrapper : public QObject
{
Expand Down
Loading

0 comments on commit d403efc

Please sign in to comment.