1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Added distance & time info

This commit is contained in:
Martin Tůma 2015-10-14 02:54:36 +02:00
parent 7e2b27acf1
commit da42f3ab33
5 changed files with 96 additions and 41 deletions

View File

@ -34,12 +34,12 @@
<translation>Klesání</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="47"/>
<location filename="../src/elevationgraph.cpp" line="48"/>
<source>Minimum</source>
<translation>Minimum</translation>
</message>
<message>
<location filename="../src/elevationgraph.cpp" line="48"/>
<location filename="../src/elevationgraph.cpp" line="47"/>
<source>Maximum</source>
<translation>Maximum</translation>
</message>
@ -47,118 +47,123 @@
<context>
<name>GUI</name>
<message>
<location filename="../src/gui.cpp" line="70"/>
<location filename="../src/gui.cpp" line="84"/>
<source>About Qt</source>
<translation>O Qt</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="181"/>
<location filename="../src/gui.cpp" line="198"/>
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
</message>
<message>
<location filename="../src/gui.cpp" line="189"/>
<location filename="../src/gui.cpp" line="206"/>
<source>Open file</source>
<translation>Otevřít soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="84"/>
<location filename="../src/gui.cpp" line="98"/>
<source>Save as</source>
<translation>Uložit jako</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="239"/>
<location filename="../src/gui.cpp" line="261"/>
<source>Open POI file</source>
<translation>Otevřít POI soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="75"/>
<location filename="../src/gui.cpp" line="89"/>
<source>Open</source>
<translation>Otevřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="63"/>
<location filename="../src/gui.cpp" line="77"/>
<source>Quit</source>
<translation>Ukončit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="79"/>
<location filename="../src/gui.cpp" line="93"/>
<source>Save</source>
<translation>Uložit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="89"/>
<location filename="../src/gui.cpp" line="103"/>
<source>Close</source>
<translation>Zavřít</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="96"/>
<location filename="../src/gui.cpp" line="110"/>
<source>Load file</source>
<translation>Nahrát soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="99"/>
<location filename="../src/gui.cpp" line="113"/>
<source>Show</source>
<translation>Zobrazit</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="106"/>
<location filename="../src/gui.cpp" line="129"/>
<location filename="../src/gui.cpp" line="120"/>
<location filename="../src/gui.cpp" line="143"/>
<source>File</source>
<translation>Soubor</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="118"/>
<location filename="../src/gui.cpp" line="137"/>
<location filename="../src/gui.cpp" line="132"/>
<location filename="../src/gui.cpp" line="151"/>
<source>POI</source>
<translation>POI</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="122"/>
<location filename="../src/gui.cpp" line="136"/>
<source>Help</source>
<translation>Nápověda</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="155"/>
<location filename="../src/gui.cpp" line="169"/>
<source>Elevation</source>
<translation>Výška</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="156"/>
<location filename="../src/gui.cpp" line="170"/>
<source>Speed</source>
<translation>Rychlost</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="68"/>
<location filename="../src/gui.cpp" line="178"/>
<location filename="../src/gui.cpp" line="82"/>
<location filename="../src/gui.cpp" line="195"/>
<source>About GPXSee</source>
<translation>O aplikaci GPXSee</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="180"/>
<location filename="../src/gui.cpp" line="197"/>
<source>GPX viewer and analyzer</source>
<translation>Prohlížeč a analyzátor GPX</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="223"/>
<location filename="../src/gui.cpp" line="240"/>
<source>%1 tracks</source>
<translation>Počet tras: %1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="229"/>
<location filename="../src/gui.cpp" line="243"/>
<location filename="../src/gui.cpp" line="245"/>
<source>km</source>
<translation>km</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="251"/>
<location filename="../src/gui.cpp" line="265"/>
<source>Error</source>
<translation>Chyba</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="230"/>
<location filename="../src/gui.cpp" line="252"/>
<source>Error loading GPX file:
%1</source>
<translation>Soubor GPX nelze otevřít:
%1</translation>
</message>
<message>
<location filename="../src/gui.cpp" line="244"/>
<location filename="../src/gui.cpp" line="266"/>
<source>Error loading POI file:
%1</source>
<translation>Soubor POI nelze otevřít:

View File

