diff --git a/src/map/IMG/gmap.cpp b/src/map/IMG/gmap.cpp index 0641169a..4e16bb60 100644 --- a/src/map/IMG/gmap.cpp +++ b/src/map/IMG/gmap.cpp @@ -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; } diff --git a/src/map/IMG/img.cpp b/src/map/IMG/img.cpp index f729bc95..7b577e3c 100644 --- a/src/map/IMG/img.cpp +++ b/src/map/IMG/img.cpp @@ -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()) diff --git a/src/map/IMG/mapdata.cpp b/src/map/IMG/mapdata.cpp index c5944c8a..ce0a48fb 100644 --- a/src/map/IMG/mapdata.cpp +++ b/src/map/IMG/mapdata.cpp @@ -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); diff --git a/src/map/IMG/mapdata.h b/src/map/IMG/mapdata.h index 423c24ec..eaeb1d15 100644 --- a/src/map/IMG/mapdata.h +++ b/src/map/IMG/mapdata.h @@ -7,6 +7,7 @@ #include #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 *polygons, QList *lines); @@ -79,6 +81,7 @@ protected: SubFile *_typ; Style *_style; TileTree _tileTree; + Range _zooms; bool _baseMap; bool _valid; diff --git a/src/map/IMG/trefile.cpp b/src/map/IMG/trefile.cpp index 6854cbf0..66685213 100644 --- a/src/map/IMG/trefile.cpp +++ b/src/map/IMG/trefile.cpp @@ -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()); diff --git a/src/map/IMG/trefile.h b/src/map/IMG/trefile.h index d3869748..2e252f73 100644 --- a/src/map/IMG/trefile.h +++ b/src/map/IMG/trefile.h @@ -25,6 +25,8 @@ public: QList 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 { diff --git a/src/map/IMG/vectortile.h b/src/map/IMG/vectortile.h index c446c5e0..26f27ac5 100644 --- a/src/map/IMG/vectortile.h +++ b/src/map/IMG/vectortile.h @@ -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); diff --git a/src/map/imgmap.cpp b/src/map/imgmap.cpp index 5ea914b7..9be288f9 100644 --- a/src/map/imgmap.cpp +++ b/src/map/imgmap.cpp @@ -79,8 +79,6 @@ private: }; -static const Range zooms(12, 28); - static const QColor shieldColor(Qt::white); static const QColor shieldBgColor1("#dd3e3e"); static const QColor shieldBgColor2("#379947"); @@ -243,7 +241,7 @@ IMGMap::IMGMap(const QString &fileName, QObject *parent) return; } - _zoom = zooms.min(); + _zoom = _data->zooms().min(); updateTransform(); _valid = true; @@ -271,8 +269,8 @@ int IMGMap::zoomFit(const QSize &size, const RectC &rect) if (rect.isValid()) { RectD pr(rect, _projection, 10); - _zoom = zooms.min(); - for (int i = zooms.min() + 1; i <= zooms.max(); i++) { + _zoom = _data->zooms().min(); + for (int i = _data->zooms().min() + 1; i <= _data->zooms().max(); i++) { Transform t(transform(i)); QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight())); if (size.width() < r.width() || size.height() < r.height()) @@ -280,7 +278,7 @@ int IMGMap::zoomFit(const QSize &size, const RectC &rect) _zoom = i; } } else - _zoom = zooms.max(); + _zoom = _data->zooms().max(); updateTransform(); @@ -289,14 +287,14 @@ int IMGMap::zoomFit(const QSize &size, const RectC &rect) int IMGMap::zoomIn() { - _zoom = qMin(_zoom + 1, zooms.max()); + _zoom = qMin(_zoom + 1, _data->zooms().max()); updateTransform(); return _zoom; } int IMGMap::zoomOut() { - _zoom = qMax(_zoom - 1, zooms.min()); + _zoom = qMax(_zoom - 1, _data->zooms().min()); updateTransform(); return _zoom; }