mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Compute the min map zoom from the tiles
This commit is contained in:
parent
42e4b0769f
commit
c9b3c2eedd
@ -98,6 +98,8 @@ bool GMAP::loadTile(const QDir &dir, bool baseMap)
|
|||||||
_tileTree.Insert(min, max, tile);
|
_tileTree.Insert(min, max, tile);
|
||||||
|
|
||||||
_bounds |= tile->bounds();
|
_bounds |= tile->bounds();
|
||||||
|
if (tile->zooms().min() < _zooms.min())
|
||||||
|
_zooms.setMin(tile->zooms().min());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -151,6 +151,8 @@ IMG::IMG(const QString &fileName) : _file(fileName)
|
|||||||
_tileTree.Insert(min, max, tile);
|
_tileTree.Insert(min, max, tile);
|
||||||
|
|
||||||
_bounds |= tile->bounds();
|
_bounds |= tile->bounds();
|
||||||
|
if (tile->zooms().min() < _zooms.min())
|
||||||
|
_zooms.setMin(tile->zooms().min());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_tileTree.Count())
|
if (!_tileTree.Count())
|
||||||
|
@ -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);
|
_polyCache.setMaxCost(CACHED_SUBDIVS_COUNT);
|
||||||
_pointCache.setMaxCost(CACHED_SUBDIVS_COUNT);
|
_pointCache.setMaxCost(CACHED_SUBDIVS_COUNT);
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
#include "common/rtree.h"
|
#include "common/rtree.h"
|
||||||
|
#include "common/range.h"
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
|
|
||||||
class Style;
|
class Style;
|
||||||
@ -58,6 +59,7 @@ public:
|
|||||||
|
|
||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
const RectC &bounds() const {return _bounds;}
|
const RectC &bounds() const {return _bounds;}
|
||||||
|
const Range &zooms() const {return _zooms;}
|
||||||
const Style *style() const {return _style;}
|
const Style *style() const {return _style;}
|
||||||
void polys(const RectC &rect, int bits, QList<Poly> *polygons,
|
void polys(const RectC &rect, int bits, QList<Poly> *polygons,
|
||||||
QList<Poly> *lines);
|
QList<Poly> *lines);
|
||||||
@ -79,6 +81,7 @@ protected:
|
|||||||
SubFile *_typ;
|
SubFile *_typ;
|
||||||
Style *_style;
|
Style *_style;
|
||||||
TileTree _tileTree;
|
TileTree _tileTree;
|
||||||
|
Range _zooms;
|
||||||
bool _baseMap;
|
bool _baseMap;
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
|
@ -57,7 +57,7 @@ bool TREFile::init(bool baseMap)
|
|||||||
if (!(seek(hdl, _gmpOffset + 0x15) && readInt24(hdl, north)
|
if (!(seek(hdl, _gmpOffset + 0x15) && readInt24(hdl, north)
|
||||||
&& readInt24(hdl, east) && readInt24(hdl, south) && readInt24(hdl, west)))
|
&& readInt24(hdl, east) && readInt24(hdl, south) && readInt24(hdl, west)))
|
||||||
return false;
|
return false;
|
||||||
_bounds = RectC(Coordinates(toWGS24(west), toWGS24(north)),
|
_bounds = RectC(Coordinates(toWGS24(west), qMin(toWGS24(north), 85.11)),
|
||||||
Coordinates(RB(east), toWGS24(south)));
|
Coordinates(RB(east), toWGS24(south)));
|
||||||
Q_ASSERT(_bounds.left() <= _bounds.right());
|
Q_ASSERT(_bounds.left() <= _bounds.right());
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ public:
|
|||||||
QList<SubDiv*> subdivs(const RectC &rect, int bits, bool baseMap);
|
QList<SubDiv*> subdivs(const RectC &rect, int bits, bool baseMap);
|
||||||
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
|
||||||
|
{return Range(_levels.first().bits, _levels.last().bits);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MapLevel {
|
struct MapLevel {
|
||||||
|
@ -19,6 +19,7 @@ public:
|
|||||||
void clear() {_tre->clear();}
|
void clear() {_tre->clear();}
|
||||||
|
|
||||||
const RectC &bounds() const {return _tre->bounds();}
|
const RectC &bounds() const {return _tre->bounds();}
|
||||||
|
Range zooms() const {return _tre->zooms();}
|
||||||
|
|
||||||
SubFile *file(SubFile::Type type);
|
SubFile *file(SubFile::Type type);
|
||||||
SubFile *addFile(IMG *img, SubFile::Type type);
|
SubFile *addFile(IMG *img, SubFile::Type type);
|
||||||
|
@ -79,8 +79,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const Range zooms(12, 28);
|
|
||||||
|
|
||||||
static const QColor shieldColor(Qt::white);
|
static const QColor shieldColor(Qt::white);
|
||||||
static const QColor shieldBgColor1("#dd3e3e");
|
static const QColor shieldBgColor1("#dd3e3e");
|
||||||
static const QColor shieldBgColor2("#379947");
|
static const QColor shieldBgColor2("#379947");
|
||||||
@ -243,7 +241,7 @@ IMGMap::IMGMap(const QString &fileName, QObject *parent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_zoom = zooms.min();
|
_zoom = _data->zooms().min();
|
||||||
updateTransform();
|
updateTransform();
|
||||||
|
|
||||||
_valid = true;
|
_valid = true;
|
||||||
@ -271,8 +269,8 @@ int IMGMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
if (rect.isValid()) {
|
if (rect.isValid()) {
|
||||||
RectD pr(rect, _projection, 10);
|
RectD pr(rect, _projection, 10);
|
||||||
|
|
||||||
_zoom = zooms.min();
|
_zoom = _data->zooms().min();
|
||||||
for (int i = zooms.min() + 1; i <= zooms.max(); i++) {
|
for (int i = _data->zooms().min() + 1; i <= _data->zooms().max(); i++) {
|
||||||
Transform t(transform(i));
|
Transform t(transform(i));
|
||||||
QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight()));
|
QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight()));
|
||||||
if (size.width() < r.width() || size.height() < r.height())
|
if (size.width() < r.width() || size.height() < r.height())
|
||||||
@ -280,7 +278,7 @@ int IMGMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
_zoom = i;
|
_zoom = i;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
_zoom = zooms.max();
|
_zoom = _data->zooms().max();
|
||||||
|
|
||||||
updateTransform();
|
updateTransform();
|
||||||
|
|
||||||
@ -289,14 +287,14 @@ int IMGMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
|
|
||||||
int IMGMap::zoomIn()
|
int IMGMap::zoomIn()
|
||||||
{
|
{
|
||||||
_zoom = qMin(_zoom + 1, zooms.max());
|
_zoom = qMin(_zoom + 1, _data->zooms().max());
|
||||||
updateTransform();
|
updateTransform();
|
||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IMGMap::zoomOut()
|
int IMGMap::zoomOut()
|
||||||
{
|
{
|
||||||
_zoom = qMax(_zoom - 1, zooms.min());
|
_zoom = qMax(_zoom - 1, _data->zooms().min());
|
||||||
updateTransform();
|
updateTransform();
|
||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user