mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Properly handle IMG basemaps (gmapbmap.img)
This commit is contained in:
parent
f333a76ef7
commit
27edc4d6b5
@ -84,11 +84,13 @@ bool GMAP::loadTile(const QDir &dir, bool baseMap)
|
|||||||
tile->addFile(fi.absoluteFilePath(), tileType(fi.suffix()));
|
tile->addFile(fi.absoluteFilePath(), tileType(fi.suffix()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tile->init(baseMap)) {
|
if (!tile->init()) {
|
||||||
qWarning("%s: Invalid map tile", qPrintable(dir.path()));
|
qWarning("%s: Invalid map tile", qPrintable(dir.path()));
|
||||||
delete tile;
|
delete tile;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (baseMap)
|
||||||
|
tile->markAsBasemap();
|
||||||
|
|
||||||
double min[2], max[2];
|
double min[2], max[2];
|
||||||
min[0] = tile->bounds().left();
|
min[0] = tile->bounds().left();
|
||||||
|
@ -132,11 +132,13 @@ IMG::IMG(const QString &fileName) : _file(fileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create tile tree
|
// Create tile tree
|
||||||
|
|
||||||
|
int minMapZoom = 24;
|
||||||
for (TileMap::const_iterator it = tileMap.constBegin();
|
for (TileMap::const_iterator it = tileMap.constBegin();
|
||||||
it != tileMap.constEnd(); ++it) {
|
it != tileMap.constEnd(); ++it) {
|
||||||
VectorTile *tile = it.value();
|
VectorTile *tile = it.value();
|
||||||
|
|
||||||
if (!tile->init(false)) {
|
if (!tile->init()) {
|
||||||
qWarning("%s: %s: Invalid map tile", qPrintable(_file.fileName()),
|
qWarning("%s: %s: Invalid map tile", qPrintable(_file.fileName()),
|
||||||
qPrintable(it.key()));
|
qPrintable(it.key()));
|
||||||
delete tile;
|
delete tile;
|
||||||
@ -153,6 +155,17 @@ IMG::IMG(const QString &fileName) : _file(fileName)
|
|||||||
_bounds |= tile->bounds();
|
_bounds |= tile->bounds();
|
||||||
if (tile->zooms().min() < _zooms.min())
|
if (tile->zooms().min() < _zooms.min())
|
||||||
_zooms.setMin(tile->zooms().min());
|
_zooms.setMin(tile->zooms().min());
|
||||||
|
if (tile->zooms().min() < minMapZoom)
|
||||||
|
minMapZoom = tile->zooms().min();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (TileMap::const_iterator it = tileMap.constBegin();
|
||||||
|
it != tileMap.constEnd(); ++it) {
|
||||||
|
VectorTile *tile = it.value();
|
||||||
|
if (tile->zooms().min() > minMapZoom)
|
||||||
|
_baseMap = true;
|
||||||
|
if (tile->zooms().min() == minMapZoom)
|
||||||
|
tile->markAsBasemap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_tileTree.Count())
|
if (!_tileTree.Count())
|
||||||
|
@ -42,12 +42,13 @@ TREFile::~TREFile()
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TREFile::init(bool baseMap)
|
bool TREFile::init()
|
||||||
{
|
{
|
||||||
Handle hdl(this);
|
Handle hdl(this);
|
||||||
quint8 locked;
|
quint8 locked;
|
||||||
quint16 hdrLen;
|
quint16 hdrLen;
|
||||||
|
|
||||||
|
|
||||||
if (!(seek(hdl, _gmpOffset) && readUInt16(hdl, hdrLen)
|
if (!(seek(hdl, _gmpOffset) && readUInt16(hdl, hdrLen)
|
||||||
&& seek(hdl, _gmpOffset + 0x0D) && readUInt8(hdl, locked)))
|
&& seek(hdl, _gmpOffset + 0x0D) && readUInt8(hdl, locked)))
|
||||||
return false;
|
return false;
|
||||||
@ -114,7 +115,7 @@ bool TREFile::init(bool baseMap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_isBaseMap = baseMap;
|
_isBaseMap = false;
|
||||||
|
|
||||||
return (_firstLevel >= 0);
|
return (_firstLevel >= 0);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@ public:
|
|||||||
TREFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset) {}
|
TREFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset) {}
|
||||||
~TREFile();
|
~TREFile();
|
||||||
|
|
||||||
bool init(bool baseMap);
|
bool init();
|
||||||
|
void markAsBasemap() {_isBaseMap = true;}
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
const RectC &bounds() const {return _bounds;}
|
const RectC &bounds() const {return _bounds;}
|
||||||
@ -26,7 +27,7 @@ public:
|
|||||||
quint32 shift(quint8 bits) const
|
quint32 shift(quint8 bits) const
|
||||||
{return (bits == _levels.last().bits) ? (_flags >> 0xb) & 7 : 0;}
|
{return (bits == _levels.last().bits) ? (_flags >> 0xb) & 7 : 0;}
|
||||||
Range zooms() const
|
Range zooms() const
|
||||||
{return Range(_levels.first().bits, _levels.last().bits);}
|
{return Range(_levels.at(_firstLevel).bits, _levels.last().bits);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MapLevel {
|
struct MapLevel {
|
||||||
|
@ -82,12 +82,12 @@ SubFile *VectorTile::addFile(const QString &path, SubFile::Type type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VectorTile::init(bool baseMap)
|
bool VectorTile::init()
|
||||||
{
|
{
|
||||||
if (_gmp && !initGMP())
|
if (_gmp && !initGMP())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!(_tre && _tre->init(baseMap) && _rgn))
|
if (!(_tre && _tre->init() && _rgn))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -15,7 +15,8 @@ public:
|
|||||||
delete _tre; delete _rgn; delete _lbl; delete _net; delete _gmp;
|
delete _tre; delete _rgn; delete _lbl; delete _net; delete _gmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool init(bool baseMap);
|
bool init();
|
||||||
|
void markAsBasemap() {_tre->markAsBasemap();}
|
||||||
void clear() {_tre->clear();}
|
void clear() {_tre->clear();}
|
||||||
|
|
||||||
const RectC &bounds() const {return _tre->bounds();}
|
const RectC &bounds() const {return _tre->bounds();}
|
||||||
|
Loading…
Reference in New Issue
Block a user