1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Compare commits

..

No commits in common. "52b6ff697f4ec76a596e0cd5a1f24eeecaa4f394" and "69ebac9f5d9bd8d3c34938c7ce8b7964b1e574c2" have entirely different histories.

3 changed files with 42 additions and 25 deletions

View File

@ -34,6 +34,20 @@
#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,
QWidget *parent) : QGraphicsView(parent)
{
@ -212,7 +226,6 @@ void MapView::addArea(const Area &area)
ai->setOpacity(_areaOpacity);
ai->setDigitalZoom(_digitalZoom);
ai->setVisible(_showAreas);
ai->setZValue(-area.boundingRect().area());
_scene->addItem(ai);
_ar |= ai->bounds();
@ -253,7 +266,6 @@ MapItem *MapView::addMap(MapAction *map)
mi->setOpacity(_areaOpacity);
mi->setDigitalZoom(_digitalZoom);
mi->setVisible(_showAreas);
mi->setZValue(-mi->bounds().area());
_scene->addItem(mi);
_ar |= mi->bounds();
@ -287,6 +299,9 @@ QList<PathItem *> MapView::loadData(const Data &data)
else
updatePOIVisibility();
if (!data.areas().isEmpty())
updateZValues(_areas);
centerOn(contentCenter());
return paths;
@ -304,6 +319,8 @@ void MapView::loadMaps(const QList<MapAction *> &maps)
else
updatePOIVisibility();
updateZValues(_areas);
centerOn(contentCenter());
}
@ -319,6 +336,8 @@ void MapView::loadDEMs(const QList<Area> &dems)
else
updatePOIVisibility();
updateZValues(_areas);
centerOn(contentCenter());
}

View File

@ -30,7 +30,6 @@ public:
return (left() > right()) ? 360.0 - res : res;
}
double height() const {return (top() - bottom());}
double area() const {return qAbs(width()) * qAbs(height());}
double top() const {return _tl.lat();}
double bottom() const {return _br.lat();}

View File

@ -429,42 +429,41 @@ static quint32 readImageInfo(DataStream &stream, Waypoint &waypoint,
return rs + rh.size;
}
static int speed(quint16 flags)
static int speed(quint8 flags)
{
return (((flags >> 3) & 0x0F) * 10) + (((flags >> 2) & 1) * 5);
}
static QString units(quint16 flags)
{
return (flags & (1<<8)) ? "km/h" : "mi/h";
}
static bool portable(quint16 flags)
static bool portable(quint8 flags)
{
return (flags & 1);
}
static bool redLight(quint16 flags)
static QString cameraDesc(quint8 type, quint8 flags)
{
return (flags & (1<<9));
switch (type) {
case 8:
return portable(flags)
? QString("<i>%1&nbsp;mi/h</i>").arg(speed(flags))
: QString("%1&nbsp;mi/h").arg(speed(flags));
case 9:
return portable(flags)
? QString("<i>%1&nbsp;km/h</i>").arg(speed(flags))
: QString("%1&nbsp;km/h").arg(speed(flags));
break;
case 10:
case 11:
return "Red light camera";
}
static QString cameraDesc(quint16 flags)
{
if (redLight(flags))
return "Red light camera";
else {
QString desc(QString::number(speed(flags)) + "&nbsp;" + units(flags));
return portable(flags) ? "<i>" + desc + "<i>" : desc;
}
return QString();
}
static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
QList<Area> &polygons)
{
RecordHeader rh;
quint8 s7, rs;
quint16 flags;
quint8 flags, type, s7, rs;
qint32 top, right, bottom, left, lat, lon;
quint32 ds = 15;
@ -474,7 +473,7 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
right = stream.readInt24();
bottom = stream.readInt24();
left = stream.readInt24();
stream >> flags >> s7;
stream >> flags >> type >> s7;
if (s7) {
quint32 skip = s7 + 2 + s7/4;
@ -495,7 +494,7 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
Area area(RectC(Coordinates(toWGS24(left), toWGS24(top)),
Coordinates(toWGS24(right), toWGS24(bottom))));
area.setDescription(cameraDesc(flags));
area.setDescription(cameraDesc(type, flags));
waypoints.append(Coordinates(toWGS24(lon), toWGS24(lat)));
polygons.append(area);