mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-12-05 00:39:09 +01:00
Compare commits
2 Commits
a4a54101a3
...
190a961242
Author | SHA1 | Date | |
---|---|---|---|
190a961242 | |||
ccfb748404 |
@ -224,6 +224,12 @@ qreal GraphItem::timeAtDistance(qreal distance) const
|
||||
return l.pointAt((distance - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
||||
}
|
||||
|
||||
GraphItem::SegmentTime GraphItem::date(qreal x)
|
||||
{
|
||||
const GraphSegment *seg = segment(x, _type);
|
||||
return seg ? SegmentTime(seg->start(), seg->first().t()) : SegmentTime();
|
||||
}
|
||||
|
||||
void GraphItem::hover(bool hover)
|
||||
{
|
||||
if (hover) {
|
||||
|
@ -12,6 +12,16 @@ class GraphItem : public QObject, public GraphicsItem
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
struct SegmentTime
|
||||
{
|
||||
SegmentTime() : time(NAN) {}
|
||||
SegmentTime(const QDateTime &date, qreal time)
|
||||
: date(date), time(time) {}
|
||||
|
||||
QDateTime date;
|
||||
qreal time;
|
||||
};
|
||||
|
||||
GraphItem(const Graph &graph, GraphType type, int width,
|
||||
const QColor &color, Qt::PenStyle style, QGraphicsItem *parent = 0);
|
||||
virtual ~GraphItem() {}
|
||||
@ -43,6 +53,7 @@ public:
|
||||
qreal yAtX(qreal x) const;
|
||||
qreal distanceAtTime(qreal time) const;
|
||||
qreal timeAtDistance(qreal distance) const;
|
||||
SegmentTime date(qreal x);
|
||||
|
||||
void redraw();
|
||||
|
||||
|
@ -334,12 +334,18 @@ void PathItem::setMarkerPosition(qreal pos)
|
||||
void PathItem::setMarkerInfo(qreal pos)
|
||||
{
|
||||
if (_markerInfoType == MarkerInfoItem::Date) {
|
||||
qreal time = _graph
|
||||
? (_graph->graphType() == Time) ? pos : _graph->timeAtDistance(pos)
|
||||
: NAN;
|
||||
QDateTime d(date());
|
||||
if (!std::isnan(time) && d.isValid())
|
||||
_markerInfo->setDate(d.addSecs(time).toTimeZone(_timeZone));
|
||||
QDateTime date;
|
||||
|
||||
if (_graph) {
|
||||
qreal time = (_graph->graphType() == Time)
|
||||
? pos : _graph->timeAtDistance(pos);
|
||||
GraphItem::SegmentTime st(_graph->date(pos));
|
||||
if (st.date.isValid() && !std::isnan(time))
|
||||
date = st.date.addSecs(time - st.time);
|
||||
}
|
||||
|
||||
if (date.isValid())
|
||||
_markerInfo->setDate(date.toTimeZone(_timeZone));
|
||||
else
|
||||
_markerInfo->setDate(QDateTime());
|
||||
} else if (_markerInfoType == MarkerInfoItem::Position)
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QList>
|
||||
#include <QVector>
|
||||
#include <QColor>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
@ -41,7 +42,19 @@ inline QDebug operator<<(QDebug dbg, const GraphPoint &point)
|
||||
}
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
typedef QVector<GraphPoint> GraphSegment;
|
||||
class GraphSegment : public QVector<GraphPoint>
|
||||
{
|
||||
public:
|
||||
GraphSegment(const QDateTime &start)
|
||||
: _start(start) {}
|
||||
GraphSegment(int size, const QDateTime &start)
|
||||
: QVector<GraphPoint>(size), _start(start) {}
|
||||
|
||||
const QDateTime &start() const {return _start;}
|
||||
|
||||
private:
|
||||
QDateTime _start;
|
||||
};
|
||||
|
||||
class Graph : public QList<GraphSegment>
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ Path Route::path() const
|
||||
Graph Route::gpsElevation() const
|
||||
{
|
||||
Graph graph;
|
||||
graph.append(GraphSegment());
|
||||
graph.append(GraphSegment(QDateTime()));
|
||||
GraphSegment &gs = graph.last();
|
||||
|
||||
for (int i = 0; i < _data.size(); i++)
|
||||
@ -49,7 +49,7 @@ Graph Route::gpsElevation() const
|
||||
Graph Route::demElevation() const
|
||||
{
|
||||
Graph graph;
|
||||
graph.append(GraphSegment());
|
||||
graph.append(GraphSegment(QDateTime()));
|
||||
GraphSegment &gs = graph.last();
|
||||
|
||||
for (int i = 0; i < _data.size(); i++) {
|
||||
|
@ -66,10 +66,10 @@ static QSet<int> eliminate(const QVector<qreal> &v)
|
||||
static GraphSegment filter(const GraphSegment &g, int window)
|
||||
{
|
||||
if (g.size() < window || window < 2)
|
||||
return GraphSegment(g);
|
||||
return g;
|
||||
|
||||
qreal acc = 0;
|
||||
GraphSegment ret(g.size());
|
||||
GraphSegment ret(g.size(), g.start());
|
||||
|
||||
for (int i = 0; i < window; i++)
|
||||
acc += g.at(i).y();
|
||||
@ -131,6 +131,7 @@ Track::Track(const TrackData &data) : _pause(0)
|
||||
|
||||
Segment &seg = _segments.last();
|
||||
|
||||
seg.start = sd.first().timestamp();
|
||||
seg.distance.append(lastDistance(i));
|
||||
seg.time.append(sd.first().hasTimestamp() ? lastTime(i) : NAN);
|
||||
seg.speed.append(sd.first().hasTimestamp() ? 0 : NAN);
|
||||
@ -257,7 +258,7 @@ Graph Track::gpsElevation() const
|
||||
if (sd.size() < 2)
|
||||
continue;
|
||||
const Segment &seg = _segments.at(i);
|
||||
GraphSegment gs;
|
||||
GraphSegment gs(seg.start);
|
||||
|
||||
for (int j = 0; j < sd.size(); j++) {
|
||||
if (!sd.at(j).hasElevation() || seg.outliers.contains(j))
|
||||
@ -285,7 +286,7 @@ Graph Track::demElevation() const
|
||||
if (sd.size() < 2)
|
||||
continue;
|
||||
const Segment &seg = _segments.at(i);
|
||||
GraphSegment gs;
|
||||
GraphSegment gs(seg.start);
|
||||
|
||||
for (int j = 0; j < sd.size(); j++) {
|
||||
qreal dem = DEM::elevation(sd.at(j).coordinates());
|
||||
@ -328,7 +329,7 @@ Graph Track::computedSpeed() const
|
||||
if (sd.size() < 2)
|
||||
continue;
|
||||
const Segment &seg = _segments.at(i);
|
||||
GraphSegment gs;
|
||||
GraphSegment gs(seg.start);
|
||||
QList<int> stop;
|
||||
qreal v;
|
||||
|
||||
@ -368,7 +369,7 @@ Graph Track::reportedSpeed() const
|
||||
if (sd.size() < 2)
|
||||
continue;
|
||||
const Segment &seg = _segments.at(i);
|
||||
GraphSegment gs;
|
||||
GraphSegment gs(seg.start);
|
||||
QList<int> stop;
|
||||
qreal v;
|
||||
|
||||
@ -423,7 +424,7 @@ Graph Track::heartRate() const
|
||||
if (sd.size() < 2)
|
||||
continue;
|
||||
const Segment &seg = _segments.at(i);
|
||||
GraphSegment gs;
|
||||
GraphSegment gs(seg.start);
|
||||
|
||||
for (int j = 0; j < sd.size(); j++)
|
||||
if (sd.at(j).hasHeartRate() && !seg.outliers.contains(j))
|
||||
@ -449,7 +450,7 @@ Graph Track::temperature() const
|
||||
if (sd.size() < 2)
|
||||
continue;
|
||||
const Segment &seg = _segments.at(i);
|
||||
GraphSegment gs;
|
||||
GraphSegment gs(seg.start);
|
||||
|
||||
for (int j = 0; j < sd.count(); j++) {
|
||||
if (sd.at(j).hasTemperature() && !seg.outliers.contains(j))
|
||||
@ -476,7 +477,7 @@ Graph Track::ratio() const
|
||||
if (sd.size() < 2)
|
||||
continue;
|
||||
const Segment &seg = _segments.at(i);
|
||||
GraphSegment gs;
|
||||
GraphSegment gs(seg.start);
|
||||
|
||||
for (int j = 0; j < sd.size(); j++)
|
||||
if (sd.at(j).hasRatio() && !seg.outliers.contains(j))
|
||||
@ -502,7 +503,7 @@ Graph Track::cadence() const
|
||||
if (sd.size() < 2)
|
||||
continue;
|
||||
const Segment &seg = _segments.at(i);
|
||||
GraphSegment gs;
|
||||
GraphSegment gs(seg.start);
|
||||
QList<int> stop;
|
||||
qreal c;
|
||||
|
||||
@ -545,7 +546,7 @@ Graph Track::power() const
|
||||
if (sd.size() < 2)
|
||||
continue;
|
||||
const Segment &seg = _segments.at(i);
|
||||
GraphSegment gs;
|
||||
GraphSegment gs(seg.start);
|
||||
|
||||
for (int j = 0; j < sd.size(); j++) {
|
||||
if (sd.at(j).hasPower() && seg.stop.contains(j)) {
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
|
||||
private:
|
||||
struct Segment {
|
||||
QDateTime start;
|
||||
QVector<qreal> distance;
|
||||
QVector<qreal> time;
|
||||
QVector<qreal> speed;
|
||||
|
@ -157,7 +157,7 @@ void KMZMap::computeBounds()
|
||||
_adjust = 0;
|
||||
_bounds = QVector<Bounds>(_tiles.count());
|
||||
for (int i = 0; i < _tiles.count(); i++) {
|
||||
QRectF xy(offsets.at(i), _tiles.at(i).bounds().size());
|
||||
QRectF xy(offsets.at(i), _tiles.at(i).bounds().size() / _mapRatio);
|
||||
_bounds[i] = Bounds(_tiles.at(i).bbox(), xy);
|
||||
_adjust = qMin(qMin(_tiles.at(i).bounds().left(),
|
||||
_tiles.at(i).bounds().top()), _adjust);
|
||||
|
Loading…
Reference in New Issue
Block a user