mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Compare commits
3 Commits
69ebac9f5d
...
52b6ff697f
Author | SHA1 | Date | |
---|---|---|---|
52b6ff697f | |||
0b3e54abf2 | |||
1f0bd76f67 |
@ -34,20 +34,6 @@
|
|||||||
#define COORDINATES_OFFSET SCALE_OFFSET
|
#define COORDINATES_OFFSET SCALE_OFFSET
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static void updateZValues(T &items)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < items.size(); i++) {
|
|
||||||
const QGraphicsItem *ai = items.at(i);
|
|
||||||
for (int j = 0; j < items.size(); j++) {
|
|
||||||
QGraphicsItem *aj = items[j];
|
|
||||||
if (aj->boundingRect().contains(ai->boundingRect()))
|
|
||||||
aj->setZValue(qMin(ai->zValue() - 1, aj->zValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MapView::MapView(Map *map, POI *poi, QGeoPositionInfoSource *source,
|
MapView::MapView(Map *map, POI *poi, QGeoPositionInfoSource *source,
|
||||||
QWidget *parent) : QGraphicsView(parent)
|
QWidget *parent) : QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
@ -226,6 +212,7 @@ void MapView::addArea(const Area &area)
|
|||||||
ai->setOpacity(_areaOpacity);
|
ai->setOpacity(_areaOpacity);
|
||||||
ai->setDigitalZoom(_digitalZoom);
|
ai->setDigitalZoom(_digitalZoom);
|
||||||
ai->setVisible(_showAreas);
|
ai->setVisible(_showAreas);
|
||||||
|
ai->setZValue(-area.boundingRect().area());
|
||||||
|
|
||||||
_scene->addItem(ai);
|
_scene->addItem(ai);
|
||||||
_ar |= ai->bounds();
|
_ar |= ai->bounds();
|
||||||
@ -266,6 +253,7 @@ MapItem *MapView::addMap(MapAction *map)
|
|||||||
mi->setOpacity(_areaOpacity);
|
mi->setOpacity(_areaOpacity);
|
||||||
mi->setDigitalZoom(_digitalZoom);
|
mi->setDigitalZoom(_digitalZoom);
|
||||||
mi->setVisible(_showAreas);
|
mi->setVisible(_showAreas);
|
||||||
|
mi->setZValue(-mi->bounds().area());
|
||||||
|
|
||||||
_scene->addItem(mi);
|
_scene->addItem(mi);
|
||||||
_ar |= mi->bounds();
|
_ar |= mi->bounds();
|
||||||
@ -299,9 +287,6 @@ QList<PathItem *> MapView::loadData(const Data &data)
|
|||||||
else
|
else
|
||||||
updatePOIVisibility();
|
updatePOIVisibility();
|
||||||
|
|
||||||
if (!data.areas().isEmpty())
|
|
||||||
updateZValues(_areas);
|
|
||||||
|
|
||||||
centerOn(contentCenter());
|
centerOn(contentCenter());
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
@ -319,8 +304,6 @@ void MapView::loadMaps(const QList<MapAction *> &maps)
|
|||||||
else
|
else
|
||||||
updatePOIVisibility();
|
updatePOIVisibility();
|
||||||
|
|
||||||
updateZValues(_areas);
|
|
||||||
|
|
||||||
centerOn(contentCenter());
|
centerOn(contentCenter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,8 +319,6 @@ void MapView::loadDEMs(const QList<Area> &dems)
|
|||||||
else
|
else
|
||||||
updatePOIVisibility();
|
updatePOIVisibility();
|
||||||
|
|
||||||
updateZValues(_areas);
|
|
||||||
|
|
||||||
centerOn(contentCenter());
|
centerOn(contentCenter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
return (left() > right()) ? 360.0 - res : res;
|
return (left() > right()) ? 360.0 - res : res;
|
||||||
}
|
}
|
||||||
double height() const {return (top() - bottom());}
|
double height() const {return (top() - bottom());}
|
||||||
|
double area() const {return qAbs(width()) * qAbs(height());}
|
||||||
|
|
||||||
double top() const {return _tl.lat();}
|
double top() const {return _tl.lat();}
|
||||||
double bottom() const {return _br.lat();}
|
double bottom() const {return _br.lat();}
|
||||||
|
@ -429,41 +429,42 @@ static quint32 readImageInfo(DataStream &stream, Waypoint &waypoint,
|
|||||||
return rs + rh.size;
|
return rs + rh.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int speed(quint8 flags)
|
static int speed(quint16 flags)
|
||||||
{
|
{
|
||||||
return (((flags >> 3) & 0x0F) * 10) + (((flags >> 2) & 1) * 5);
|
return (((flags >> 3) & 0x0F) * 10) + (((flags >> 2) & 1) * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool portable(quint8 flags)
|
static QString units(quint16 flags)
|
||||||
|
{
|
||||||
|
return (flags & (1<<8)) ? "km/h" : "mi/h";
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool portable(quint16 flags)
|
||||||
{
|
{
|
||||||
return (flags & 1);
|
return (flags & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString cameraDesc(quint8 type, quint8 flags)
|
static bool redLight(quint16 flags)
|
||||||
{
|
{
|
||||||
switch (type) {
|
return (flags & (1<<9));
|
||||||
case 8:
|
}
|
||||||
return portable(flags)
|
|
||||||
? QString("<i>%1 mi/h</i>").arg(speed(flags))
|
|
||||||
: QString("%1 mi/h").arg(speed(flags));
|
|
||||||
case 9:
|
|
||||||
return portable(flags)
|
|
||||||
? QString("<i>%1 km/h</i>").arg(speed(flags))
|
|
||||||
: QString("%1 km/h").arg(speed(flags));
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
case 11:
|
|
||||||
return "Red light camera";
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString();
|
static QString cameraDesc(quint16 flags)
|
||||||
|
{
|
||||||
|
if (redLight(flags))
|
||||||
|
return "Red light camera";
|
||||||
|
else {
|
||||||
|
QString desc(QString::number(speed(flags)) + " " + units(flags));
|
||||||
|
return portable(flags) ? "<i>" + desc + "<i>" : desc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
|
static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
|
||||||
QList<Area> &polygons)
|
QList<Area> &polygons)
|
||||||
{
|
{
|
||||||
RecordHeader rh;
|
RecordHeader rh;
|
||||||
quint8 flags, type, s7, rs;
|
quint8 s7, rs;
|
||||||
|
quint16 flags;
|
||||||
qint32 top, right, bottom, left, lat, lon;
|
qint32 top, right, bottom, left, lat, lon;
|
||||||
quint32 ds = 15;
|
quint32 ds = 15;
|
||||||
|
|
||||||
@ -473,7 +474,7 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
|
|||||||
right = stream.readInt24();
|
right = stream.readInt24();
|
||||||
bottom = stream.readInt24();
|
bottom = stream.readInt24();
|
||||||
left = stream.readInt24();
|
left = stream.readInt24();
|
||||||
stream >> flags >> type >> s7;
|
stream >> flags >> s7;
|
||||||
|
|
||||||
if (s7) {
|
if (s7) {
|
||||||
quint32 skip = s7 + 2 + s7/4;
|
quint32 skip = s7 + 2 + s7/4;
|
||||||
@ -494,7 +495,7 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
|
|||||||
|
|
||||||
Area area(RectC(Coordinates(toWGS24(left), toWGS24(top)),
|
Area area(RectC(Coordinates(toWGS24(left), toWGS24(top)),
|
||||||
Coordinates(toWGS24(right), toWGS24(bottom))));
|
Coordinates(toWGS24(right), toWGS24(bottom))));
|
||||||
area.setDescription(cameraDesc(type, flags));
|
area.setDescription(cameraDesc(flags));
|
||||||
|
|
||||||
waypoints.append(Coordinates(toWGS24(lon), toWGS24(lat)));
|
waypoints.append(Coordinates(toWGS24(lon), toWGS24(lat)));
|
||||||
polygons.append(area);
|
polygons.append(area);
|
||||||
|
Loading…
Reference in New Issue
Block a user