1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-28 12:09:15 +02:00

Compute the min map zoom from the tiles

This commit is contained in:
2020-02-15 21:49:00 +01:00
parent 42e4b0769f
commit c9b3c2eedd
8 changed files with 19 additions and 10 deletions

View File

@ -98,6 +98,8 @@ bool GMAP::loadTile(const QDir &dir, bool baseMap)
_tileTree.Insert(min, max, tile);
_bounds |= tile->bounds();
if (tile->zooms().min() < _zooms.min())
_zooms.setMin(tile->zooms().min());
return true;
}

View File

@ -151,6 +151,8 @@ IMG::IMG(const QString &fileName) : _file(fileName)
_tileTree.Insert(min, max, tile);
_bounds |= tile->bounds();
if (tile->zooms().min() < _zooms.min())
_zooms.setMin(tile->zooms().min());
}
if (!_tileTree.Count())

View File

@ -54,7 +54,8 @@ inline bool pointCb(VectorTile *tile, void *context)
}
MapData::MapData() : _typ(0), _style(0), _baseMap(false), _valid(false)
MapData::MapData() : _typ(0), _style(0), _zooms(24, 28), _baseMap(false),
_valid(false)
{
_polyCache.setMaxCost(CACHED_SUBDIVS_COUNT);
_pointCache.setMaxCost(CACHED_SUBDIVS_COUNT);

View File

@ -7,6 +7,7 @@
#include <QDebug>
#include "common/rectc.h"
#include "common/rtree.h"
#include "common/range.h"
#include "label.h"
class Style;
@ -58,6 +59,7 @@ public:
const QString &name() const {return _name;}
const RectC &bounds() const {return _bounds;}
const Range &zooms() const {return _zooms;}
const Style *style() const {return _style;}
void polys(const RectC &rect, int bits, QList<Poly> *polygons,
QList<Poly> *lines);
@ -79,6 +81,7 @@ protected:
SubFile *_typ;
Style *_style;
TileTree _tileTree;
Range _zooms;
bool _baseMap;
bool _valid;

View File

@ -57,7 +57,7 @@ bool TREFile::init(bool baseMap)
if (!(seek(hdl, _gmpOffset + 0x15) && readInt24(hdl, north)
&& readInt24(hdl, east) && readInt24(hdl, south) && readInt24(hdl, west)))
return false;
_bounds = RectC(Coordinates(toWGS24(west), toWGS24(north)),
_bounds = RectC(Coordinates(toWGS24(west), qMin(toWGS24(north), 85.11)),
Coordinates(RB(east), toWGS24(south)));
Q_ASSERT(_bounds.left() <= _bounds.right());

View File

@ -25,6 +25,8 @@ public:
QList<SubDiv*> subdivs(const RectC &rect, int bits, bool baseMap);
quint32 shift(quint8 bits) const
{return (bits == _levels.last().bits) ? (_flags >> 0xb) & 7 : 0;}
Range zooms() const
{return Range(_levels.first().bits, _levels.last().bits);}
private:
struct MapLevel {

View File

@ -19,6 +19,7 @@ public:
void clear() {_tre->clear();}
const RectC &bounds() const {return _tre->bounds();}
Range zooms() const {return _tre->zooms();}
SubFile *file(SubFile::Type type);
SubFile *addFile(IMG *img, SubFile::Type type);