1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-29 18:04:24 +02:00

Compare commits

..

7 Commits

3 changed files with 43 additions and 67 deletions

View File

@ -34,20 +34,6 @@
#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)
{
@ -226,6 +212,7 @@ 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();
@ -266,6 +253,7 @@ 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();
@ -299,9 +287,6 @@ QList<PathItem *> MapView::loadData(const Data &data)
else
updatePOIVisibility();
if (!data.areas().isEmpty())
updateZValues(_areas);
centerOn(contentCenter());
return paths;
@ -319,8 +304,6 @@ void MapView::loadMaps(const QList<MapAction *> &maps)
else
updatePOIVisibility();
updateZValues(_areas);
centerOn(contentCenter());
}
@ -336,8 +319,6 @@ void MapView::loadDEMs(const QList<Area> &dems)
else
updatePOIVisibility();
updateZValues(_areas);
centerOn(contentCenter());
}

View File

@ -30,6 +30,7 @@ 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,27 +429,33 @@ static quint32 readImageInfo(DataStream &stream, Waypoint &waypoint,
return rs + rh.size;
}
static int speed(quint8 flags)
static int speed(quint16 flags)
{
switch (flags >> 4) {
case 0x8:
return 40;
case 0x9:
return 30;
case 0xA:
return 50;
case 0xB:
return 70;
case 0xC:
return 80;
case 0xD:
return 90;
case 0xE:
return 100;
case 0xF:
return 120;
default:
return 0;
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)
{
return (flags & 1);
}
static bool redLight(quint16 flags)
{
return (flags & (1<<9));
}
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;
}
}
@ -457,7 +463,8 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
QList<Area> &polygons)
{
RecordHeader rh;
quint8 flags, type, s7, rs;
quint8 s7, rs;
quint16 flags;
qint32 top, right, bottom, left, lat, lon;
quint32 ds = 15;
@ -467,7 +474,7 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
right = stream.readInt24();
bottom = stream.readInt24();
left = stream.readInt24();
stream >> flags >> type >> s7;
stream >> flags >> s7;
if (s7) {
quint32 skip = s7 + 2 + s7/4;
@ -486,26 +493,11 @@ static quint32 readCamera(DataStream &stream, QVector<Waypoint> &waypoints,
ds += skip + 16;
}
waypoints.append(Coordinates(toWGS24(lon), toWGS24(lat)));
Area area(RectC(Coordinates(toWGS24(left), toWGS24(top)),
Coordinates(toWGS24(right), toWGS24(bottom))));
area.setDescription(cameraDesc(flags));
switch (type) {
case 8:
area.setDescription(QString("%1&nbsp;mi/h")
.arg(speed(flags)));
break;
case 9:
area.setDescription(QString("%1&nbsp;km/h")
.arg(speed(flags)));
break;
case 10:
case 11:
area.setDescription("Red light camera");
break;
}
waypoints.append(Coordinates(toWGS24(lon), toWGS24(lat)));
polygons.append(area);
if (ds > rh.size)
@ -654,13 +646,15 @@ static quint32 readSymbol(DataStream &stream, QPixmap &pixmap)
ds += paletteSize * 4;
}
if (paletteSize) {
img = QImage((uchar*)data.data(), width, height, lineSize,
QImage::Format_Indexed8);
img.setColorTable(palette);
} else
img = QImage((uchar*)data.data(), width, height, lineSize,
QImage::Format_RGBX8888).rgbSwapped();
if (data.size() >= lineSize * height) {
if (paletteSize) {
img = QImage((uchar*)data.data(), width, height, lineSize,
QImage::Format_Indexed8);
img.setColorTable(palette);
} else
img = QImage((uchar*)data.data(), width, height, lineSize,
QImage::Format_RGBX8888).rgbSwapped();
}
pixmap = QPixmap::fromImage(img);
/* There should be no more data left in the record, but broken GPI files