@ -29,16 +29,15 @@ bool GPX::loadFile(const QString &fileName)
void GPX::elevationGraph(QVector<QPointF> &graph) const
{
qreal dist = 0, ds, dh, acc;
qreal dist = 0, dh, acc;
if (!_data.size())
return;
graph.append(QPointF(0, _data.at(0).elevation));
for (int i = 1; i < _data.size(); i++) {
ds = llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
dh = _data.at(i).elevation;
dist += ds;
acc = (i == 1) ? dh : (ALPHA_E * dh) + (1.0 - ALPHA_E) * acc;
graph.append(QPointF(dist, acc));
}
@ -73,3 +72,22 @@ void GPX::track(QVector<QPointF> &track) const
track.append(p);
}
}
qreal GPX::distance()
{
qreal dist = 0;
for (int i = 1; i < _data.size(); i++)
dist += llDistance(_data.at(i).coordinates, _data.at(i-1).coordinates);
return dist;
}
qreal GPX::time()
{
if (_data.size() < 2)
return 0;
return (_data.at(0).timestamp.msecsTo(_data.at(_data.size() - 1).timestamp)
/ 1000.0);
}

View File

@ -15,6 +15,8 @@ public:
void elevationGraph(QVector<QPointF> &graph) const;
void speedGraph(QVector<QPointF> &graph) const;
void track(QVector<QPointF> &track) const;
qreal distance();
qreal time();
private:
Parser _parser;

View File

@ -20,6 +20,18 @@
#include <QDebug>
static QString timeSpan(qreal time)
{
unsigned h, m, s;
h = time / 3600;
m = (time - (h * 3600)) / 60;
s = time - (h * 3600) - (m * 60);
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
.arg(s,2, 10, QChar('0'));
}
GUI::GUI()
{
createActions();
@ -47,6 +59,8 @@ GUI::GUI()
_dirIndex = -1;
_files = 0;
_distance = 0;
_time = 0;
resize(600, 800);
}
@ -164,12 +178,15 @@ void GUI::createTrackGraphs()
void GUI::createStatusBar()
{
_fileName = new QLabel();
_zoom = new QLabel();
_zoom->setAlignment(Qt::AlignHCenter);
_fileNameLabel = new QLabel();
_distanceLabel = new QLabel();
_timeLabel = new QLabel();
_distanceLabel->setAlignment(Qt::AlignHCenter);
_timeLabel->setAlignment(Qt::AlignHCenter);
statusBar()->addPermanentWidget(_fileName, 9);
statusBar()->addPermanentWidget(_zoom, 1);
statusBar()->addPermanentWidget(_fileNameLabel, 8);
statusBar()->addPermanentWidget(_distanceLabel, 1);
statusBar()->addPermanentWidget(_timeLabel, 1);
statusBar()->setSizeGripEnabled(false);
}
@ -220,9 +237,14 @@ bool GUI::openFile(const QString &fileName)
_fileActionGroup->setEnabled(true);
if (++_files > 1)
_fileName->setText(tr("%1 tracks").arg(_files));
_fileNameLabel->setText(tr("%1 tracks").arg(_files));
else
_fileName->setText(fileName);
_fileNameLabel->setText(fileName);
_distance += gpx.distance();
_distanceLabel->setText(QString::number(_distance / 1000, 'f', 1)
+ " " + tr("km"));
_time += gpx.time();
_timeLabel->setText(timeSpan(_time));
return true;
} else {
@ -289,11 +311,15 @@ void GUI::saveFile(const QString &fileName)
void GUI::closeFile()
{
_files = 0;
_distance = 0;
_time = 0;
_elevationGraph->clear();
_speedGraph->clear();
_track->clear();
_fileName->clear();
_fileNameLabel->clear();
_distanceLabel->clear();
_timeLabel->clear();
_fileActionGroup->setEnabled(false);
}

View File

@ -68,8 +68,9 @@ private:
QAction *_openPOIAction;
QAction *_showPOIAction;
QLabel *_fileName;
QLabel *_zoom;
QLabel *_fileNameLabel;
QLabel *_distanceLabel;
QLabel *_timeLabel;
ElevationGraph *_elevationGraph;
SpeedGraph *_speedGraph;
@ -82,6 +83,9 @@ private:
QString _saveFileName;
unsigned _files;
qreal _distance;
qreal _time;
};
#endif // GUI_H