mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Added support for polygon objects
This commit is contained in:
parent
91e633e9fa
commit
50306ecb84
@ -153,7 +153,10 @@ HEADERS += src/common/config.h \
|
|||||||
src/data/locparser.h \
|
src/data/locparser.h \
|
||||||
src/data/slfparser.h \
|
src/data/slfparser.h \
|
||||||
src/data/dem.h \
|
src/data/dem.h \
|
||||||
src/map/polarstereographic.h
|
src/map/polarstereographic.h \
|
||||||
|
src/data/polygon.h \
|
||||||
|
src/data/area.h \
|
||||||
|
src/GUI/areaitem.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/common/coordinates.cpp \
|
src/common/coordinates.cpp \
|
||||||
src/common/rectc.cpp \
|
src/common/rectc.cpp \
|
||||||
@ -264,7 +267,9 @@ SOURCES += src/main.cpp \
|
|||||||
src/data/slfparser.cpp \
|
src/data/slfparser.cpp \
|
||||||
src/data/dem.cpp \
|
src/data/dem.cpp \
|
||||||
src/map/polarstereographic.cpp \
|
src/map/polarstereographic.cpp \
|
||||||
src/map/rectd.cpp
|
src/map/rectd.cpp \
|
||||||
|
src/data/polygon.cpp \
|
||||||
|
src/GUI/areaitem.cpp
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||||
HEADERS += src/data/geojsonparser.h
|
HEADERS += src/data/geojsonparser.h
|
||||||
|
155
src/GUI/areaitem.cpp
Normal file
155
src/GUI/areaitem.cpp
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
#include <cmath>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QCursor>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "map/map.h"
|
||||||
|
#include "tooltip.h"
|
||||||
|
#include "areaitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString AreaItem::toolTip() const
|
||||||
|
{
|
||||||
|
ToolTip tt;
|
||||||
|
|
||||||
|
if (!_area.name().isEmpty())
|
||||||
|
tt.insert(qApp->translate("PolygonItem", "Name"), _area.name());
|
||||||
|
if (!_area.description().isEmpty())
|
||||||
|
tt.insert(qApp->translate("PolygonItem", "Description"),
|
||||||
|
_area.description());
|
||||||
|
|
||||||
|
return tt.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
AreaItem::AreaItem(const Area &area, Map *map, QGraphicsItem *parent)
|
||||||
|
: QGraphicsItem(parent), _area(area)
|
||||||
|
{
|
||||||
|
_map = map;
|
||||||
|
_digitalZoom = 0;
|
||||||
|
|
||||||
|
_width = 2;
|
||||||
|
_opacity = 0.5;
|
||||||
|
QBrush brush(Qt::SolidPattern);
|
||||||
|
_pen = QPen(brush, _width);
|
||||||
|
|
||||||
|
updatePainterPath();
|
||||||
|
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
|
||||||
|
setToolTip(toolTip());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPainterPath AreaItem::painterPath(const Polygon &polygon)
|
||||||
|
{
|
||||||
|
QPainterPath path;
|
||||||
|
|
||||||
|
const QVector<Coordinates> &lr = polygon.first();
|
||||||
|
path.moveTo(_map->ll2xy(lr.first()));
|
||||||
|
for (int i = 1; i < lr.size(); i++)
|
||||||
|
path.lineTo(_map->ll2xy(lr.at(i)));
|
||||||
|
path.closeSubpath();
|
||||||
|
|
||||||
|
for (int i = 1; i < polygon.size(); i++) {
|
||||||
|
const QVector<Coordinates> &lr = polygon.at(i);
|
||||||
|
QPainterPath hole;
|
||||||
|
hole.moveTo(_map->ll2xy(lr.first()));
|
||||||
|
for (int j = 1; j < lr.size(); j++)
|
||||||
|
hole.lineTo(_map->ll2xy(lr.at(j)));
|
||||||
|
hole.closeSubpath();
|
||||||
|
path = path.subtracted(hole);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaItem::updatePainterPath()
|
||||||
|
{
|
||||||
|
_painterPath = QPainterPath();
|
||||||
|
|
||||||
|
for (int i = 0; i < _area.size(); i++)
|
||||||
|
_painterPath.addPath(painterPath(_area.at(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
|
painter->setPen(_pen);
|
||||||
|
painter->drawPath(_painterPath);
|
||||||
|
painter->fillPath(_painterPath, _brush);
|
||||||
|
|
||||||
|
/*
|
||||||
|
QPen p = QPen(QBrush(Qt::red), 0);
|
||||||
|
painter->setPen(p);
|
||||||
|
painter->drawRect(boundingRect());
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaItem::setMap(Map *map)
|
||||||
|
{
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_map = map;
|
||||||
|
|
||||||
|
updatePainterPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaItem::setColor(const QColor &color)
|
||||||
|
{
|
||||||
|
if (_pen.color() == color)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QColor bc(color);
|
||||||
|
bc.setAlphaF(_opacity * color.alphaF());
|
||||||
|
|
||||||
|
_pen.setColor(color);
|
||||||
|
_brush = QBrush(bc);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaItem::setOpacity(qreal opacity)
|
||||||
|
{
|
||||||
|
if (_opacity == opacity)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_opacity = opacity;
|
||||||
|
QColor bc(_pen.color());
|
||||||
|
bc.setAlphaF(_opacity * _pen.color().alphaF());
|
||||||
|
_brush = QBrush(bc);
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaItem::setWidth(qreal width)
|
||||||
|
{
|
||||||
|
if (_width == width)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_width = width;
|
||||||
|
_pen.setWidthF(_width * pow(2, -_digitalZoom));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaItem::setStyle(Qt::PenStyle style)
|
||||||
|
{
|
||||||
|
if (_pen.style() == style)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_pen.setStyle(style);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AreaItem::setDigitalZoom(int zoom)
|
||||||
|
{
|
||||||
|
if (_digitalZoom == zoom)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
|
||||||
|
_digitalZoom = zoom;
|
||||||
|
_pen.setWidthF(_width * pow(2, -_digitalZoom));
|
||||||
|
}
|
46
src/GUI/areaitem.h
Normal file
46
src/GUI/areaitem.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#ifndef AREAITEM_H
|
||||||
|
#define AREAITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
#include "data/area.h"
|
||||||
|
|
||||||
|
class Map;
|
||||||
|
|
||||||
|
class AreaItem : public QGraphicsItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AreaItem(const Area &area, Map *map, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
QPainterPath shape() const {return _painterPath;}
|
||||||
|
QRectF boundingRect() const {return _painterPath.boundingRect();}
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget);
|
||||||
|
|
||||||
|
const Area &area() const {return _area;}
|
||||||
|
|
||||||
|
void setMap(Map *map);
|
||||||
|
|
||||||
|
void setColor(const QColor &color);
|
||||||
|
void setOpacity(qreal opacity);
|
||||||
|
void setWidth(qreal width);
|
||||||
|
void setStyle(Qt::PenStyle style);
|
||||||
|
void setDigitalZoom(int zoom);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPainterPath painterPath(const Polygon &polygon);
|
||||||
|
void updatePainterPath();
|
||||||
|
QString toolTip() const;
|
||||||
|
|
||||||
|
Area _area;
|
||||||
|
Map *_map;
|
||||||
|
int _digitalZoom;
|
||||||
|
|
||||||
|
qreal _width;
|
||||||
|
QPen _pen;
|
||||||
|
QBrush _brush;
|
||||||
|
qreal _opacity;
|
||||||
|
|
||||||
|
QPainterPath _painterPath;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // AREAITEM_H
|
@ -32,15 +32,16 @@ QList<GraphItem*> CadenceGraph::loadData(const Data &data)
|
|||||||
QList<GraphItem*> graphs;
|
QList<GraphItem*> graphs;
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
const Graph &graph = data.tracks().at(i)->cadence();
|
const Track &track = data.tracks().at(i);
|
||||||
|
const Graph &graph = track.cadence();
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (!graph.isValid()) {
|
||||||
skipColor();
|
skipColor();
|
||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
} else {
|
} else {
|
||||||
CadenceGraphItem *gi = new CadenceGraphItem(graph, _graphType);
|
CadenceGraphItem *gi = new CadenceGraphItem(graph, _graphType);
|
||||||
GraphView::addGraph(gi);
|
GraphView::addGraph(gi);
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
_avg.append(QPointF(track.distance(), gi->avg()));
|
||||||
graphs.append(gi);
|
graphs.append(gi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,6 +51,9 @@ QList<GraphItem*> CadenceGraph::loadData(const Data &data)
|
|||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < data.areas().count(); i++)
|
||||||
|
skipColor();
|
||||||
|
|
||||||
setInfo();
|
setInfo();
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void ElevationGraph::setInfo()
|
|||||||
|
|
||||||
GraphItem *ElevationGraph::loadGraph(const Graph &graph, Type type)
|
GraphItem *ElevationGraph::loadGraph(const Graph &graph, Type type)
|
||||||
{
|
{
|
||||||
if (graph.size() < 2) {
|
if (!graph.isValid()) {
|
||||||
skipColor();
|
skipColor();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -97,9 +97,11 @@ QList<GraphItem*> ElevationGraph::loadData(const Data &data)
|
|||||||
QList<GraphItem*> graphs;
|
QList<GraphItem*> graphs;
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++)
|
for (int i = 0; i < data.tracks().count(); i++)
|
||||||
graphs.append(loadGraph(data.tracks().at(i)->elevation(), Track));
|
graphs.append(loadGraph(data.tracks().at(i).elevation(), Track));
|
||||||
for (int i = 0; i < data.routes().count(); i++)
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
graphs.append(loadGraph(data.routes().at(i)->elevation(), Route));
|
graphs.append(loadGraph(data.routes().at(i).elevation(), Route));
|
||||||
|
for (int i = 0; i < data.areas().count(); i++)
|
||||||
|
skipColor();
|
||||||
|
|
||||||
setInfo();
|
setInfo();
|
||||||
redraw();
|
redraw();
|
||||||
|
@ -34,9 +34,9 @@ QList<GraphItem*> GearRatioGraph::loadData(const Data &data)
|
|||||||
QList<GraphItem*> graphs;
|
QList<GraphItem*> graphs;
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
const Graph &graph = data.tracks().at(i)->ratio();
|
const Graph &graph = data.tracks().at(i).ratio();
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (!graph.isValid()) {
|
||||||
skipColor();
|
skipColor();
|
||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
} else {
|
} else {
|
||||||
@ -55,6 +55,9 @@ QList<GraphItem*> GearRatioGraph::loadData(const Data &data)
|
|||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < data.areas().count(); i++)
|
||||||
|
skipColor();
|
||||||
|
|
||||||
setInfo();
|
setInfo();
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ GUI::GUI()
|
|||||||
_trackCount = 0;
|
_trackCount = 0;
|
||||||
_routeCount = 0;
|
_routeCount = 0;
|
||||||
_waypointCount = 0;
|
_waypointCount = 0;
|
||||||
|
_areaCount = 0;
|
||||||
_trackDistance = 0;
|
_trackDistance = 0;
|
||||||
_routeDistance = 0;
|
_routeDistance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
@ -329,6 +330,11 @@ void GUI::createActions()
|
|||||||
_showWaypointsAction->setCheckable(true);
|
_showWaypointsAction->setCheckable(true);
|
||||||
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _mapView,
|
connect(_showWaypointsAction, SIGNAL(triggered(bool)), _mapView,
|
||||||
SLOT(showWaypoints(bool)));
|
SLOT(showWaypoints(bool)));
|
||||||
|
_showAreasAction = new QAction(tr("Show areas"), this);
|
||||||
|
_showAreasAction->setMenuRole(QAction::NoRole);
|
||||||
|
_showAreasAction->setCheckable(true);
|
||||||
|
connect(_showAreasAction, SIGNAL(triggered(bool)), _mapView,
|
||||||
|
SLOT(showAreas(bool)));
|
||||||
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
|
_showWaypointLabelsAction = new QAction(tr("Waypoint labels"), this);
|
||||||
_showWaypointLabelsAction->setMenuRole(QAction::NoRole);
|
_showWaypointLabelsAction->setMenuRole(QAction::NoRole);
|
||||||
_showWaypointLabelsAction->setCheckable(true);
|
_showWaypointLabelsAction->setCheckable(true);
|
||||||
@ -521,6 +527,7 @@ void GUI::createMenus()
|
|||||||
dataMenu->addSeparator();
|
dataMenu->addSeparator();
|
||||||
dataMenu->addAction(_showTracksAction);
|
dataMenu->addAction(_showTracksAction);
|
||||||
dataMenu->addAction(_showRoutesAction);
|
dataMenu->addAction(_showRoutesAction);
|
||||||
|
dataMenu->addAction(_showAreasAction);
|
||||||
dataMenu->addAction(_showWaypointsAction);
|
dataMenu->addAction(_showWaypointsAction);
|
||||||
|
|
||||||
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
|
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
|
||||||
@ -753,10 +760,11 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
|
|
||||||
if (data.isValid()) {
|
if (data.isValid()) {
|
||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
_trackDistance += data.tracks().at(i)->distance();
|
const Track &track = data.tracks().at(i);
|
||||||
_time += data.tracks().at(i)->time();
|
_trackDistance += track.distance();
|
||||||
_movingTime += data.tracks().at(i)->movingTime();
|
_time += track.time();
|
||||||
const QDate &date = data.tracks().at(i)->date().date();
|
_movingTime += track.movingTime();
|
||||||
|
const QDate &date = track.date().date();
|
||||||
if (_dateRange.first.isNull() || _dateRange.first > date)
|
if (_dateRange.first.isNull() || _dateRange.first > date)
|
||||||
_dateRange.first = date;
|
_dateRange.first = date;
|
||||||
if (_dateRange.second.isNull() || _dateRange.second < date)
|
if (_dateRange.second.isNull() || _dateRange.second < date)
|
||||||
@ -765,16 +773,17 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
_trackCount += data.tracks().count();
|
_trackCount += data.tracks().count();
|
||||||
|
|
||||||
for (int i = 0; i < data.routes().count(); i++)
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
_routeDistance += data.routes().at(i)->distance();
|
_routeDistance += data.routes().at(i).distance();
|
||||||
_routeCount += data.routes().count();
|
_routeCount += data.routes().count();
|
||||||
|
|
||||||
_waypointCount += data.waypoints().count();
|
_waypointCount += data.waypoints().count();
|
||||||
|
_areaCount += data.areas().count();
|
||||||
|
|
||||||
if (_pathName.isNull()) {
|
if (_pathName.isNull()) {
|
||||||
if (data.tracks().count() == 1 && !data.routes().count())
|
if (data.tracks().count() == 1 && !data.routes().count())
|
||||||
_pathName = data.tracks().first()->name();
|
_pathName = data.tracks().first().name();
|
||||||
else if (data.routes().count() == 1 && !data.tracks().count())
|
else if (data.routes().count() == 1 && !data.tracks().count())
|
||||||
_pathName = data.routes().first()->name();
|
_pathName = data.routes().first().name();
|
||||||
} else
|
} else
|
||||||
_pathName = QString();
|
_pathName = QString();
|
||||||
|
|
||||||
@ -893,8 +902,11 @@ void GUI::openOptions()
|
|||||||
SET_VIEW_OPTION(backgroundColor, setBackgroundColor);
|
SET_VIEW_OPTION(backgroundColor, setBackgroundColor);
|
||||||
SET_VIEW_OPTION(trackWidth, setTrackWidth);
|
SET_VIEW_OPTION(trackWidth, setTrackWidth);
|
||||||
SET_VIEW_OPTION(routeWidth, setRouteWidth);
|
SET_VIEW_OPTION(routeWidth, setRouteWidth);
|
||||||
|
SET_VIEW_OPTION(areaWidth, setAreaWidth);
|
||||||
SET_VIEW_OPTION(trackStyle, setTrackStyle);
|
SET_VIEW_OPTION(trackStyle, setTrackStyle);
|
||||||
SET_VIEW_OPTION(routeStyle, setRouteStyle);
|
SET_VIEW_OPTION(routeStyle, setRouteStyle);
|
||||||
|
SET_VIEW_OPTION(areaStyle, setAreaStyle);
|
||||||
|
SET_VIEW_OPTION(areaOpacity, setAreaOpacity);
|
||||||
SET_VIEW_OPTION(waypointSize, setWaypointSize);
|
SET_VIEW_OPTION(waypointSize, setWaypointSize);
|
||||||
SET_VIEW_OPTION(waypointColor, setWaypointColor);
|
SET_VIEW_OPTION(waypointColor, setWaypointColor);
|
||||||
SET_VIEW_OPTION(poiSize, setPOISize);
|
SET_VIEW_OPTION(poiSize, setPOISize);
|
||||||
@ -1000,6 +1012,9 @@ void GUI::statistics()
|
|||||||
if (_showWaypointsAction->isChecked() && _waypointCount > 1)
|
if (_showWaypointsAction->isChecked() && _waypointCount > 1)
|
||||||
text.append("<tr><td>" + tr("Waypoints") + ":</td><td>"
|
text.append("<tr><td>" + tr("Waypoints") + ":</td><td>"
|
||||||
+ l.toString(_waypointCount) + "</td></tr>");
|
+ l.toString(_waypointCount) + "</td></tr>");
|
||||||
|
if (_showAreasAction->isChecked() && _areaCount > 1)
|
||||||
|
text.append("<tr><td>" + tr("Areas") + ":</td><td>"
|
||||||
|
+ l.toString(_areaCount) + "</td></tr>");
|
||||||
|
|
||||||
if (_dateRange.first.isValid()) {
|
if (_dateRange.first.isValid()) {
|
||||||
if (_dateRange.first == _dateRange.second) {
|
if (_dateRange.first == _dateRange.second) {
|
||||||
@ -1065,6 +1080,8 @@ void GUI::plot(QPrinter *printer)
|
|||||||
info.insert(tr("Routes"), l.toString(_routeCount));
|
info.insert(tr("Routes"), l.toString(_routeCount));
|
||||||
if (_showWaypointsAction->isChecked() && _waypointCount > 1)
|
if (_showWaypointsAction->isChecked() && _waypointCount > 1)
|
||||||
info.insert(tr("Waypoints"), l.toString(_waypointCount));
|
info.insert(tr("Waypoints"), l.toString(_waypointCount));
|
||||||
|
if (_showAreasAction->isChecked() && _areaCount > 1)
|
||||||
|
info.insert(tr("Areas"), l.toString(_areaCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_dateRange.first.isValid() && _options.printDate) {
|
if (_dateRange.first.isValid() && _options.printDate) {
|
||||||
@ -1138,6 +1155,7 @@ void GUI::reloadFile()
|
|||||||
_trackCount = 0;
|
_trackCount = 0;
|
||||||
_routeCount = 0;
|
_routeCount = 0;
|
||||||
_waypointCount = 0;
|
_waypointCount = 0;
|
||||||
|
_areaCount = 0;
|
||||||
_trackDistance = 0;
|
_trackDistance = 0;
|
||||||
_routeDistance = 0;
|
_routeDistance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
@ -1171,6 +1189,7 @@ void GUI::closeFiles()
|
|||||||
_trackCount = 0;
|
_trackCount = 0;
|
||||||
_routeCount = 0;
|
_routeCount = 0;
|
||||||
_waypointCount = 0;
|
_waypointCount = 0;
|
||||||
|
_areaCount = 0;
|
||||||
_trackDistance = 0;
|
_trackDistance = 0;
|
||||||
_routeDistance = 0;
|
_routeDistance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
@ -1457,7 +1476,8 @@ bool GUI::updateMapView()
|
|||||||
if (_options.alwaysShowMap)
|
if (_options.alwaysShowMap)
|
||||||
_mapView->setHidden(false);
|
_mapView->setHidden(false);
|
||||||
else
|
else
|
||||||
_mapView->setHidden(!(_trackCount + _routeCount + _waypointCount));
|
_mapView->setHidden(!(_trackCount + _routeCount + _waypointCount
|
||||||
|
+ _areaCount));
|
||||||
|
|
||||||
return (hidden != _mapView->isHidden());
|
return (hidden != _mapView->isHidden());
|
||||||
}
|
}
|
||||||
@ -1692,6 +1712,8 @@ void GUI::writeSettings()
|
|||||||
if (_showWaypointsAction->isChecked() != SHOW_WAYPOINTS_DEFAULT)
|
if (_showWaypointsAction->isChecked() != SHOW_WAYPOINTS_DEFAULT)
|
||||||
settings.setValue(SHOW_WAYPOINTS_SETTING,
|
settings.setValue(SHOW_WAYPOINTS_SETTING,
|
||||||
_showWaypointsAction->isChecked());
|
_showWaypointsAction->isChecked());
|
||||||
|
if (_showAreasAction->isChecked() != SHOW_AREAS_DEFAULT)
|
||||||
|
settings.setValue(SHOW_AREAS_SETTING, _showAreasAction->isChecked());
|
||||||
if (_showWaypointLabelsAction->isChecked() != SHOW_WAYPOINT_LABELS_DEFAULT)
|
if (_showWaypointLabelsAction->isChecked() != SHOW_WAYPOINT_LABELS_DEFAULT)
|
||||||
settings.setValue(SHOW_WAYPOINT_LABELS_SETTING,
|
settings.setValue(SHOW_WAYPOINT_LABELS_SETTING,
|
||||||
_showWaypointLabelsAction->isChecked());
|
_showWaypointLabelsAction->isChecked());
|
||||||
@ -1732,10 +1754,16 @@ void GUI::writeSettings()
|
|||||||
settings.setValue(TRACK_WIDTH_SETTING, _options.trackWidth);
|
settings.setValue(TRACK_WIDTH_SETTING, _options.trackWidth);
|
||||||
if (_options.routeWidth != ROUTE_WIDTH_DEFAULT)
|
if (_options.routeWidth != ROUTE_WIDTH_DEFAULT)
|
||||||
settings.setValue(ROUTE_WIDTH_SETTING, _options.routeWidth);
|
settings.setValue(ROUTE_WIDTH_SETTING, _options.routeWidth);
|
||||||
|
if (_options.areaWidth != AREA_WIDTH_DEFAULT)
|
||||||
|
settings.setValue(AREA_WIDTH_SETTING, _options.areaWidth);
|
||||||
if (_options.trackStyle != TRACK_STYLE_DEFAULT)
|
if (_options.trackStyle != TRACK_STYLE_DEFAULT)
|
||||||
settings.setValue(TRACK_STYLE_SETTING, (int)_options.trackStyle);
|
settings.setValue(TRACK_STYLE_SETTING, (int)_options.trackStyle);
|
||||||
if (_options.routeStyle != ROUTE_STYLE_DEFAULT)
|
if (_options.routeStyle != ROUTE_STYLE_DEFAULT)
|
||||||
settings.setValue(ROUTE_STYLE_SETTING, (int)_options.routeStyle);
|
settings.setValue(ROUTE_STYLE_SETTING, (int)_options.routeStyle);
|
||||||
|
if (_options.areaStyle != AREA_STYLE_DEFAULT)
|
||||||
|
settings.setValue(AREA_STYLE_SETTING, (int)_options.areaStyle);
|
||||||
|
if (_options.areaOpacity != AREA_OPACITY_DEFAULT)
|
||||||
|
settings.setValue(AREA_OPACITY_SETTING, (int)_options.areaOpacity);
|
||||||
if (_options.waypointSize != WAYPOINT_SIZE_DEFAULT)
|
if (_options.waypointSize != WAYPOINT_SIZE_DEFAULT)
|
||||||
settings.setValue(WAYPOINT_SIZE_SETTING, _options.waypointSize);
|
settings.setValue(WAYPOINT_SIZE_SETTING, _options.waypointSize);
|
||||||
if (_options.waypointColor != WAYPOINT_COLOR_DEFAULT)
|
if (_options.waypointColor != WAYPOINT_COLOR_DEFAULT)
|
||||||
@ -1931,6 +1959,10 @@ void GUI::readSettings()
|
|||||||
_mapView->showWaypoints(false);
|
_mapView->showWaypoints(false);
|
||||||
else
|
else
|
||||||
_showWaypointsAction->setChecked(true);
|
_showWaypointsAction->setChecked(true);
|
||||||
|
if (!settings.value(SHOW_AREAS_SETTING, SHOW_AREAS_DEFAULT).toBool())
|
||||||
|
_mapView->showAreas(false);
|
||||||
|
else
|
||||||
|
_showAreasAction->setChecked(true);
|
||||||
if (!settings.value(SHOW_WAYPOINT_LABELS_SETTING,
|
if (!settings.value(SHOW_WAYPOINT_LABELS_SETTING,
|
||||||
SHOW_WAYPOINT_LABELS_DEFAULT).toBool())
|
SHOW_WAYPOINT_LABELS_DEFAULT).toBool())
|
||||||
_mapView->showWaypointLabels(false);
|
_mapView->showWaypointLabels(false);
|
||||||
@ -1976,10 +2008,16 @@ void GUI::readSettings()
|
|||||||
TRACK_WIDTH_DEFAULT).toInt();
|
TRACK_WIDTH_DEFAULT).toInt();
|
||||||
_options.routeWidth = settings.value(ROUTE_WIDTH_SETTING,
|
_options.routeWidth = settings.value(ROUTE_WIDTH_SETTING,
|
||||||
ROUTE_WIDTH_DEFAULT).toInt();
|
ROUTE_WIDTH_DEFAULT).toInt();
|
||||||
|
_options.areaWidth = settings.value(AREA_WIDTH_SETTING,
|
||||||
|
AREA_WIDTH_DEFAULT).toInt();
|
||||||
_options.trackStyle = (Qt::PenStyle) settings.value(TRACK_STYLE_SETTING,
|
_options.trackStyle = (Qt::PenStyle) settings.value(TRACK_STYLE_SETTING,
|
||||||
(int)TRACK_STYLE_DEFAULT).toInt();
|
(int)TRACK_STYLE_DEFAULT).toInt();
|
||||||
_options.routeStyle = (Qt::PenStyle) settings.value(ROUTE_STYLE_SETTING,
|
_options.routeStyle = (Qt::PenStyle) settings.value(ROUTE_STYLE_SETTING,
|
||||||
(int)ROUTE_STYLE_DEFAULT).toInt();
|
(int)ROUTE_STYLE_DEFAULT).toInt();
|
||||||
|
_options.areaStyle = (Qt::PenStyle) settings.value(AREA_STYLE_SETTING,
|
||||||
|
(int)AREA_STYLE_DEFAULT).toInt();
|
||||||
|
_options.areaOpacity = settings.value(AREA_OPACITY_SETTING,
|
||||||
|
AREA_OPACITY_DEFAULT).toInt();
|
||||||
_options.pathAntiAliasing = settings.value(PATH_AA_SETTING, PATH_AA_DEFAULT)
|
_options.pathAntiAliasing = settings.value(PATH_AA_SETTING, PATH_AA_DEFAULT)
|
||||||
.toBool();
|
.toBool();
|
||||||
_options.waypointSize = settings.value(WAYPOINT_SIZE_SETTING,
|
_options.waypointSize = settings.value(WAYPOINT_SIZE_SETTING,
|
||||||
@ -2058,8 +2096,11 @@ void GUI::readSettings()
|
|||||||
_mapView->setBackgroundColor(_options.backgroundColor);
|
_mapView->setBackgroundColor(_options.backgroundColor);
|
||||||
_mapView->setTrackWidth(_options.trackWidth);
|
_mapView->setTrackWidth(_options.trackWidth);
|
||||||
_mapView->setRouteWidth(_options.routeWidth);
|
_mapView->setRouteWidth(_options.routeWidth);
|
||||||
|
_mapView->setAreaWidth(_options.areaWidth);
|
||||||
_mapView->setTrackStyle(_options.trackStyle);
|
_mapView->setTrackStyle(_options.trackStyle);
|
||||||
_mapView->setRouteStyle(_options.routeStyle);
|
_mapView->setRouteStyle(_options.routeStyle);
|
||||||
|
_mapView->setAreaStyle(_options.areaStyle);
|
||||||
|
_mapView->setAreaOpacity(_options.areaOpacity);
|
||||||
_mapView->setWaypointSize(_options.waypointSize);
|
_mapView->setWaypointSize(_options.waypointSize);
|
||||||
_mapView->setWaypointColor(_options.waypointColor);
|
_mapView->setWaypointColor(_options.waypointColor);
|
||||||
_mapView->setPOISize(_options.poiSize);
|
_mapView->setPOISize(_options.poiSize);
|
||||||
|
@ -190,6 +190,7 @@ private:
|
|||||||
QAction *_showRoutesAction;
|
QAction *_showRoutesAction;
|
||||||
QAction *_showWaypointsAction;
|
QAction *_showWaypointsAction;
|
||||||
QAction *_showWaypointLabelsAction;
|
QAction *_showWaypointLabelsAction;
|
||||||
|
QAction *_showAreasAction;
|
||||||
QAction *_showRouteWaypointsAction;
|
QAction *_showRouteWaypointsAction;
|
||||||
QAction *_openOptionsAction;
|
QAction *_openOptionsAction;
|
||||||
QAction *_mapsEnd;
|
QAction *_mapsEnd;
|
||||||
@ -215,13 +216,9 @@ private:
|
|||||||
FileBrowser *_browser;
|
FileBrowser *_browser;
|
||||||
QList<QString> _files;
|
QList<QString> _files;
|
||||||
|
|
||||||
int _trackCount;
|
int _trackCount, _routeCount, _areaCount, _waypointCount;
|
||||||
int _routeCount;
|
qreal _trackDistance, _routeDistance;
|
||||||
int _waypointCount;
|
qreal _time, _movingTime;
|
||||||
qreal _trackDistance;
|
|
||||||
qreal _routeDistance;
|
|
||||||
qreal _time;
|
|
||||||
qreal _movingTime;
|
|
||||||
DateRange _dateRange;
|
DateRange _dateRange;
|
||||||
QString _pathName;
|
QString _pathName;
|
||||||
|
|
||||||
|
@ -32,15 +32,16 @@ QList<GraphItem*> HeartRateGraph::loadData(const Data &data)
|
|||||||
QList<GraphItem*> graphs;
|
QList<GraphItem*> graphs;
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
const Graph &graph = data.tracks().at(i)->heartRate();
|
const Track &track = data.tracks().at(i);
|
||||||
|
const Graph &graph = track.heartRate();
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (!graph.isValid()) {
|
||||||
skipColor();
|
skipColor();
|
||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
} else {
|
} else {
|
||||||
HeartRateGraphItem *gi = new HeartRateGraphItem(graph, _graphType);
|
HeartRateGraphItem *gi = new HeartRateGraphItem(graph, _graphType);
|
||||||
GraphView::addGraph(gi);
|
GraphView::addGraph(gi);
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
_avg.append(QPointF(track.distance(), gi->avg()));
|
||||||
graphs.append(gi);
|
graphs.append(gi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,6 +51,9 @@ QList<GraphItem*> HeartRateGraph::loadData(const Data &data)
|
|||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < data.areas().count(); i++)
|
||||||
|
skipColor();
|
||||||
|
|
||||||
setInfo();
|
setInfo();
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "trackitem.h"
|
#include "trackitem.h"
|
||||||
#include "routeitem.h"
|
#include "routeitem.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
|
#include "areaitem.h"
|
||||||
#include "scaleitem.h"
|
#include "scaleitem.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "mapview.h"
|
#include "mapview.h"
|
||||||
@ -50,13 +51,14 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
|
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
_coordinatesFormat = DecimalDegrees;
|
_coordinatesFormat = DecimalDegrees;
|
||||||
_opacity = 1.0;
|
_mapOpacity = 1.0;
|
||||||
_backgroundColor = Qt::white;
|
_backgroundColor = Qt::white;
|
||||||
_markerColor = Qt::red;
|
_markerColor = Qt::red;
|
||||||
|
|
||||||
_showMap = true;
|
_showMap = true;
|
||||||
_showTracks = true;
|
_showTracks = true;
|
||||||
_showRoutes = true;
|
_showRoutes = true;
|
||||||
|
_showAreas = true;
|
||||||
_showWaypoints = true;
|
_showWaypoints = true;
|
||||||
_showWaypointLabels = true;
|
_showWaypointLabels = true;
|
||||||
_showPOI = true;
|
_showPOI = true;
|
||||||
@ -96,8 +98,8 @@ void MapView::centerOn(const QPointF &pos)
|
|||||||
|
|
||||||
PathItem *MapView::addTrack(const Track &track)
|
PathItem *MapView::addTrack(const Track &track)
|
||||||
{
|
{
|
||||||
if (track.isNull()) {
|
if (!track.isValid()) {
|
||||||
_palette.nextColor();
|
skipColor();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,8 +123,8 @@ PathItem *MapView::addTrack(const Track &track)
|
|||||||
|
|
||||||
PathItem *MapView::addRoute(const Route &route)
|
PathItem *MapView::addRoute(const Route &route)
|
||||||
{
|
{
|
||||||
if (route.isNull()) {
|
if (!route.isValid()) {
|
||||||
_palette.nextColor();
|
skipColor();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,6 +149,28 @@ PathItem *MapView::addRoute(const Route &route)
|
|||||||
return ri;
|
return ri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::addArea(const Area &area)
|
||||||
|
{
|
||||||
|
if (!area.isValid()) {
|
||||||
|
skipColor();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AreaItem *ai = new AreaItem(area, _map);
|
||||||
|
_areas.append(ai);
|
||||||
|
_ar |= ai->area().boundingRect();
|
||||||
|
ai->setColor(_palette.nextColor());
|
||||||
|
ai->setWidth(_areaWidth);
|
||||||
|
ai->setStyle(_areaStyle);
|
||||||
|
ai->setOpacity(_areaOpacity);
|
||||||
|
ai->setDigitalZoom(_digitalZoom);
|
||||||
|
ai->setVisible(_showAreas);
|
||||||
|
_scene->addItem(ai);
|
||||||
|
|
||||||
|
if (_showAreas)
|
||||||
|
addPOI(_poi->points(ai->area()));
|
||||||
|
}
|
||||||
|
|
||||||
void MapView::addWaypoints(const QVector<Waypoint> &waypoints)
|
void MapView::addWaypoints(const QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < waypoints.count(); i++) {
|
for (int i = 0; i < waypoints.count(); i++) {
|
||||||
@ -175,12 +199,15 @@ QList<PathItem *> MapView::loadData(const Data &data)
|
|||||||
int zoom = _map->zoom();
|
int zoom = _map->zoom();
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++)
|
for (int i = 0; i < data.tracks().count(); i++)
|
||||||
paths.append(addTrack(*(data.tracks().at(i))));
|
paths.append(addTrack(data.tracks().at(i)));
|
||||||
for (int i = 0; i < data.routes().count(); i++)
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
paths.append(addRoute(*(data.routes().at(i))));
|
paths.append(addRoute(data.routes().at(i)));
|
||||||
|
for (int i = 0; i < data.areas().count(); i++)
|
||||||
|
addArea(data.areas().at(i));
|
||||||
addWaypoints(data.waypoints());
|
addWaypoints(data.waypoints());
|
||||||
|
|
||||||
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
if (_tracks.empty() && _routes.empty() && _waypoints.empty()
|
||||||
|
&& _areas.empty())
|
||||||
return paths;
|
return paths;
|
||||||
|
|
||||||
if (fitMapZoom() != zoom)
|
if (fitMapZoom() != zoom)
|
||||||
@ -195,7 +222,7 @@ QList<PathItem *> MapView::loadData(const Data &data)
|
|||||||
|
|
||||||
int MapView::fitMapZoom() const
|
int MapView::fitMapZoom() const
|
||||||
{
|
{
|
||||||
RectC br = _tr | _rr | _wr;
|
RectC br = _tr | _rr | _wr | _ar;
|
||||||
|
|
||||||
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN),
|
return _map->zoomFit(viewport()->size() - QSize(2*MARGIN, 2*MARGIN),
|
||||||
br.isNull() ? RectC(_map->xy2ll(_map->bounds().topLeft()),
|
br.isNull() ? RectC(_map->xy2ll(_map->bounds().topLeft()),
|
||||||
@ -204,7 +231,7 @@ int MapView::fitMapZoom() const
|
|||||||
|
|
||||||
QPointF MapView::contentCenter() const
|
QPointF MapView::contentCenter() const
|
||||||
{
|
{
|
||||||
RectC br = _tr | _rr | _wr;
|
RectC br = _tr | _rr | _wr | _ar;
|
||||||
|
|
||||||
return br.isNull() ? sceneRect().center() : _map->ll2xy(br.center());
|
return br.isNull() ? sceneRect().center() : _map->ll2xy(br.center());
|
||||||
}
|
}
|
||||||
@ -239,6 +266,8 @@ void MapView::rescale()
|
|||||||
_tracks.at(i)->setMap(_map);
|
_tracks.at(i)->setMap(_map);
|
||||||
for (int i = 0; i < _routes.size(); i++)
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
_routes.at(i)->setMap(_map);
|
_routes.at(i)->setMap(_map);
|
||||||
|
for (int i = 0; i < _areas.size(); i++)
|
||||||
|
_areas.at(i)->setMap(_map);
|
||||||
for (int i = 0; i < _waypoints.size(); i++)
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
_waypoints.at(i)->setMap(_map);
|
_waypoints.at(i)->setMap(_map);
|
||||||
|
|
||||||
@ -258,6 +287,8 @@ void MapView::setPalette(const Palette &palette)
|
|||||||
_tracks.at(i)->setColor(_palette.nextColor());
|
_tracks.at(i)->setColor(_palette.nextColor());
|
||||||
for (int i = 0; i < _routes.count(); i++)
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
_routes.at(i)->setColor(_palette.nextColor());
|
_routes.at(i)->setColor(_palette.nextColor());
|
||||||
|
for (int i = 0; i < _areas.count(); i++)
|
||||||
|
_areas.at(i)->setColor(_palette.nextColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::setMap(Map *map)
|
void MapView::setMap(Map *map)
|
||||||
@ -285,6 +316,8 @@ void MapView::setMap(Map *map)
|
|||||||
_tracks.at(i)->setMap(map);
|
_tracks.at(i)->setMap(map);
|
||||||
for (int i = 0; i < _routes.size(); i++)
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
_routes.at(i)->setMap(map);
|
_routes.at(i)->setMap(map);
|
||||||
|
for (int i = 0; i < _areas.size(); i++)
|
||||||
|
_areas.at(i)->setMap(map);
|
||||||
for (int i = 0; i < _waypoints.size(); i++)
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
_waypoints.at(i)->setMap(map);
|
_waypoints.at(i)->setMap(map);
|
||||||
|
|
||||||
@ -327,6 +360,9 @@ void MapView::updatePOI()
|
|||||||
if (_showRoutes)
|
if (_showRoutes)
|
||||||
for (int i = 0; i < _routes.size(); i++)
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
addPOI(_poi->points(_routes.at(i)->path()));
|
addPOI(_poi->points(_routes.at(i)->path()));
|
||||||
|
if (_showAreas)
|
||||||
|
for (int i = 0; i < _areas.size(); i++)
|
||||||
|
addPOI(_poi->points(_areas.at(i)->area()));
|
||||||
if (_showWaypoints)
|
if (_showWaypoints)
|
||||||
for (int i = 0; i< _waypoints.size(); i++)
|
for (int i = 0; i< _waypoints.size(); i++)
|
||||||
addPOI(_poi->points(_waypoints.at(i)->waypoint()));
|
addPOI(_poi->points(_waypoints.at(i)->waypoint()));
|
||||||
@ -419,6 +455,8 @@ void MapView::digitalZoom(int zoom)
|
|||||||
_tracks.at(i)->setDigitalZoom(_digitalZoom);
|
_tracks.at(i)->setDigitalZoom(_digitalZoom);
|
||||||
for (int i = 0; i < _routes.size(); i++)
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
_routes.at(i)->setDigitalZoom(_digitalZoom);
|
_routes.at(i)->setDigitalZoom(_digitalZoom);
|
||||||
|
for (int i = 0; i < _areas.size(); i++)
|
||||||
|
_areas.at(i)->setDigitalZoom(_digitalZoom);
|
||||||
for (int i = 0; i < _waypoints.size(); i++)
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
_waypoints.at(i)->setDigitalZoom(_digitalZoom);
|
_waypoints.at(i)->setDigitalZoom(_digitalZoom);
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
@ -536,7 +574,7 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
|
|||||||
painter->device()->logicalDpiY()
|
painter->device()->logicalDpiY()
|
||||||
/ (qreal)metric(QPaintDevice::PdmDpiY));
|
/ (qreal)metric(QPaintDevice::PdmDpiY));
|
||||||
adj = QRect(0, 0, adj.width() * s.x(), adj.height() * s.y());
|
adj = QRect(0, 0, adj.width() * s.x(), adj.height() * s.y());
|
||||||
_map->zoomFit(adj.size(), _tr | _rr | _wr);
|
_map->zoomFit(adj.size(), _tr | _rr | _wr | _ar);
|
||||||
rescale();
|
rescale();
|
||||||
|
|
||||||
QPointF center = contentCenter();
|
QPointF center = contentCenter();
|
||||||
@ -579,6 +617,7 @@ void MapView::clear()
|
|||||||
_pois.clear();
|
_pois.clear();
|
||||||
_tracks.clear();
|
_tracks.clear();
|
||||||
_routes.clear();
|
_routes.clear();
|
||||||
|
_areas.clear();
|
||||||
_waypoints.clear();
|
_waypoints.clear();
|
||||||
|
|
||||||
_scene->removeItem(_mapScale);
|
_scene->removeItem(_mapScale);
|
||||||
@ -590,6 +629,7 @@ void MapView::clear()
|
|||||||
_tr = RectC();
|
_tr = RectC();
|
||||||
_rr = RectC();
|
_rr = RectC();
|
||||||
_wr = RectC();
|
_wr = RectC();
|
||||||
|
_ar = RectC();
|
||||||
|
|
||||||
digitalZoom(0);
|
digitalZoom(0);
|
||||||
|
|
||||||
@ -627,6 +667,16 @@ void MapView::showWaypoints(bool show)
|
|||||||
updatePOI();
|
updatePOI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::showAreas(bool show)
|
||||||
|
{
|
||||||
|
_showAreas = show;
|
||||||
|
|
||||||
|
for (int i = 0; i < _areas.count(); i++)
|
||||||
|
_areas.at(i)->setVisible(show);
|
||||||
|
|
||||||
|
updatePOI();
|
||||||
|
}
|
||||||
|
|
||||||
void MapView::showWaypointLabels(bool show)
|
void MapView::showWaypointLabels(bool show)
|
||||||
{
|
{
|
||||||
_showWaypointLabels = show;
|
_showWaypointLabels = show;
|
||||||
@ -697,6 +747,14 @@ void MapView::setRouteWidth(int width)
|
|||||||
_routes.at(i)->setWidth(width);
|
_routes.at(i)->setWidth(width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::setAreaWidth(int width)
|
||||||
|
{
|
||||||
|
_areaWidth = width;
|
||||||
|
|
||||||
|
for (int i = 0; i < _areas.count(); i++)
|
||||||
|
_areas.at(i)->setWidth(width);
|
||||||
|
}
|
||||||
|
|
||||||
void MapView::setTrackStyle(Qt::PenStyle style)
|
void MapView::setTrackStyle(Qt::PenStyle style)
|
||||||
{
|
{
|
||||||
_trackStyle = style;
|
_trackStyle = style;
|
||||||
@ -713,6 +771,22 @@ void MapView::setRouteStyle(Qt::PenStyle style)
|
|||||||
_routes.at(i)->setStyle(style);
|
_routes.at(i)->setStyle(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::setAreaStyle(Qt::PenStyle style)
|
||||||
|
{
|
||||||
|
_areaStyle = style;
|
||||||
|
|
||||||
|
for (int i = 0; i < _areas.count(); i++)
|
||||||
|
_areas.at(i)->setStyle(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapView::setAreaOpacity(int opacity)
|
||||||
|
{
|
||||||
|
_areaOpacity = opacity / 100.0;
|
||||||
|
|
||||||
|
for (int i = 0; i < _areas.count(); i++)
|
||||||
|
_areas.at(i)->setOpacity(_areaOpacity);
|
||||||
|
}
|
||||||
|
|
||||||
void MapView::setWaypointSize(int size)
|
void MapView::setWaypointSize(int size)
|
||||||
{
|
{
|
||||||
_waypointSize = size;
|
_waypointSize = size;
|
||||||
@ -751,7 +825,7 @@ void MapView::setPOIColor(const QColor &color)
|
|||||||
|
|
||||||
void MapView::setMapOpacity(int opacity)
|
void MapView::setMapOpacity(int opacity)
|
||||||
{
|
{
|
||||||
_opacity = opacity / 100.0;
|
_mapOpacity = opacity / 100.0;
|
||||||
reloadMap();
|
reloadMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,8 +843,8 @@ void MapView::drawBackground(QPainter *painter, const QRectF &rect)
|
|||||||
QRectF ir = rect.intersected(_map->bounds());
|
QRectF ir = rect.intersected(_map->bounds());
|
||||||
Map::Flags flags = Map::NoFlags;
|
Map::Flags flags = Map::NoFlags;
|
||||||
|
|
||||||
if (_opacity < 1.0)
|
if (_mapOpacity < 1.0)
|
||||||
painter->setOpacity(_opacity);
|
painter->setOpacity(_mapOpacity);
|
||||||
|
|
||||||
if (_plot)
|
if (_plot)
|
||||||
flags = Map::Block;
|
flags = Map::Block;
|
||||||
@ -867,6 +941,8 @@ void MapView::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
|||||||
_tracks.at(i)->setMap(_map);
|
_tracks.at(i)->setMap(_map);
|
||||||
for (int i = 0; i < _routes.size(); i++)
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
_routes.at(i)->setMap(_map);
|
_routes.at(i)->setMap(_map);
|
||||||
|
for (int i = 0; i < _areas.size(); i++)
|
||||||
|
_areas.at(i)->setMap(_map);
|
||||||
for (int i = 0; i < _waypoints.size(); i++)
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
_waypoints.at(i)->setMap(_map);
|
_waypoints.at(i)->setMap(_map);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
|
#include "data/polygon.h"
|
||||||
|
|
||||||
class Data;
|
class Data;
|
||||||
class POI;
|
class POI;
|
||||||
@ -24,6 +25,8 @@ class WaypointItem;
|
|||||||
class ScaleItem;
|
class ScaleItem;
|
||||||
class PathItem;
|
class PathItem;
|
||||||
class GraphItem;
|
class GraphItem;
|
||||||
|
class AreaItem;
|
||||||
|
class Area;
|
||||||
|
|
||||||
class MapView : public QGraphicsView
|
class MapView : public QGraphicsView
|
||||||
{
|
{
|
||||||
@ -46,8 +49,11 @@ public:
|
|||||||
void setMarkerColor(const QColor &color);
|
void setMarkerColor(const QColor &color);
|
||||||
void setTrackWidth(int width);
|
void setTrackWidth(int width);
|
||||||
void setRouteWidth(int width);
|
void setRouteWidth(int width);
|
||||||
|
void setAreaWidth(int width);
|
||||||
void setTrackStyle(Qt::PenStyle style);
|
void setTrackStyle(Qt::PenStyle style);
|
||||||
void setRouteStyle(Qt::PenStyle style);
|
void setRouteStyle(Qt::PenStyle style);
|
||||||
|
void setAreaStyle(Qt::PenStyle style);
|
||||||
|
void setAreaOpacity(int opacity);
|
||||||
void setWaypointSize(int size);
|
void setWaypointSize(int size);
|
||||||
void setWaypointColor(const QColor &color);
|
void setWaypointColor(const QColor &color);
|
||||||
void setPOISize(int size);
|
void setPOISize(int size);
|
||||||
@ -65,6 +71,7 @@ public slots:
|
|||||||
void showPOILabels(bool show);
|
void showPOILabels(bool show);
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show);
|
void showRoutes(bool show);
|
||||||
|
void showAreas(bool show);
|
||||||
void showWaypoints(bool show);
|
void showWaypoints(bool show);
|
||||||
void showRouteWaypoints(bool show);
|
void showRouteWaypoints(bool show);
|
||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
@ -78,6 +85,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
PathItem *addTrack(const Track &track);
|
PathItem *addTrack(const Track &track);
|
||||||
PathItem *addRoute(const Route &route);
|
PathItem *addRoute(const Route &route);
|
||||||
|
void addArea(const Area &area);
|
||||||
void addWaypoints(const QVector<Waypoint> &waypoints);
|
void addWaypoints(const QVector<Waypoint> &waypoints);
|
||||||
void addPOI(const QList<Waypoint> &waypoints);
|
void addPOI(const QList<Waypoint> &waypoints);
|
||||||
void loadPOI();
|
void loadPOI();
|
||||||
@ -90,6 +98,7 @@ private:
|
|||||||
void zoom(int zoom, const QPoint &pos);
|
void zoom(int zoom, const QPoint &pos);
|
||||||
void digitalZoom(int zoom);
|
void digitalZoom(int zoom);
|
||||||
void updatePOIVisibility();
|
void updatePOIVisibility();
|
||||||
|
void skipColor() {_palette.nextColor();}
|
||||||
|
|
||||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||||
void wheelEvent(QWheelEvent *event);
|
void wheelEvent(QWheelEvent *event);
|
||||||
@ -104,37 +113,28 @@ private:
|
|||||||
QList<TrackItem*> _tracks;
|
QList<TrackItem*> _tracks;
|
||||||
QList<RouteItem*> _routes;
|
QList<RouteItem*> _routes;
|
||||||
QList<WaypointItem*> _waypoints;
|
QList<WaypointItem*> _waypoints;
|
||||||
|
QList<AreaItem*> _areas;
|
||||||
QHash<SearchPointer<Waypoint>, WaypointItem*> _pois;
|
QHash<SearchPointer<Waypoint>, WaypointItem*> _pois;
|
||||||
|
|
||||||
RectC _tr, _rr, _wr;
|
RectC _tr, _rr, _wr, _ar;
|
||||||
qreal _res;
|
qreal _res;
|
||||||
|
|
||||||
Map *_map;
|
Map *_map;
|
||||||
POI *_poi;
|
POI *_poi;
|
||||||
|
|
||||||
Palette _palette;
|
Palette _palette;
|
||||||
Units _units;
|
Units _units;
|
||||||
CoordinatesFormat _coordinatesFormat;
|
CoordinatesFormat _coordinatesFormat;
|
||||||
|
qreal _mapOpacity;
|
||||||
|
|
||||||
qreal _opacity;
|
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
||||||
QColor _backgroundColor;
|
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints;
|
||||||
bool _showMap;
|
|
||||||
bool _showTracks;
|
|
||||||
bool _showRoutes;
|
|
||||||
bool _showWaypoints;
|
|
||||||
bool _showWaypointLabels;
|
|
||||||
bool _showPOI;
|
|
||||||
bool _showPOILabels;
|
|
||||||
bool _overlapPOIs;
|
bool _overlapPOIs;
|
||||||
bool _showRouteWaypoints;
|
int _trackWidth, _routeWidth, _areaWidth;
|
||||||
int _trackWidth;
|
Qt::PenStyle _trackStyle, _routeStyle, _areaStyle;
|
||||||
int _routeWidth;
|
int _waypointSize, _poiSize;
|
||||||
Qt::PenStyle _trackStyle;
|
QColor _backgroundColor, _waypointColor, _poiColor, _markerColor;
|
||||||
Qt::PenStyle _routeStyle;
|
qreal _areaOpacity;
|
||||||
int _waypointSize;
|
|
||||||
int _poiSize;
|
|
||||||
QColor _waypointColor;
|
|
||||||
QColor _poiColor;
|
|
||||||
QColor _markerColor;
|
|
||||||
|
|
||||||
int _digitalZoom;
|
int _digitalZoom;
|
||||||
bool _plot;
|
bool _plot;
|
||||||
|
@ -93,22 +93,7 @@ QWidget *OptionsDialog::createMapPage()
|
|||||||
|
|
||||||
QWidget *OptionsDialog::createAppearancePage()
|
QWidget *OptionsDialog::createAppearancePage()
|
||||||
{
|
{
|
||||||
// Paths
|
// Tracks
|
||||||
_baseColor = new ColorBox();
|
|
||||||
_baseColor->setColor(_options->palette.color());
|
|
||||||
_colorOffset = new QDoubleSpinBox();
|
|
||||||
_colorOffset->setMinimum(0);
|
|
||||||
_colorOffset->setMaximum(1.0);
|
|
||||||
_colorOffset->setSingleStep(0.01);
|
|
||||||
_colorOffset->setValue(_options->palette.shift());
|
|
||||||
QFormLayout *paletteLayout = new QFormLayout();
|
|
||||||
paletteLayout->addRow(tr("Base color:"), _baseColor);
|
|
||||||
paletteLayout->addRow(tr("Palette shift:"), _colorOffset);
|
|
||||||
#ifndef Q_OS_MAC
|
|
||||||
QGroupBox *colorBox = new QGroupBox(tr("Colors"));
|
|
||||||
colorBox->setLayout(paletteLayout);
|
|
||||||
#endif // Q_OS_MAC
|
|
||||||
|
|
||||||
_trackWidth = new QSpinBox();
|
_trackWidth = new QSpinBox();
|
||||||
_trackWidth->setValue(_options->trackWidth);
|
_trackWidth->setValue(_options->trackWidth);
|
||||||
_trackWidth->setMinimum(1);
|
_trackWidth->setMinimum(1);
|
||||||
@ -125,6 +110,7 @@ QWidget *OptionsDialog::createAppearancePage()
|
|||||||
trackBox->setLayout(trackLayout);
|
trackBox->setLayout(trackLayout);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
|
// Routes
|
||||||
_routeWidth = new QSpinBox();
|
_routeWidth = new QSpinBox();
|
||||||
_routeWidth->setValue(_options->routeWidth);
|
_routeWidth->setValue(_options->routeWidth);
|
||||||
_routeWidth->setMinimum(1);
|
_routeWidth->setMinimum(1);
|
||||||
@ -141,6 +127,17 @@ QWidget *OptionsDialog::createAppearancePage()
|
|||||||
routeBox->setLayout(routeLayout);
|
routeBox->setLayout(routeLayout);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
|
_baseColor = new ColorBox();
|
||||||
|
_baseColor->setColor(_options->palette.color());
|
||||||
|
_colorOffset = new QDoubleSpinBox();
|
||||||
|
_colorOffset->setMinimum(0);
|
||||||
|
_colorOffset->setMaximum(1.0);
|
||||||
|
_colorOffset->setSingleStep(0.01);
|
||||||
|
_colorOffset->setValue(_options->palette.shift());
|
||||||
|
QFormLayout *paletteLayout = new QFormLayout();
|
||||||
|
paletteLayout->addRow(tr("Base color:"), _baseColor);
|
||||||
|
paletteLayout->addRow(tr("Palette shift:"), _colorOffset);
|
||||||
|
|
||||||
_pathAA = new QCheckBox(tr("Use anti-aliasing"));
|
_pathAA = new QCheckBox(tr("Use anti-aliasing"));
|
||||||
_pathAA->setChecked(_options->pathAntiAliasing);
|
_pathAA->setChecked(_options->pathAntiAliasing);
|
||||||
QFormLayout *pathAALayout = new QFormLayout();
|
QFormLayout *pathAALayout = new QFormLayout();
|
||||||
@ -149,22 +146,40 @@ QWidget *OptionsDialog::createAppearancePage()
|
|||||||
QWidget *pathTab = new QWidget();
|
QWidget *pathTab = new QWidget();
|
||||||
QVBoxLayout *pathTabLayout = new QVBoxLayout();
|
QVBoxLayout *pathTabLayout = new QVBoxLayout();
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
pathTabLayout->addLayout(paletteLayout);
|
|
||||||
pathTabLayout->addWidget(line());
|
|
||||||
pathTabLayout->addLayout(trackLayout);
|
pathTabLayout->addLayout(trackLayout);
|
||||||
pathTabLayout->addWidget(line());
|
pathTabLayout->addWidget(line());
|
||||||
pathTabLayout->addLayout(routeLayout);
|
pathTabLayout->addLayout(routeLayout);
|
||||||
pathTabLayout->addWidget(line());
|
pathTabLayout->addWidget(line());
|
||||||
#else // Q_OS_MAC
|
#else // Q_OS_MAC
|
||||||
pathTabLayout->addWidget(colorBox);
|
|
||||||
pathTabLayout->addWidget(trackBox);
|
pathTabLayout->addWidget(trackBox);
|
||||||
pathTabLayout->addWidget(routeBox);
|
pathTabLayout->addWidget(routeBox);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
pathTabLayout->addLayout(paletteLayout);
|
||||||
pathTabLayout->addLayout(pathAALayout);
|
pathTabLayout->addLayout(pathAALayout);
|
||||||
pathTabLayout->addStretch();
|
pathTabLayout->addStretch();
|
||||||
pathTab->setLayout(pathTabLayout);
|
pathTab->setLayout(pathTabLayout);
|
||||||
|
|
||||||
|
|
||||||
|
// Areas
|
||||||
|
_areaWidth = new QSpinBox();
|
||||||
|
_areaWidth->setValue(_options->areaWidth);
|
||||||
|
_areaWidth->setMinimum(1);
|
||||||
|
_areaStyle = new StyleComboBox();
|
||||||
|
_areaStyle->setValue(_options->areaStyle);
|
||||||
|
_areaOpacity = new PercentSlider();
|
||||||
|
_areaOpacity->setValue(_options->areaOpacity);
|
||||||
|
QFormLayout *areaLayout = new QFormLayout();
|
||||||
|
areaLayout->addRow(tr("Border width:"), _areaWidth);
|
||||||
|
areaLayout->addRow(tr("Border style:"), _areaStyle);
|
||||||
|
areaLayout->addRow(tr("Fill opacity:"), _areaOpacity);
|
||||||
|
|
||||||
|
QWidget *areaTab = new QWidget();
|
||||||
|
QVBoxLayout *areaTabLayout = new QVBoxLayout();
|
||||||
|
areaTabLayout->addLayout(areaLayout);
|
||||||
|
areaTabLayout->addStretch();
|
||||||
|
areaTab->setLayout(areaTabLayout);
|
||||||
|
|
||||||
|
|
||||||
// Waypoints
|
// Waypoints
|
||||||
_waypointSize = new QSpinBox();
|
_waypointSize = new QSpinBox();
|
||||||
_waypointSize->setMinimum(1);
|
_waypointSize->setMinimum(1);
|
||||||
@ -255,6 +270,7 @@ QWidget *OptionsDialog::createAppearancePage()
|
|||||||
|
|
||||||
QTabWidget *appearancePage = new QTabWidget();
|
QTabWidget *appearancePage = new QTabWidget();
|
||||||
appearancePage->addTab(pathTab, tr("Paths"));
|
appearancePage->addTab(pathTab, tr("Paths"));
|
||||||
|
appearancePage->addTab(areaTab, tr("Areas"));
|
||||||
appearancePage->addTab(pointTab, tr("Points"));
|
appearancePage->addTab(pointTab, tr("Points"));
|
||||||
appearancePage->addTab(graphTab, tr("Graphs"));
|
appearancePage->addTab(graphTab, tr("Graphs"));
|
||||||
appearancePage->addTab(mapTab, tr("Map"));
|
appearancePage->addTab(mapTab, tr("Map"));
|
||||||
@ -630,6 +646,10 @@ void OptionsDialog::accept()
|
|||||||
_options->routeStyle = (Qt::PenStyle) _routeStyle->itemData(
|
_options->routeStyle = (Qt::PenStyle) _routeStyle->itemData(
|
||||||
_routeStyle->currentIndex()).toInt();
|
_routeStyle->currentIndex()).toInt();
|
||||||
_options->pathAntiAliasing = _pathAA->isChecked();
|
_options->pathAntiAliasing = _pathAA->isChecked();
|
||||||
|
_options->areaWidth = _areaWidth->value();
|
||||||
|
_options->areaStyle = (Qt::PenStyle) _areaStyle->itemData(
|
||||||
|
_areaStyle->currentIndex()).toInt();
|
||||||
|
_options->areaOpacity = _areaOpacity->value();
|
||||||
_options->waypointSize = _waypointSize->value();
|
_options->waypointSize = _waypointSize->value();
|
||||||
_options->waypointColor = _waypointColor->color();
|
_options->waypointColor = _waypointColor->color();
|
||||||
_options->poiSize = _poiSize->value();
|
_options->poiSize = _poiSize->value();
|
||||||
|
@ -21,8 +21,11 @@ struct Options {
|
|||||||
Palette palette;
|
Palette palette;
|
||||||
int trackWidth;
|
int trackWidth;
|
||||||
int routeWidth;
|
int routeWidth;
|
||||||
|
int areaWidth;
|
||||||
Qt::PenStyle trackStyle;
|
Qt::PenStyle trackStyle;
|
||||||
Qt::PenStyle routeStyle;
|
Qt::PenStyle routeStyle;
|
||||||
|
Qt::PenStyle areaStyle;
|
||||||
|
int areaOpacity;
|
||||||
QColor waypointColor;
|
QColor waypointColor;
|
||||||
QColor poiColor;
|
QColor poiColor;
|
||||||
int waypointSize;
|
int waypointSize;
|
||||||
@ -101,6 +104,9 @@ private:
|
|||||||
StyleComboBox *_trackStyle;
|
StyleComboBox *_trackStyle;
|
||||||
QSpinBox *_routeWidth;
|
QSpinBox *_routeWidth;
|
||||||
StyleComboBox *_routeStyle;
|
StyleComboBox *_routeStyle;
|
||||||
|
QSpinBox *_areaWidth;
|
||||||
|
StyleComboBox *_areaStyle;
|
||||||
|
PercentSlider *_areaOpacity;
|
||||||
QCheckBox *_pathAA;
|
QCheckBox *_pathAA;
|
||||||
QSpinBox *_waypointSize;
|
QSpinBox *_waypointSize;
|
||||||
ColorBox *_waypointColor;
|
ColorBox *_waypointColor;
|
||||||
|
@ -14,11 +14,10 @@ static unsigned segments(qreal distance)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
||||||
: QGraphicsObject(parent)
|
: QGraphicsObject(parent), _path(path)
|
||||||
{
|
{
|
||||||
Q_ASSERT(path.count() >= 2);
|
Q_ASSERT(path.count() >= 2);
|
||||||
|
|
||||||
_path = path;
|
|
||||||
_map = map;
|
_map = map;
|
||||||
_digitalZoom = 0;
|
_digitalZoom = 0;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ PercentSlider::PercentSlider(QWidget *parent) : QWidget(parent)
|
|||||||
QFontMetrics fm(_label->font());
|
QFontMetrics fm(_label->font());
|
||||||
_label->setFixedWidth(fm.boundingRect(format(_slider->maximum())).width());
|
_label->setFixedWidth(fm.boundingRect(format(_slider->maximum())).width());
|
||||||
_label->setAlignment(Qt::AlignRight);
|
_label->setAlignment(Qt::AlignRight);
|
||||||
|
_label->setText(format(_slider->value()));
|
||||||
|
|
||||||
connect(_slider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabel(int)));
|
connect(_slider, SIGNAL(sliderMoved(int)), this, SLOT(updateLabel(int)));
|
||||||
|
|
||||||
|
@ -32,15 +32,16 @@ QList<GraphItem*> PowerGraph::loadData(const Data &data)
|
|||||||
QList<GraphItem*> graphs;
|
QList<GraphItem*> graphs;
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
const Graph &graph = data.tracks().at(i)->power();
|
const Track &track = data.tracks().at(i);
|
||||||
|
const Graph &graph = track.power();
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (!graph.isValid()) {
|
||||||
skipColor();
|
skipColor();
|
||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
} else {
|
} else {
|
||||||
PowerGraphItem *gi = new PowerGraphItem(graph, _graphType);
|
PowerGraphItem *gi = new PowerGraphItem(graph, _graphType);
|
||||||
GraphView::addGraph(gi);
|
GraphView::addGraph(gi);
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
_avg.append(QPointF(track.distance(), gi->avg()));
|
||||||
graphs.append(gi);
|
graphs.append(gi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,6 +51,9 @@ QList<GraphItem*> PowerGraph::loadData(const Data &data)
|
|||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < data.areas().count(); i++)
|
||||||
|
skipColor();
|
||||||
|
|
||||||
setInfo();
|
setInfo();
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
|
@ -52,6 +52,8 @@
|
|||||||
#define SHOW_ROUTES_DEFAULT true
|
#define SHOW_ROUTES_DEFAULT true
|
||||||
#define SHOW_WAYPOINTS_SETTING "waypoints"
|
#define SHOW_WAYPOINTS_SETTING "waypoints"
|
||||||
#define SHOW_WAYPOINTS_DEFAULT true
|
#define SHOW_WAYPOINTS_DEFAULT true
|
||||||
|
#define SHOW_AREAS_SETTING "areas"
|
||||||
|
#define SHOW_AREAS_DEFAULT true
|
||||||
#define SHOW_ROUTE_WAYPOINTS_SETTING "routeWaypoints"
|
#define SHOW_ROUTE_WAYPOINTS_SETTING "routeWaypoints"
|
||||||
#define SHOW_ROUTE_WAYPOINTS_DEFAULT true
|
#define SHOW_ROUTE_WAYPOINTS_DEFAULT true
|
||||||
#define SHOW_WAYPOINT_LABELS_SETTING "waypointLabels"
|
#define SHOW_WAYPOINT_LABELS_SETTING "waypointLabels"
|
||||||
@ -90,10 +92,16 @@
|
|||||||
#define TRACK_WIDTH_DEFAULT 3
|
#define TRACK_WIDTH_DEFAULT 3
|
||||||
#define ROUTE_WIDTH_SETTING "routeWidth"
|
#define ROUTE_WIDTH_SETTING "routeWidth"
|
||||||
#define ROUTE_WIDTH_DEFAULT 3
|
#define ROUTE_WIDTH_DEFAULT 3
|
||||||
|
#define AREA_WIDTH_SETTING "areaWidth"
|
||||||
|
#define AREA_WIDTH_DEFAULT 2
|
||||||
#define TRACK_STYLE_SETTING "trackStyle"
|
#define TRACK_STYLE_SETTING "trackStyle"
|
||||||
#define TRACK_STYLE_DEFAULT Qt::SolidLine
|
#define TRACK_STYLE_DEFAULT Qt::SolidLine
|
||||||
#define ROUTE_STYLE_SETTING "routeStyle"
|
#define ROUTE_STYLE_SETTING "routeStyle"
|
||||||
#define ROUTE_STYLE_DEFAULT Qt::DotLine
|
#define ROUTE_STYLE_DEFAULT Qt::DotLine
|
||||||
|
#define AREA_STYLE_SETTING "areaStyle"
|
||||||
|
#define AREA_STYLE_DEFAULT Qt::SolidLine
|
||||||
|
#define AREA_OPACITY_SETTING "areaOpacity"
|
||||||
|
#define AREA_OPACITY_DEFAULT 50
|
||||||
#define WAYPOINT_SIZE_SETTING "waypointSize"
|
#define WAYPOINT_SIZE_SETTING "waypointSize"
|
||||||
#define WAYPOINT_SIZE_DEFAULT 8
|
#define WAYPOINT_SIZE_DEFAULT 8
|
||||||
#define WAYPOINT_COLOR_SETTING "waypointColor"
|
#define WAYPOINT_COLOR_SETTING "waypointColor"
|
||||||
|
@ -40,19 +40,19 @@ QList<GraphItem*> SpeedGraph::loadData(const Data &data)
|
|||||||
QList<GraphItem*> graphs;
|
QList<GraphItem*> graphs;
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
const Track *track = data.tracks().at(i);
|
const Track &track = data.tracks().at(i);
|
||||||
const Graph &graph = track->speed();
|
const Graph &graph = track.speed();
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (!graph.isValid()) {
|
||||||
skipColor();
|
skipColor();
|
||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
} else {
|
} else {
|
||||||
SpeedGraphItem *gi = new SpeedGraphItem(graph, _graphType,
|
SpeedGraphItem *gi = new SpeedGraphItem(graph, _graphType,
|
||||||
track->movingTime());
|
track.movingTime());
|
||||||
gi->setTimeType(_timeType);
|
gi->setTimeType(_timeType);
|
||||||
GraphView::addGraph(gi);
|
GraphView::addGraph(gi);
|
||||||
_avg.append(QPointF(track->distance(), gi->avg()));
|
_avg.append(QPointF(track.distance(), gi->avg()));
|
||||||
_mavg.append(QPointF(track->distance(), gi->mavg()));
|
_mavg.append(QPointF(track.distance(), gi->mavg()));
|
||||||
graphs.append(gi);
|
graphs.append(gi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,6 +62,9 @@ QList<GraphItem*> SpeedGraph::loadData(const Data &data)
|
|||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < data.areas().count(); i++)
|
||||||
|
skipColor();
|
||||||
|
|
||||||
setInfo();
|
setInfo();
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
|
@ -34,16 +34,17 @@ QList<GraphItem*> TemperatureGraph::loadData(const Data &data)
|
|||||||
QList<GraphItem*> graphs;
|
QList<GraphItem*> graphs;
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
const Graph &graph = data.tracks().at(i)->temperature();
|
const Track &track = data.tracks().at(i);
|
||||||
|
const Graph &graph = track.temperature();
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (!graph.isValid()) {
|
||||||
skipColor();
|
skipColor();
|
||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
} else {
|
} else {
|
||||||
TemperatureGraphItem *gi = new TemperatureGraphItem(graph,
|
TemperatureGraphItem *gi = new TemperatureGraphItem(graph,
|
||||||
_graphType);
|
_graphType);
|
||||||
GraphView::addGraph(gi);
|
GraphView::addGraph(gi);
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
_avg.append(QPointF(track.distance(), gi->avg()));
|
||||||
graphs.append(gi);
|
graphs.append(gi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,6 +54,9 @@ QList<GraphItem*> TemperatureGraph::loadData(const Data &data)
|
|||||||
graphs.append(0);
|
graphs.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < data.areas().count(); i++)
|
||||||
|
skipColor();
|
||||||
|
|
||||||
setInfo();
|
setInfo();
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
|
@ -7,6 +7,9 @@ void ToolTip::insert(const QString &key, const QString &value)
|
|||||||
|
|
||||||
QString ToolTip::toString()
|
QString ToolTip::toString()
|
||||||
{
|
{
|
||||||
|
if (_list.isEmpty())
|
||||||
|
return QString();
|
||||||
|
|
||||||
QString ret = "<table>";
|
QString ret = "<table>";
|
||||||
|
|
||||||
for (int i = 0; i < _list.count(); i++)
|
for (int i = 0; i < _list.count(); i++)
|
||||||
|
39
src/data/area.h
Normal file
39
src/data/area.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef AREA_H
|
||||||
|
#define AREA_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QList>
|
||||||
|
#include "polygon.h"
|
||||||
|
|
||||||
|
class Area : public QList<Polygon>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const QString& name() const {return _name;}
|
||||||
|
const QString& description() const {return _desc;}
|
||||||
|
void setName(const QString &name) {_name = name;}
|
||||||
|
void setDescription(const QString &desc) {_desc = desc;}
|
||||||
|
|
||||||
|
bool isValid() const
|
||||||
|
{
|
||||||
|
if (isEmpty())
|
||||||
|
return false;
|
||||||
|
for (int i = 0; i < size(); i++)
|
||||||
|
if (!at(i).isValid())
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
RectC boundingRect() const
|
||||||
|
{
|
||||||
|
RectC ret;
|
||||||
|
for (int i = 0; i < size(); i++)
|
||||||
|
ret |= at(i).boundingRect();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _name;
|
||||||
|
QString _desc;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // AREA_H
|
@ -1,10 +1,12 @@
|
|||||||
#include "csvparser.h"
|
#include "csvparser.h"
|
||||||
|
|
||||||
bool CSVParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool CSVParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(tracks);
|
Q_UNUSED(tracks);
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
bool res;
|
bool res;
|
||||||
|
|
||||||
_errorLine = 1;
|
_errorLine = 1;
|
||||||
|
@ -9,7 +9,7 @@ public:
|
|||||||
CSVParser() : _errorLine(0) {}
|
CSVParser() : _errorLine(0) {}
|
||||||
|
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
|
@ -63,20 +63,13 @@ static QHash<QString, Parser*> parsers()
|
|||||||
QHash<QString, Parser*> Data::_parsers = parsers();
|
QHash<QString, Parser*> Data::_parsers = parsers();
|
||||||
bool Data::_useDEM = false;
|
bool Data::_useDEM = false;
|
||||||
|
|
||||||
Data::~Data()
|
void Data::processData(const QList<TrackData> &trackData,
|
||||||
|
const QList<RouteData> &routeData)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _tracks.count(); i++)
|
for (int i = 0; i < trackData.count(); i++)
|
||||||
delete _tracks.at(i);
|
_tracks.append(Track(trackData.at(i)));
|
||||||
for (int i = 0; i < _routes.count(); i++)
|
for (int i = 0; i < routeData.count(); i++)
|
||||||
delete _routes.at(i);
|
_routes.append(Route(routeData.at(i)));
|
||||||
}
|
|
||||||
|
|
||||||
void Data::processData()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < _trackData.count(); i++)
|
|
||||||
_tracks.append(new Track(_trackData.at(i)));
|
|
||||||
for (int i = 0; i < _routeData.count(); i++)
|
|
||||||
_routes.append(new Route(_routeData.at(i)));
|
|
||||||
for (int i = 0; i < _waypoints.size(); i++) {
|
for (int i = 0; i < _waypoints.size(); i++) {
|
||||||
if (!_waypoints.at(i).hasElevation() || _useDEM) {
|
if (!_waypoints.at(i).hasElevation() || _useDEM) {
|
||||||
qreal elevation = DEM::elevation(_waypoints.at(i).coordinates());
|
qreal elevation = DEM::elevation(_waypoints.at(i).coordinates());
|
||||||
@ -90,6 +83,8 @@ Data::Data(const QString &fileName, bool poi)
|
|||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
|
QList<TrackData> trackData;
|
||||||
|
QList<RouteData> routeData;
|
||||||
|
|
||||||
_valid = false;
|
_valid = false;
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
@ -101,9 +96,10 @@ Data::Data(const QString &fileName, bool poi)
|
|||||||
|
|
||||||
QHash<QString, Parser*>::iterator it;
|
QHash<QString, Parser*>::iterator it;
|
||||||
if ((it = _parsers.find(fi.suffix().toLower())) != _parsers.end()) {
|
if ((it = _parsers.find(fi.suffix().toLower())) != _parsers.end()) {
|
||||||
if (it.value()->parse(&file, _trackData, _routeData, _waypoints)) {
|
if (it.value()->parse(&file, trackData, routeData, _polygons,
|
||||||
|
_waypoints)) {
|
||||||
if (!poi)
|
if (!poi)
|
||||||
processData();
|
processData(trackData, routeData);
|
||||||
_valid = true;
|
_valid = true;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -112,9 +108,10 @@ Data::Data(const QString &fileName, bool poi)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
||||||
if (it.value()->parse(&file, _trackData, _routeData, _waypoints)) {
|
if (it.value()->parse(&file, trackData, routeData, _polygons,
|
||||||
|
_waypoints)) {
|
||||||
if (!poi)
|
if (!poi)
|
||||||
processData();
|
processData(trackData, routeData);
|
||||||
_valid = true;
|
_valid = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,15 @@ class Data
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Data(const QString &fileName, bool poi = false);
|
Data(const QString &fileName, bool poi = false);
|
||||||
~Data();
|
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
const QList<Track*> &tracks() const {return _tracks;}
|
const QList<Track> &tracks() const {return _tracks;}
|
||||||
const QList<Route*> &routes() const {return _routes;}
|
const QList<Route> &routes() const {return _routes;}
|
||||||
const QVector<Waypoint> &waypoints() const {return _waypoints;}
|
const QVector<Waypoint> &waypoints() const {return _waypoints;}
|
||||||
|
const QList<Area> &areas() const {return _polygons;}
|
||||||
|
|
||||||
static QString formats();
|
static QString formats();
|
||||||
static QStringList filter();
|
static QStringList filter();
|
||||||
@ -31,19 +31,18 @@ public:
|
|||||||
static void useDEM(bool use);
|
static void useDEM(bool use);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void processData();
|
void processData(const QList<TrackData> &trackData,
|
||||||
|
const QList<RouteData> &routeData);
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
int _errorLine;
|
int _errorLine;
|
||||||
|
|
||||||
QList<Track*> _tracks;
|
QList<Track> _tracks;
|
||||||
QList<Route*> _routes;
|
QList<Route> _routes;
|
||||||
|
QList<Area> _polygons;
|
||||||
QVector<Waypoint> _waypoints;
|
QVector<Waypoint> _waypoints;
|
||||||
|
|
||||||
QList<TrackData> _trackData;
|
|
||||||
QList<RouteData> _routeData;
|
|
||||||
|
|
||||||
static QHash<QString, Parser*> _parsers;
|
static QHash<QString, Parser*> _parsers;
|
||||||
static bool _useDEM;
|
static bool _useDEM;
|
||||||
};
|
};
|
||||||
|
@ -372,10 +372,12 @@ bool FITParser::parseHeader(CTX &ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool FITParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes,
|
||||||
|
QList<Area> &polygons, QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
Q_UNUSED(waypoints);
|
Q_UNUSED(waypoints);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
CTX ctx(file);
|
CTX ctx(file);
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class FITParser : public Parser
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return 0;}
|
int errorLine() const {return 0;}
|
||||||
|
|
||||||
|
@ -3,20 +3,7 @@
|
|||||||
#include "geojsonparser.h"
|
#include "geojsonparser.h"
|
||||||
|
|
||||||
|
|
||||||
enum Type {
|
GeoJSONParser::Type GeoJSONParser::type(const QJsonObject &json)
|
||||||
Unknown,
|
|
||||||
Point,
|
|
||||||
LineString,
|
|
||||||
MultiPoint,
|
|
||||||
Polygon,
|
|
||||||
MultiLineString,
|
|
||||||
MultiPolygon,
|
|
||||||
GeometryCollection,
|
|
||||||
Feature,
|
|
||||||
FeatureCollection
|
|
||||||
};
|
|
||||||
|
|
||||||
static Type type(const QJsonObject &json)
|
|
||||||
{
|
{
|
||||||
QString str(json["type"].toString());
|
QString str(json["type"].toString());
|
||||||
|
|
||||||
@ -57,6 +44,8 @@ bool GeoJSONParser::point(const QJsonArray &coordinates, Waypoint &waypoint,
|
|||||||
waypoint.setElevation(coordinates.at(2).toDouble());
|
waypoint.setElevation(coordinates.at(2).toDouble());
|
||||||
if (properties.contains("title") && properties["title"].isString())
|
if (properties.contains("title") && properties["title"].isString())
|
||||||
waypoint.setName(properties["title"].toString());
|
waypoint.setName(properties["title"].toString());
|
||||||
|
if (properties.contains("name") && properties["name"].isString())
|
||||||
|
waypoint.setName(properties["name"].toString());
|
||||||
if (properties.contains("description")
|
if (properties.contains("description")
|
||||||
&& properties["description"].isString())
|
&& properties["description"].isString())
|
||||||
waypoint.setDescription(properties["description"].toString());
|
waypoint.setDescription(properties["description"].toString());
|
||||||
@ -69,7 +58,7 @@ bool GeoJSONParser::multiPoint(const QJsonArray &coordinates,
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < coordinates.size(); i++) {
|
for (int i = 0; i < coordinates.size(); i++) {
|
||||||
if (!coordinates.at(i).isArray()) {
|
if (!coordinates.at(i).isArray()) {
|
||||||
_errorString = "Invalid MultiPoint Coordinates";
|
_errorString = "Invalid MultiPoint coordinates";
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
waypoints.resize(waypoints.size() + 1);
|
waypoints.resize(waypoints.size() + 1);
|
||||||
@ -86,6 +75,8 @@ bool GeoJSONParser::lineString(const QJsonArray &coordinates, TrackData &track,
|
|||||||
{
|
{
|
||||||
if (properties.contains("title") && properties["title"].isString())
|
if (properties.contains("title") && properties["title"].isString())
|
||||||
track.setName(properties["title"].toString());
|
track.setName(properties["title"].toString());
|
||||||
|
if (properties.contains("name") && properties["name"].isString())
|
||||||
|
track.setName(properties["name"].toString());
|
||||||
if (properties.contains("description")
|
if (properties.contains("description")
|
||||||
&& properties["description"].isString())
|
&& properties["description"].isString())
|
||||||
track.setDescription(properties["description"].toString());
|
track.setDescription(properties["description"].toString());
|
||||||
@ -94,7 +85,7 @@ bool GeoJSONParser::lineString(const QJsonArray &coordinates, TrackData &track,
|
|||||||
QJsonArray point(coordinates.at(i).toArray());
|
QJsonArray point(coordinates.at(i).toArray());
|
||||||
if (point.count() < 2 || !point.at(0).isDouble()
|
if (point.count() < 2 || !point.at(0).isDouble()
|
||||||
|| !point.at(1).isDouble()) {
|
|| !point.at(1).isDouble()) {
|
||||||
_errorString = "Invalid LineString Coordinates";
|
_errorString = "Invalid LineString coordinates";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +104,7 @@ bool GeoJSONParser::multiLineString(const QJsonArray &coordinates,
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < coordinates.size(); i++) {
|
for (int i = 0; i < coordinates.size(); i++) {
|
||||||
if (!coordinates.at(i).isArray()) {
|
if (!coordinates.at(i).isArray()) {
|
||||||
_errorString = "Invalid MultiLineString Coordinates";
|
_errorString = "Invalid MultiLineString coordinates";
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
tracks.append(TrackData());
|
tracks.append(TrackData());
|
||||||
@ -126,9 +117,76 @@ bool GeoJSONParser::multiLineString(const QJsonArray &coordinates,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeoJSONParser::geometryCollection(const QJsonObject &json,
|
bool GeoJSONParser::polygon(const QJsonArray &coordinates, ::Polygon &pg)
|
||||||
QList<TrackData> &tracks, QVector<Waypoint> &waypoints,
|
{
|
||||||
|
for (int i = 0; i < coordinates.size(); i++) {
|
||||||
|
if (!coordinates.at(i).isArray()) {
|
||||||
|
_errorString = "Invalid Polygon linear ring";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QJsonArray lr(coordinates.at(i).toArray());
|
||||||
|
pg.append(QVector<Coordinates>());
|
||||||
|
QVector<Coordinates> &data = pg.last();
|
||||||
|
|
||||||
|
for (int j = 0; j < lr.size(); j++) {
|
||||||
|
QJsonArray point(lr.at(j).toArray());
|
||||||
|
if (point.count() < 2 || !point.at(0).isDouble()
|
||||||
|
|| !point.at(1).isDouble()) {
|
||||||
|
_errorString = "Invalid Polygon linear ring coordinates";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
data.append(Coordinates(point.at(0).toDouble(),
|
||||||
|
point.at(1).toDouble()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GeoJSONParser::polygon(const QJsonArray &coordinates, Area &area,
|
||||||
const QJsonObject &properties)
|
const QJsonObject &properties)
|
||||||
|
{
|
||||||
|
if (properties.contains("title") && properties["title"].isString())
|
||||||
|
area.setName(properties["title"].toString());
|
||||||
|
if (properties.contains("name") && properties["name"].isString())
|
||||||
|
area.setName(properties["name"].toString());
|
||||||
|
if (properties.contains("description")
|
||||||
|
&& properties["description"].isString())
|
||||||
|
area.setDescription(properties["description"].toString());
|
||||||
|
|
||||||
|
area.append(::Polygon());
|
||||||
|
return polygon(coordinates, area.last());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GeoJSONParser::multiPolygon(const QJsonArray &coordinates,
|
||||||
|
Area &area, const QJsonObject &properties)
|
||||||
|
{
|
||||||
|
if (properties.contains("title") && properties["title"].isString())
|
||||||
|
area.setName(properties["title"].toString());
|
||||||
|
if (properties.contains("name") && properties["name"].isString())
|
||||||
|
area.setName(properties["name"].toString());
|
||||||
|
if (properties.contains("description")
|
||||||
|
&& properties["description"].isString())
|
||||||
|
area.setDescription(properties["description"].toString());
|
||||||
|
|
||||||
|
for (int i = 0; i < coordinates.size(); i++) {
|
||||||
|
if (!coordinates.at(i).isArray()) {
|
||||||
|
_errorString = "Invalid MultiPolygon coordinates";
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
area.append(::Polygon());
|
||||||
|
if (!polygon(coordinates.at(i).toArray(), area.last()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GeoJSONParser::geometryCollection(const QJsonObject &json,
|
||||||
|
QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
|
QVector<Waypoint> &waypoints, const QJsonObject &properties)
|
||||||
{
|
{
|
||||||
if (!json.contains("geometries") || !json["geometries"].isArray()) {
|
if (!json.contains("geometries") || !json["geometries"].isArray()) {
|
||||||
_errorString = "Invalid/missing GeometryCollection geometries array";
|
_errorString = "Invalid/missing GeometryCollection geometries array";
|
||||||
@ -162,10 +220,19 @@ bool GeoJSONParser::geometryCollection(const QJsonObject &json,
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case Polygon:
|
case Polygon:
|
||||||
|
areas.append(Area());
|
||||||
|
if (!polygon(geometry["coordinates"].toArray(), areas.last(),
|
||||||
|
properties))
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
case MultiPolygon:
|
case MultiPolygon:
|
||||||
|
areas.append(Area());
|
||||||
|
if (!multiPolygon(geometry["coordinates"].toArray(),
|
||||||
|
areas.last(), properties))
|
||||||
|
return false;
|
||||||
break;
|
break;
|
||||||
case GeometryCollection:
|
case GeometryCollection:
|
||||||
if (!geometryCollection(geometry, tracks, waypoints,
|
if (!geometryCollection(geometry, tracks, areas, waypoints,
|
||||||
properties))
|
properties))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
@ -180,7 +247,7 @@ bool GeoJSONParser::geometryCollection(const QJsonObject &json,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GeoJSONParser::feature(const QJsonObject &json, QList<TrackData> &tracks,
|
bool GeoJSONParser::feature(const QJsonObject &json, QList<TrackData> &tracks,
|
||||||
QVector<Waypoint> &waypoints)
|
QList<Area> &areas, QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
QJsonObject properties(json["properties"].toObject());
|
QJsonObject properties(json["properties"].toObject());
|
||||||
QJsonObject geometry(json["geometry"].toObject());
|
QJsonObject geometry(json["geometry"].toObject());
|
||||||
@ -201,10 +268,15 @@ bool GeoJSONParser::feature(const QJsonObject &json, QList<TrackData> &tracks,
|
|||||||
return multiLineString(geometry["coordinates"].toArray(), tracks,
|
return multiLineString(geometry["coordinates"].toArray(), tracks,
|
||||||
properties);
|
properties);
|
||||||
case GeometryCollection:
|
case GeometryCollection:
|
||||||
return geometryCollection(geometry, tracks, waypoints);
|
return geometryCollection(geometry, tracks, areas, waypoints);
|
||||||
case Polygon:
|
case Polygon:
|
||||||
|
areas.append(Area());
|
||||||
|
return polygon(geometry["coordinates"].toArray(), areas.last(),
|
||||||
|
properties);
|
||||||
case MultiPolygon:
|
case MultiPolygon:
|
||||||
return true;
|
areas.append(Area());
|
||||||
|
return multiPolygon(geometry["coordinates"].toArray(), areas.last(),
|
||||||
|
properties);
|
||||||
default:
|
default:
|
||||||
_errorString = geometry["type"].toString()
|
_errorString = geometry["type"].toString()
|
||||||
+ ": invalid/missing Feature geometry";
|
+ ": invalid/missing Feature geometry";
|
||||||
@ -213,7 +285,8 @@ bool GeoJSONParser::feature(const QJsonObject &json, QList<TrackData> &tracks,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GeoJSONParser::featureCollection(const QJsonObject &json,
|
bool GeoJSONParser::featureCollection(const QJsonObject &json,
|
||||||
QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
|
QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
if (!json.contains("features") || !json["features"].isArray()) {
|
if (!json.contains("features") || !json["features"].isArray()) {
|
||||||
_errorString = "Invalid/missing FeatureCollection features array";
|
_errorString = "Invalid/missing FeatureCollection features array";
|
||||||
@ -222,7 +295,7 @@ bool GeoJSONParser::featureCollection(const QJsonObject &json,
|
|||||||
|
|
||||||
QJsonArray features(json["features"].toArray());
|
QJsonArray features(json["features"].toArray());
|
||||||
for (int i = 0; i < features.size(); i++)
|
for (int i = 0; i < features.size(); i++)
|
||||||
if (!feature(features.at(i).toObject(), tracks, waypoints))
|
if (!feature(features.at(i).toObject(), tracks, areas, waypoints))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -230,7 +303,7 @@ bool GeoJSONParser::featureCollection(const QJsonObject &json,
|
|||||||
|
|
||||||
|
|
||||||
bool GeoJSONParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool GeoJSONParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &areas, QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
@ -256,14 +329,17 @@ bool GeoJSONParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
case MultiLineString:
|
case MultiLineString:
|
||||||
return multiLineString(json["coordinates"].toArray(), tracks);
|
return multiLineString(json["coordinates"].toArray(), tracks);
|
||||||
case GeometryCollection:
|
case GeometryCollection:
|
||||||
return geometryCollection(json, tracks, waypoints);
|
return geometryCollection(json, tracks, areas, waypoints);
|
||||||
case Feature:
|
case Feature:
|
||||||
return feature(json, tracks, waypoints);
|
return feature(json, tracks, areas, waypoints);
|
||||||
case FeatureCollection:
|
case FeatureCollection:
|
||||||
return featureCollection(json, tracks, waypoints);
|
return featureCollection(json, tracks, areas, waypoints);
|
||||||
case Polygon:
|
case Polygon:
|
||||||
|
areas.append(Area());
|
||||||
|
return polygon(json["coordinates"].toArray(), areas.last());
|
||||||
case MultiPolygon:
|
case MultiPolygon:
|
||||||
return true;
|
areas.append(Area());
|
||||||
|
return multiPolygon(json["coordinates"].toArray(), areas.last());
|
||||||
case Unknown:
|
case Unknown:
|
||||||
if (json["type"].toString().isNull())
|
if (json["type"].toString().isNull())
|
||||||
_errorString = "Not a GeoJSON file";
|
_errorString = "Not a GeoJSON file";
|
||||||
|
@ -11,11 +11,25 @@ class GeoJSONParser : public Parser
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QVector<Waypoint> &waypoints);
|
QList<Area> &areas, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return 0;}
|
int errorLine() const {return 0;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum Type {
|
||||||
|
Unknown,
|
||||||
|
Point,
|
||||||
|
LineString,
|
||||||
|
MultiPoint,
|
||||||
|
Polygon,
|
||||||
|
MultiLineString,
|
||||||
|
MultiPolygon,
|
||||||
|
GeometryCollection,
|
||||||
|
Feature,
|
||||||
|
FeatureCollection
|
||||||
|
};
|
||||||
|
|
||||||
|
Type type(const QJsonObject &json);
|
||||||
bool point(const QJsonArray &coordinates, Waypoint &waypoint,
|
bool point(const QJsonArray &coordinates, Waypoint &waypoint,
|
||||||
const QJsonObject &properties = QJsonObject());
|
const QJsonObject &properties = QJsonObject());
|
||||||
bool multiPoint(const QJsonArray &coordinates,
|
bool multiPoint(const QJsonArray &coordinates,
|
||||||
@ -24,12 +38,18 @@ private:
|
|||||||
const QJsonObject &properties = QJsonObject());
|
const QJsonObject &properties = QJsonObject());
|
||||||
bool multiLineString(const QJsonArray &coordinates,
|
bool multiLineString(const QJsonArray &coordinates,
|
||||||
QList<TrackData> &tracks, const QJsonObject &properties = QJsonObject());
|
QList<TrackData> &tracks, const QJsonObject &properties = QJsonObject());
|
||||||
|
bool polygon(const QJsonArray &coordinates, ::Polygon &pg);
|
||||||
|
bool polygon(const QJsonArray &coordinates, Area &area,
|
||||||
|
const QJsonObject &properties = QJsonObject());
|
||||||
|
bool multiPolygon(const QJsonArray &coordinates, Area &area,
|
||||||
|
const QJsonObject &properties = QJsonObject());
|
||||||
bool geometryCollection(const QJsonObject &json, QList<TrackData> &tracks,
|
bool geometryCollection(const QJsonObject &json, QList<TrackData> &tracks,
|
||||||
QVector<Waypoint> &waypoints, const QJsonObject &properties = QJsonObject());
|
QList<Area> &areas, QVector<Waypoint> &waypoints,
|
||||||
|
const QJsonObject &properties = QJsonObject());
|
||||||
bool feature(const QJsonObject &json, QList<TrackData> &tracks,
|
bool feature(const QJsonObject &json, QList<TrackData> &tracks,
|
||||||
QVector<Waypoint> &waypoints);
|
QList<Area> &areas, QVector<Waypoint> &waypoints);
|
||||||
bool featureCollection(const QJsonObject &json, QList<TrackData> &tracks,
|
bool featureCollection(const QJsonObject &json, QList<TrackData> &tracks,
|
||||||
QVector<Waypoint> &waypoints);
|
QList<Area> &areas, QVector<Waypoint> &waypoints);
|
||||||
|
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
};
|
};
|
||||||
|
@ -216,8 +216,11 @@ void GPXParser::gpx(QList<TrackData> &tracks, QList<RouteData> &routes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GPXParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool GPXParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(polygons);
|
||||||
|
|
||||||
_reader.clear();
|
_reader.clear();
|
||||||
_reader.setDevice(file);
|
_reader.setDevice(file);
|
||||||
_reader.setNamespaceProcessing(false);
|
_reader.setNamespaceProcessing(false);
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
class GPXParser : public Parser
|
class GPXParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _reader.errorString();}
|
QString errorString() const {return _reader.errorString();}
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
|
@ -39,6 +39,14 @@ inline QDebug operator<<(QDebug dbg, const GraphPoint &point)
|
|||||||
}
|
}
|
||||||
#endif // QT_NO_DEBUG
|
#endif // QT_NO_DEBUG
|
||||||
|
|
||||||
typedef QVector<GraphPoint> Graph;
|
class Graph : public QVector<GraphPoint>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Graph() {}
|
||||||
|
Graph(int size) : QVector<GraphPoint>(size) {}
|
||||||
|
Graph(const Graph &other) : QVector<GraphPoint>(other) {}
|
||||||
|
|
||||||
|
bool isValid() const {return size() >= 2;}
|
||||||
|
};
|
||||||
|
|
||||||
#endif // GRAPH_H
|
#endif // GRAPH_H
|
||||||
|
@ -192,9 +192,11 @@ bool IGCParser::readCRecord(RouteData &route, const char *line, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IGCParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool IGCParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(waypoints);
|
Q_UNUSED(waypoints);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
qint64 len;
|
qint64 len;
|
||||||
char line[76 + 2 + 1 + 1];
|
char line[76 + 2 + 1 + 1];
|
||||||
bool route = false, track = false;
|
bool route = false, track = false;
|
||||||
|
@ -11,8 +11,8 @@ class IGCParser : public Parser
|
|||||||
public:
|
public:
|
||||||
IGCParser() : _errorLine(0) {}
|
IGCParser() : _errorLine(0) {}
|
||||||
|
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
|
@ -186,6 +186,63 @@ bool KMLParser::lineCoordinates(TrackData &track)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool KMLParser::polygonCoordinates(QVector<Coordinates> &points)
|
||||||
|
{
|
||||||
|
QString data = _reader.readElementText();
|
||||||
|
const QChar *sp, *ep, *cp, *vp;
|
||||||
|
int c = 0;
|
||||||
|
qreal val[3];
|
||||||
|
bool res;
|
||||||
|
|
||||||
|
|
||||||
|
sp = data.constData();
|
||||||
|
ep = sp + data.size();
|
||||||
|
|
||||||
|
for (cp = sp; cp < ep; cp++)
|
||||||
|
if (!cp->isSpace())
|
||||||
|
break;
|
||||||
|
|
||||||
|
for (vp = cp; cp <= ep; cp++) {
|
||||||
|
if (*cp == ',') {
|
||||||
|
if (c > 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
val[c] = QString(vp, cp - vp).toDouble(&res);
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
val[c] = QStringRef(&data, vp - sp, cp - vp).toDouble(&res);
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
c++;
|
||||||
|
vp = cp + 1;
|
||||||
|
} else if (cp->isSpace() || cp->isNull()) {
|
||||||
|
if (c < 1 || c > 2)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
val[c] = QString(vp, cp - vp).toDouble(&res);
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
val[c] = QStringRef(&data, vp - sp, cp - vp).toDouble(&res);
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
|
if (!res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
points.append(Coordinates(val[0], val[1]));
|
||||||
|
if (!points.last().isValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (cp->isSpace())
|
||||||
|
cp++;
|
||||||
|
c = 0;
|
||||||
|
vp = cp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QDateTime KMLParser::timeStamp()
|
QDateTime KMLParser::timeStamp()
|
||||||
{
|
{
|
||||||
QDateTime ts;
|
QDateTime ts;
|
||||||
@ -211,6 +268,52 @@ void KMLParser::lineString(TrackData &track)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KMLParser::linearRing(QVector<Coordinates> &coordinates)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == QLatin1String("coordinates")) {
|
||||||
|
if (!polygonCoordinates(coordinates))
|
||||||
|
_reader.raiseError("Invalid coordinates");
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::boundary(QVector<Coordinates> &coordinates)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == QLatin1String("LinearRing"))
|
||||||
|
linearRing(coordinates);
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::polygon(Area &area)
|
||||||
|
{
|
||||||
|
area.append(Polygon());
|
||||||
|
Polygon &polygon = area.last();
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == QLatin1String("outerBoundaryIs")) {
|
||||||
|
if (!area.isEmpty()) {
|
||||||
|
_reader.raiseError("Multiple polygon outerBoundaryIss");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
polygon.append(QVector<Coordinates>());
|
||||||
|
boundary(polygon.last());
|
||||||
|
} else if (_reader.name() == QLatin1String("innerBoundaryIs")) {
|
||||||
|
if (area.isEmpty()) {
|
||||||
|
_reader.raiseError("Missing polygon outerBoundaryIs");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
polygon.append(QVector<Coordinates>());
|
||||||
|
boundary(polygon.last());
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void KMLParser::point(Waypoint &waypoint)
|
void KMLParser::point(Waypoint &waypoint)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -380,7 +483,7 @@ void KMLParser::multiTrack(TrackData &t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::multiGeometry(QList<TrackData> &tracks,
|
void KMLParser::multiGeometry(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
QVector<Waypoint> &waypoints, const QString &name, const QString &desc,
|
QVector<Waypoint> &waypoints, const QString &name, const QString &desc,
|
||||||
const QDateTime timestamp)
|
const QDateTime timestamp)
|
||||||
{
|
{
|
||||||
@ -398,12 +501,19 @@ void KMLParser::multiGeometry(QList<TrackData> &tracks,
|
|||||||
t.setName(name);
|
t.setName(name);
|
||||||
t.setDescription(desc);
|
t.setDescription(desc);
|
||||||
lineString(t);
|
lineString(t);
|
||||||
|
} else if (_reader.name() == QLatin1String("Polygon")) {
|
||||||
|
areas.append(Area());
|
||||||
|
Area &a = areas.last();
|
||||||
|
a.setName(name);
|
||||||
|
a.setDescription(desc);
|
||||||
|
polygon(a);
|
||||||
} else
|
} else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::placemark(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
|
void KMLParser::placemark(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
QString name, desc;
|
QString name, desc;
|
||||||
QDateTime timestamp;
|
QDateTime timestamp;
|
||||||
@ -416,7 +526,7 @@ void KMLParser::placemark(QList<TrackData> &tracks, QVector<Waypoint> &waypoints
|
|||||||
else if (_reader.name() == QLatin1String("TimeStamp"))
|
else if (_reader.name() == QLatin1String("TimeStamp"))
|
||||||
timestamp = timeStamp();
|
timestamp = timeStamp();
|
||||||
else if (_reader.name() == QLatin1String("MultiGeometry"))
|
else if (_reader.name() == QLatin1String("MultiGeometry"))
|
||||||
multiGeometry(tracks, waypoints, name, desc, timestamp);
|
multiGeometry(tracks, areas, waypoints, name, desc, timestamp);
|
||||||
else if (_reader.name() == QLatin1String("Point")) {
|
else if (_reader.name() == QLatin1String("Point")) {
|
||||||
waypoints.append(Waypoint());
|
waypoints.append(Waypoint());
|
||||||
Waypoint &w = waypoints.last();
|
Waypoint &w = waypoints.last();
|
||||||
@ -443,51 +553,60 @@ void KMLParser::placemark(QList<TrackData> &tracks, QVector<Waypoint> &waypoints
|
|||||||
t.setName(name);
|
t.setName(name);
|
||||||
t.setDescription(desc);
|
t.setDescription(desc);
|
||||||
multiTrack(t);
|
multiTrack(t);
|
||||||
|
} else if (_reader.name() == QLatin1String("Polygon")) {
|
||||||
|
areas.append(Area());
|
||||||
|
Area &a = areas.last();
|
||||||
|
a.setName(name);
|
||||||
|
a.setDescription(desc);
|
||||||
|
polygon(a);
|
||||||
} else
|
} else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::folder(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
|
void KMLParser::folder(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("Placemark"))
|
if (_reader.name() == QLatin1String("Placemark"))
|
||||||
placemark(tracks, waypoints);
|
placemark(tracks, areas, waypoints);
|
||||||
else if (_reader.name() == QLatin1String("Folder"))
|
else if (_reader.name() == QLatin1String("Folder"))
|
||||||
folder(tracks, waypoints);
|
folder(tracks, areas, waypoints);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::document(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
|
void KMLParser::document(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("Placemark"))
|
if (_reader.name() == QLatin1String("Placemark"))
|
||||||
placemark(tracks, waypoints);
|
placemark(tracks, areas, waypoints);
|
||||||
else if (_reader.name() == QLatin1String("Folder"))
|
else if (_reader.name() == QLatin1String("Folder"))
|
||||||
folder(tracks, waypoints);
|
folder(tracks, areas, waypoints);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::kml(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
|
void KMLParser::kml(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("Document"))
|
if (_reader.name() == QLatin1String("Document"))
|
||||||
document(tracks, waypoints);
|
document(tracks, areas, waypoints);
|
||||||
else if (_reader.name() == QLatin1String("Placemark"))
|
else if (_reader.name() == QLatin1String("Placemark"))
|
||||||
placemark(tracks, waypoints);
|
placemark(tracks, areas, waypoints);
|
||||||
else if (_reader.name() == QLatin1String("Folder"))
|
else if (_reader.name() == QLatin1String("Folder"))
|
||||||
folder(tracks, waypoints);
|
folder(tracks, areas, waypoints);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KMLParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool KMLParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &areas, QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
|
|
||||||
@ -496,7 +615,7 @@ bool KMLParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
|
|
||||||
if (_reader.readNextStartElement()) {
|
if (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("kml"))
|
if (_reader.name() == QLatin1String("kml"))
|
||||||
kml(tracks, waypoints);
|
kml(tracks, areas, waypoints);
|
||||||
else
|
else
|
||||||
_reader.raiseError("Not a KML file");
|
_reader.raiseError("Not a KML file");
|
||||||
}
|
}
|
||||||
|
@ -8,24 +8,33 @@
|
|||||||
class KMLParser : public Parser
|
class KMLParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints);
|
QList<Area> &areas, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _reader.errorString();}
|
QString errorString() const {return _reader.errorString();}
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void kml(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
|
void kml(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
void document(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
|
QVector<Waypoint> &waypoints);
|
||||||
void folder(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
|
void document(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
void placemark(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
|
QVector<Waypoint> &waypoints);
|
||||||
void multiGeometry(QList<TrackData> &tracks, QVector<Waypoint> &waypoints,
|
void folder(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
const QString &name, const QString &desc, const QDateTime timestamp);
|
QVector<Waypoint> &waypoints);
|
||||||
|
void placemark(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
|
QVector<Waypoint> &waypoints);
|
||||||
|
void multiGeometry(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
|
QVector<Waypoint> &waypoints, const QString &name, const QString &desc,
|
||||||
|
const QDateTime timestamp);
|
||||||
void track(TrackData &track);
|
void track(TrackData &track);
|
||||||
void multiTrack(TrackData &t);
|
void multiTrack(TrackData &t);
|
||||||
void lineString(TrackData &track);
|
void lineString(TrackData &track);
|
||||||
|
void linearRing(QVector<Coordinates> &coordinates);
|
||||||
|
void boundary(QVector<Coordinates> &coordinates);
|
||||||
|
void polygon(Area &area);
|
||||||
void point(Waypoint &waypoint);
|
void point(Waypoint &waypoint);
|
||||||
bool pointCoordinates(Waypoint &waypoint);
|
bool pointCoordinates(Waypoint &waypoint);
|
||||||
bool lineCoordinates(TrackData &track);
|
bool lineCoordinates(TrackData &track);
|
||||||
|
bool polygonCoordinates(QVector<Coordinates> &points);
|
||||||
bool coord(Trackpoint &trackpoint);
|
bool coord(Trackpoint &trackpoint);
|
||||||
void extendedData(TrackData &track, int start);
|
void extendedData(TrackData &track, int start);
|
||||||
void schemaData(TrackData &track, int start);
|
void schemaData(TrackData &track, int start);
|
||||||
|
@ -58,10 +58,12 @@ void LOCParser::loc(QVector<Waypoint> &waypoints)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool LOCParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool LOCParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(tracks);
|
Q_UNUSED(tracks);
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
|
|
||||||
_reader.clear();
|
_reader.clear();
|
||||||
_reader.setDevice(file);
|
_reader.setDevice(file);
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
class LOCParser : public Parser
|
class LOCParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _reader.errorString();}
|
QString errorString() const {return _reader.errorString();}
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
|
@ -478,9 +478,11 @@ bool NMEAParser::readZDA(const char *line, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool NMEAParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool NMEAParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
qint64 len;
|
qint64 len;
|
||||||
char line[80 + 2 + 1 + 1];
|
char line[80 + 2 + 1 + 1];
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ class NMEAParser : public Parser
|
|||||||
public:
|
public:
|
||||||
NMEAParser() : _errorLine(0), _GGA(false) {}
|
NMEAParser() : _errorLine(0), _GGA(false) {}
|
||||||
|
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
|
@ -27,10 +27,12 @@ static QByteArray &decode(QByteArray &ba)
|
|||||||
|
|
||||||
|
|
||||||
bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(waypoints);
|
Q_UNUSED(waypoints);
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
bool res;
|
bool res;
|
||||||
const GCS *gcs = 0;
|
const GCS *gcs = 0;
|
||||||
|
|
||||||
@ -113,10 +115,12 @@ bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(waypoints);
|
Q_UNUSED(waypoints);
|
||||||
Q_UNUSED(tracks);
|
Q_UNUSED(tracks);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
bool res, record = false;
|
bool res, record = false;
|
||||||
const GCS *gcs = 0;
|
const GCS *gcs = 0;
|
||||||
|
|
||||||
@ -211,10 +215,12 @@ bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WPTParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool WPTParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(tracks);
|
Q_UNUSED(tracks);
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
bool res;
|
bool res;
|
||||||
const GCS *gcs = 0;
|
const GCS *gcs = 0;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ public:
|
|||||||
PLTParser() : _errorLine(0) {}
|
PLTParser() : _errorLine(0) {}
|
||||||
|
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public:
|
|||||||
RTEParser() : _errorLine(0) {}
|
RTEParser() : _errorLine(0) {}
|
||||||
|
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public:
|
|||||||
WPTParser() : _errorLine(0) {}
|
WPTParser() : _errorLine(0) {}
|
||||||
|
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "trackdata.h"
|
#include "trackdata.h"
|
||||||
#include "routedata.h"
|
#include "routedata.h"
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
|
#include "area.h"
|
||||||
|
|
||||||
|
|
||||||
class Parser
|
class Parser
|
||||||
@ -16,7 +17,8 @@ public:
|
|||||||
virtual ~Parser() {}
|
virtual ~Parser() {}
|
||||||
|
|
||||||
virtual bool parse(QFile *file, QList<TrackData> &tracks,
|
virtual bool parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints) = 0;
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints) = 0;
|
||||||
virtual QString errorString() const = 0;
|
virtual QString errorString() const = 0;
|
||||||
virtual int errorLine() const = 0;
|
virtual int errorLine() const = 0;
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
#include "common/greatcircle.h"
|
#include "common/greatcircle.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "dem.h"
|
#include "dem.h"
|
||||||
|
#include "path.h"
|
||||||
|
#include "area.h"
|
||||||
|
#include "common/wgs84.h"
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
|
|
||||||
|
|
||||||
@ -177,6 +180,31 @@ QList<Waypoint> POI::points(const Waypoint &point) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Waypoint> POI::points(const Area &area) const
|
||||||
|
{
|
||||||
|
QList<Waypoint> ret;
|
||||||
|
qreal min[2], max[2];
|
||||||
|
QSet<int> set;
|
||||||
|
QSet<int>::const_iterator it;
|
||||||
|
|
||||||
|
RectC br(area.boundingRect());
|
||||||
|
double offset = rad2deg(_radius / WGS84_RADIUS);
|
||||||
|
|
||||||
|
min[0] = br.topLeft().lon() - offset;
|
||||||
|
min[1] = br.bottomRight().lat() - offset;
|
||||||
|
max[0] = br.bottomRight().lon() + offset;
|
||||||
|
max[1] = br.topLeft().lat() + offset;
|
||||||
|
|
||||||
|
_tree.Search(min, max, cb, &set);
|
||||||
|
|
||||||
|
for (it = set.constBegin(); it != set.constEnd(); ++it)
|
||||||
|
ret.append(_data.at(*it));
|
||||||
|
|
||||||
|
appendElevation(ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void POI::enableFile(const QString &fileName, bool enable)
|
void POI::enableFile(const QString &fileName, bool enable)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -7,8 +7,10 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "common/rtree.h"
|
#include "common/rtree.h"
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "path.h"
|
|
||||||
|
|
||||||
|
class Path;
|
||||||
|
class Area;
|
||||||
|
class RectC;
|
||||||
|
|
||||||
class POI : public QObject
|
class POI : public QObject
|
||||||
{
|
{
|
||||||
@ -28,6 +30,7 @@ public:
|
|||||||
|
|
||||||
QList<Waypoint> points(const Path &path) const;
|
QList<Waypoint> points(const Path &path) const;
|
||||||
QList<Waypoint> points(const Waypoint &point) const;
|
QList<Waypoint> points(const Waypoint &point) const;
|
||||||
|
QList<Waypoint> points(const Area &area) const;
|
||||||
|
|
||||||
const QStringList &files() const {return _files;}
|
const QStringList &files() const {return _files;}
|
||||||
void enableFile(const QString &fileName, bool enable);
|
void enableFile(const QString &fileName, bool enable);
|
||||||
|
15
src/data/polygon.cpp
Normal file
15
src/data/polygon.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "polygon.h"
|
||||||
|
|
||||||
|
RectC Polygon::boundingRect() const
|
||||||
|
{
|
||||||
|
if (isEmpty())
|
||||||
|
return RectC();
|
||||||
|
if (first().size() < 3)
|
||||||
|
return RectC();
|
||||||
|
|
||||||
|
RectC rect;
|
||||||
|
for (int i = 0; i < first().size(); i++)
|
||||||
|
rect = rect.united(first().at(i));
|
||||||
|
|
||||||
|
return rect;
|
||||||
|
}
|
17
src/data/polygon.h
Normal file
17
src/data/polygon.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef POLYGON_H
|
||||||
|
#define POLYGON_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QVector>
|
||||||
|
#include "common/coordinates.h"
|
||||||
|
#include "common/rectc.h"
|
||||||
|
|
||||||
|
class Polygon : public QList<QVector<Coordinates> >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool isValid() const {return !isEmpty() && first().size() >= 3;}
|
||||||
|
|
||||||
|
RectC boundingRect() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // POLYGON_H
|
@ -22,12 +22,12 @@ public:
|
|||||||
const QString &name() const {return _data.name();}
|
const QString &name() const {return _data.name();}
|
||||||
const QString &description() const {return _data.description();}
|
const QString &description() const {return _data.description();}
|
||||||
|
|
||||||
bool isNull() const {return (_data.count() < 2);}
|
bool isValid() const {return _data.size() >= 2;}
|
||||||
|
|
||||||
static void useDEM(bool use) {_useDEM = use;}
|
static void useDEM(bool use) {_useDEM = use;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const RouteData &_data;
|
RouteData _data;
|
||||||
QVector<qreal> _distance;
|
QVector<qreal> _distance;
|
||||||
|
|
||||||
static bool _useDEM;
|
static bool _useDEM;
|
||||||
|
@ -99,10 +99,12 @@ void SLFParser::activity(TrackData &track)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SLFParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool SLFParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(waypoints);
|
Q_UNUSED(waypoints);
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
|
|
||||||
_reader.clear();
|
_reader.clear();
|
||||||
_reader.setDevice(file);
|
_reader.setDevice(file);
|
||||||
|
@ -8,8 +8,8 @@ class QDateTime;
|
|||||||
|
|
||||||
class SLFParser : public Parser
|
class SLFParser : public Parser
|
||||||
{
|
{
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _reader.errorString();}
|
QString errorString() const {return _reader.errorString();}
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
|
@ -233,9 +233,11 @@ void TCXParser::tcx(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TCXParser::parse(QFile *file, QList<TrackData> &tracks,
|
bool TCXParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints)
|
QList<RouteData> &routes, QList<Area> &polygons,
|
||||||
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
Q_UNUSED(routes);
|
Q_UNUSED(routes);
|
||||||
|
Q_UNUSED(polygons);
|
||||||
|
|
||||||
_reader.clear();
|
_reader.clear();
|
||||||
_reader.setDevice(file);
|
_reader.setDevice(file);
|
||||||
|
@ -8,8 +8,8 @@
|
|||||||
class TCXParser : public Parser
|
class TCXParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool parse(QFile *file, QList<TrackData> &tracks,
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
QList<RouteData> &routes, QVector<Waypoint> &waypoints);
|
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _reader.errorString();}
|
QString errorString() const {return _reader.errorString();}
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
const QString &name() const {return _data.name();}
|
const QString &name() const {return _data.name();}
|
||||||
const QString &description() const {return _data.description();}
|
const QString &description() const {return _data.description();}
|
||||||
|
|
||||||
bool isNull() const {return (_data.size() < 2);}
|
bool isValid() const {return _data.size() >= 2;}
|
||||||
|
|
||||||
static void setElevationFilter(int window) {_elevationWindow = window;}
|
static void setElevationFilter(int window) {_elevationWindow = window;}
|
||||||
static void setSpeedFilter(int window) {_speedWindow = window;}
|
static void setSpeedFilter(int window) {_speedWindow = window;}
|
||||||
@ -50,7 +50,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool discardStopPoint(int i) const;
|
bool discardStopPoint(int i) const;
|
||||||
|
|
||||||
const TrackData &_data;
|
TrackData _data;
|
||||||
|
|
||||||
QVector<qreal> _distance;
|
QVector<qreal> _distance;
|
||||||
QVector<qreal> _time;
|
QVector<qreal> _time;
|
||||||
|
Loading…
Reference in New Issue
Block a user