mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-28 12:09:15 +02:00
Improved POI handling in IMG maps
This commit is contained in:
@ -255,3 +255,18 @@ bool IMG::readBlock(int blockNum, QByteArray &data)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug operator<<(QDebug dbg, const IMG::Point &point)
|
||||
{
|
||||
dbg.nospace() << "Point(" << hex << point.type << ", " << point.label
|
||||
<< ", " << point.poi << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug dbg, const IMG::Poly &poly)
|
||||
{
|
||||
dbg.nospace() << "Poly(" << hex << poly.type << ", " << poly.label << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
#endif // QT_NO_DEBUG
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
quint64 id;
|
||||
|
||||
bool operator<(const Point &other) const
|
||||
{return id < other.id;}
|
||||
{return id > other.id;}
|
||||
};
|
||||
|
||||
|
||||
@ -84,4 +84,9 @@ private:
|
||||
QString _errorString;
|
||||
};
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
QDebug operator<<(QDebug dbg, const IMG::Point &point);
|
||||
QDebug operator<<(QDebug dbg, const IMG::Poly &poly);
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
#endif // IMG_H
|
||||
|
@ -338,7 +338,8 @@ bool RGNFile::pointObjects(const RectC &rect, Handle &hdl, const SubDiv *subdiv,
|
||||
point.poi = labelPtr & 0x400000;
|
||||
if (lbl && (labelPtr & 0x3FFFFF)) {
|
||||
point.label = lbl->label(lblHdl, labelPtr & 0x3FFFFF, point.poi);
|
||||
point.id = ((quint64)lbl->offset())<<24 | (labelPtr & 0x3FFFFF);
|
||||
point.id = ((quint64)point.type)<<40 | ((quint64)lbl->offset())<<24
|
||||
| (labelPtr & 0x3FFFFF);
|
||||
}
|
||||
|
||||
points->append(point);
|
||||
@ -383,7 +384,8 @@ bool RGNFile::extPointObjects(const RectC &rect, Handle &hdl,
|
||||
point.poi = labelPtr & 0x400000;
|
||||
if (lbl && (labelPtr & 0x3FFFFF)) {
|
||||
point.label = lbl->label(lblHdl, labelPtr & 0x3FFFFF, point.poi);
|
||||
point.id = ((quint64)lbl->offset())<<24 | (labelPtr & 0x3FFFFF);
|
||||
point.id = ((quint64)point.type)<<40
|
||||
| ((quint64)lbl->offset())<<24 | (labelPtr & 0x3FFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,6 +147,137 @@ void Style::defaultLineStyle()
|
||||
_lines[TYPE(0x29)].setTextFontSize(Style::None);
|
||||
}
|
||||
|
||||
void Style::defaultPOIStyle()
|
||||
{
|
||||
_points[0x2a00] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a01] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a02] = Point(QImage(":/restaurant-noodle-11.png"));
|
||||
_points[0x2a03] = Point(QImage(":/bbq-11.png"));
|
||||
_points[0x2a04] = Point(QImage(":/restaurant-noodle-11.png"));
|
||||
_points[0x2a05] = Point(QImage(":/bakery-11.png"));
|
||||
_points[0x2a06] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a07] = Point(QImage(":/fast-food-11.png"));
|
||||
_points[0x2a08] = Point(QImage(":/restaurant-pizza-11.png"));
|
||||
_points[0x2a09] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a0a] = Point(QImage(":/restaurant-pizza-11.png"));
|
||||
_points[0x2a0b] = Point(QImage(":/restaurant-seafood-11.png"));
|
||||
_points[0x2a0c] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a0d] = Point(QImage(":/bakery-11.png"));
|
||||
_points[0x2a0e] = Point(QImage(":/cafe-11.png"));
|
||||
_points[0x2a0f] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a10] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a11] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a12] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x2a13] = Point(QImage(":/restaurant-11.png"));
|
||||
|
||||
_points[0x2b01] = Point(QImage(":/lodging-11.png"));
|
||||
_points[0x2b02] = Point(QImage(":/lodging-11.png"));
|
||||
_points[0x2b03] = Point(QImage(":/campsite-11.png"));
|
||||
_points[0x2b04] = Point(QImage(":/village-11.png"));
|
||||
_points[0x2b06] = Point(QImage(":/shelter-11.png"));
|
||||
|
||||
_points[0x2c01] = Point(QImage(":/amusement-park-11.png"));
|
||||
_points[0x2c02] = Point(QImage(":/museum-11.png"));
|
||||
_points[0x2c03] = Point(QImage(":/library-11.png"));
|
||||
_points[0x2c04] = Point(QImage(":/landmark-11.png"));
|
||||
_points[0x2c05] = Point(QImage(":/school-11.png"));
|
||||
_points[0x2c06] = Point(QImage(":/garden-11.png"));
|
||||
_points[0x2c07] = Point(QImage(":/zoo-11.png"));
|
||||
_points[0x2c08] = Point(QImage(":/soccer-11.png"));
|
||||
_points[0x2c0a] = Point(QImage(":/bar-11.png"));
|
||||
_points[0x2c0b] = Point(QImage(":/place-of-worship-11.png"));
|
||||
_points[0x2c0d] = Point(QImage(":/religious-muslim-11.png"));
|
||||
_points[0x2c0e] = Point(QImage(":/religious-christian-11.png"));
|
||||
_points[0x2c10] = Point(QImage(":/religious-jewish-11.png"));
|
||||
_points[0x2d01] = Point(QImage(":/theatre-11.png"));
|
||||
_points[0x2d02] = Point(QImage(":/bar-11.png"));
|
||||
_points[0x2d03] = Point(QImage(":/cinema-11.png"));
|
||||
_points[0x2d04] = Point(QImage(":/casino-11.png"));
|
||||
_points[0x2d05] = Point(QImage(":/golf-11.png"));
|
||||
_points[0x2d06] = Point(QImage(":/skiing-11.png"));
|
||||
_points[0x2d07] = Point(QImage(":/bowling-alley-11.png"));
|
||||
_points[0x2d09] = Point(QImage(":/swimming-11.png"));
|
||||
_points[0x2d0a] = Point(QImage(":/fitness-centre-11.png"));
|
||||
_points[0x2d0b] = Point(QImage(":/airfield-11.png"));
|
||||
|
||||
_points[0x2e02] = Point(QImage(":/grocery-11.png"));
|
||||
_points[0x2e05] = Point(QImage(":/pharmacy-11.png"));
|
||||
_points[0x2e07] = Point(QImage(":/clothing-store-11.png"));
|
||||
_points[0x2e08] = Point(QImage(":/garden-centre-11.png"));
|
||||
_points[0x2e09] = Point(QImage(":/furniture-11.png"));
|
||||
_points[0x2e0c] = Point(QImage(":/shop-11.png"));
|
||||
|
||||
_points[0x2f01] = Point(QImage(":/fuel-11.png"));
|
||||
_points[0x2f02] = Point(QImage(":/car-rental-11.png"));
|
||||
_points[0x2f03] = Point(QImage(":/car-repair-11.png"));
|
||||
_points[0x2f04] = Point(QImage(":/airport-11.png"));
|
||||
_points[0x2f05] = Point(QImage(":/post-11.png"));
|
||||
_points[0x2f06] = Point(QImage(":/bank-11.png"));
|
||||
_points[0x2f07] = Point(QImage(":/car-11.png"));
|
||||
_points[0x2f08] = Point(QImage(":/bus-11.png"));
|
||||
_points[0x2f09] = Point(QImage(":/harbor-11.png"));
|
||||
_points[0x2f0b] = Point(QImage(":/parking-11.png"));
|
||||
_points[0x2f0b].setTextFontSize(None);
|
||||
_points[0x2f0c] = Point(QImage(":/toilet-11.png"));
|
||||
_points[0x2f0c].setTextFontSize(None);
|
||||
_points[0x2f10] = Point(QImage(":/hairdresser-11.png"));
|
||||
_points[0x2f12].setTextFontSize(None);
|
||||
_points[0x2f13] = Point(QImage(":/hardware-11.png"));
|
||||
_points[0x2f17] = Point(QImage(":/bus-11.png"));
|
||||
|
||||
_points[0x3001] = Point(QImage(":/police-11.png"));
|
||||
_points[0x3002] = Point(QImage(":/hospital-11.png"));
|
||||
_points[0x3003] = Point(QImage(":/town-hall-11.png"));
|
||||
_points[0x3007] = Point(QImage(":/prison-11.png"));
|
||||
_points[0x3008] = Point(QImage(":/fire-station-11.png"));
|
||||
|
||||
_points[0x4000] = Point(QImage(":/golf-11.png"));
|
||||
_points[0x4300] = Point(QImage(":/harbor-11.png"));
|
||||
_points[0x4400] = Point(QImage(":/fuel-11.png"));
|
||||
_points[0x4500] = Point(QImage(":/restaurant-11.png"));
|
||||
_points[0x4600] = Point(QImage(":/bar-11.png"));
|
||||
_points[0x4900] = Point(QImage(":/park-11.png"));
|
||||
_points[0x4a00] = Point(QImage(":/picnic-site-11.png"));
|
||||
_points[0x4c00] = Point(QImage(":/information-11.png"));
|
||||
_points[0x4800] = Point(QImage(":/campsite-11.png"));
|
||||
_points[0x4a00] = Point(QImage(":/picnic-site-11.png"));
|
||||
_points[0x4b00] = Point(QImage(":/hospital-11.png"));
|
||||
_points[0x4c00] = Point(QImage(":/information-11.png"));
|
||||
_points[0x4d00] = Point(QImage(":/parking-11.png"));
|
||||
_points[0x4d00].setTextFontSize(None);
|
||||
_points[0x4e00] = Point(QImage(":/toilet-11.png"));
|
||||
_points[0x4e00].setTextFontSize(None);
|
||||
_points[0x5000] = Point(QImage(":/drinking-water-11.png"));
|
||||
_points[0x5000].setTextFontSize(None);
|
||||
_points[0x5100] = Point(QImage(":/telephone-11.png"));
|
||||
_points[0x5200] = Point(QImage(":/viewpoint-11.png"));
|
||||
_points[0x5300] = Point(QImage(":/skiing-11.png"));
|
||||
_points[0x5400] = Point(QImage(":/swimming-11.png"));
|
||||
_points[0x5500] = Point(QImage(":/dam-11.png"));
|
||||
_points[0x5700] = Point(QImage(":/danger-11.png"));
|
||||
_points[0x5800] = Point(QImage(":/roadblock-11.png"));
|
||||
_points[0x5900] = Point(QImage(":/airport-11.png"));
|
||||
_points[0x5901] = Point(QImage(":/airport-11.png"));
|
||||
_points[0x5904] = Point(QImage(":/heliport-11.png"));
|
||||
|
||||
_points[0x6401] = Point(QImage(":/bridge-11.png"));
|
||||
_points[0x6402] = Point(QImage(":/building-alt1-11.png"));
|
||||
_points[0x6403] = Point(QImage(":/cemetery-11.png"));
|
||||
_points[0x6404] = Point(QImage(":/religious-christian-11.png"));
|
||||
_points[0x6407] = Point(QImage(":/dam-11.png"));
|
||||
_points[0x6408] = Point(QImage(":/hospital-11.png"));
|
||||
_points[0x6409] = Point(QImage(":/dam-11.png"));
|
||||
_points[0x640d] = Point(QImage(":/communications-tower-11.png"));
|
||||
_points[0x640e] = Point(QImage(":/park-11.png"));
|
||||
_points[0x640f] = Point(QImage(":/post-11.png"));
|
||||
_points[0x6411] = Point(QImage(":/communications-tower-11.png"));
|
||||
|
||||
_points[0x6508] = Point(QImage(":/waterfall-11.png"));
|
||||
_points[0x6513] = Point(QImage(":/wetland-11.png"));
|
||||
_points[0x6604] = Point(QImage(":/beach-11.png"));
|
||||
_points[0x6616] = Point(QImage(":/mountain-11.png"));
|
||||
}
|
||||
|
||||
static bool readBitmap(SubFile *file, SubFile::Handle &hdl, QImage &img,
|
||||
int bpp)
|
||||
{
|
||||
@ -790,6 +921,7 @@ Style::Style(SubFile *typ)
|
||||
{
|
||||
defaultLineStyle();
|
||||
defaultPolygonStyle();
|
||||
defaultPOIStyle();
|
||||
|
||||
if (typ && typ->isValid())
|
||||
parseTYPFile(typ);
|
||||
@ -830,6 +962,32 @@ bool Style::isSpot(quint32 type)
|
||||
return (type == TYPE(0x62) || type == TYPE(0x63));
|
||||
}
|
||||
|
||||
Style::POIClass Style::poiClass(quint32 type)
|
||||
{
|
||||
if ((type >= 0x2a00 && type < 0x2b00) || type == 0x2c0a || type == 0x2d02)
|
||||
return Food;
|
||||
else if (type >= 0x2b00 && type < 0x2c00)
|
||||
return Accommodation;
|
||||
else if (type >= 0x2c00 && type < 0x2e00)
|
||||
return Recreation;
|
||||
else if (type >= 0x2e00 && type < 0x2f00)
|
||||
return Shopping;
|
||||
else if (type >= 0x2f00 && type < 0x2f0f)
|
||||
return Transport;
|
||||
else if (type >= 0x2f0f && type < 0x3000)
|
||||
return Services;
|
||||
else if (type >= 0x3000 && type < 0x3100)
|
||||
return Community;
|
||||
else if (type >= 0x4000 && type < 0x6000)
|
||||
return Elementary;
|
||||
else if (type >= 0x6400 && type < 0x6500)
|
||||
return ManmadePlaces;
|
||||
else if (type >= 0x6500 && type < 0x6700)
|
||||
return NaturePlaces;
|
||||
else
|
||||
return Unknown;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
static QString penColor(const QPen &pen)
|
||||
{
|
||||
|
@ -18,6 +18,20 @@ public:
|
||||
Large = 4
|
||||
};
|
||||
|
||||
enum POIClass {
|
||||
Unknown,
|
||||
Food,
|
||||
Accommodation,
|
||||
Recreation,
|
||||
Shopping,
|
||||
Transport,
|
||||
Services,
|
||||
Community,
|
||||
Elementary,
|
||||
ManmadePlaces,
|
||||
NaturePlaces
|
||||
};
|
||||
|
||||
class Polygon {
|
||||
public:
|
||||
Polygon() : _brush(Qt::NoBrush), _pen(Qt::NoPen) {}
|
||||
@ -91,6 +105,7 @@ public:
|
||||
|
||||
static bool isContourLine(quint32 type);
|
||||
static bool isSpot(quint32 type);
|
||||
static POIClass poiClass(quint32 type);
|
||||
|
||||
private:
|
||||
struct Section {
|
||||
@ -121,6 +136,7 @@ private:
|
||||
const Section §ion, ItemInfo &info);
|
||||
void defaultPolygonStyle();
|
||||
void defaultLineStyle();
|
||||
void defaultPOIStyle();
|
||||
|
||||
QMap<quint32, Line> _lines;
|
||||
QMap<quint32, Polygon> _polygons;
|
||||
|
@ -25,8 +25,6 @@
|
||||
#define POI_FONT_SIZE 9
|
||||
|
||||
#define LINE_TEXT_MIN_ZOOM 23
|
||||
#define POI_MIN_ZOOM 25
|
||||
#define POI_TEXT_MIN_ZOOM 26
|
||||
|
||||
class RasterTile
|
||||
{
|
||||
@ -76,6 +74,26 @@ static void convertUnits(QString &str)
|
||||
str = QString::number(qRound(number * 0.3048));
|
||||
}
|
||||
|
||||
static int minPOIZoom(Style::POIClass cl)
|
||||
{
|
||||
switch (cl) {
|
||||
case Style::Food:
|
||||
case Style::Shopping:
|
||||
case Style::Services:
|
||||
return 27;
|
||||
case Style::Accommodation:
|
||||
case Style::Recreation:
|
||||
return 25;
|
||||
case Style::ManmadePlaces:
|
||||
case Style::NaturePlaces:
|
||||
case Style::Transport:
|
||||
case Style::Community:
|
||||
case Style::Elementary:
|
||||
return 23;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
IMGMap::IMGMap(const QString &fileName, QObject *parent)
|
||||
: Map(parent), _fileName(fileName), _img(fileName),
|
||||
@ -280,17 +298,20 @@ void IMGMap::drawPoints(QPainter *painter, QList<IMG::Point> &points)
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
IMG::Point &point = points[i];
|
||||
const Style::Point &style = _img.style().point(point.type);
|
||||
int mz = minPOIZoom(Style::poiClass(point.type));
|
||||
|
||||
if (point.poi && _zoom < POI_MIN_ZOOM)
|
||||
if (point.poi && _zoom < mz)
|
||||
continue;
|
||||
|
||||
const QString *label = ((point.poi && _zoom < POI_TEXT_MIN_ZOOM)
|
||||
|| point.label.isEmpty()) ? 0 : &(point.label);
|
||||
const QString *label = point.label.isEmpty() ? 0 : &(point.label);
|
||||
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
||||
const QFont *font = 0;
|
||||
if (point.poi)
|
||||
font = &_poiFont;
|
||||
else {
|
||||
if (point.poi) {
|
||||
if (style.textFontSize() == Style::None)
|
||||
label = 0;
|
||||
else
|
||||
font = &_poiFont;
|
||||
} else {
|
||||
switch (style.textFontSize()) {
|
||||
case Style::None:
|
||||
label = 0;
|
||||
|
Reference in New Issue
Block a user