From 08334d7fdef24ab0d396ed0ca19ca8f9d405f11c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 19 Apr 2020 11:36:17 +0200 Subject: [PATCH] Move the world maps bounds limit hack to the propper place --- src/map/IMG/gmap.cpp | 6 ------ src/map/IMG/img.cpp | 6 ------ src/map/imgmap.cpp | 10 ++++++++-- src/map/imgmap.h | 1 + 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/map/IMG/gmap.cpp b/src/map/IMG/gmap.cpp index 2fddafae..64a1e512 100644 --- a/src/map/IMG/gmap.cpp +++ b/src/map/IMG/gmap.cpp @@ -1,6 +1,5 @@ #include #include -#include "map/osm.h" #include "vectortile.h" #include "gmap.h" @@ -104,11 +103,6 @@ bool GMAP::loadTile(const QDir &dir, bool baseMap) if (tile->zooms().min() < _zooms.min()) _zooms.setMin(tile->zooms().min()); - // Limit world maps bounds so that the maps can be projected using - // the default Web Mercator projection - if (_bounds.height() > 120) - _bounds &= OSM::BOUNDS; - return true; } diff --git a/src/map/IMG/img.cpp b/src/map/IMG/img.cpp index 3a75dcc4..13c66d2f 100644 --- a/src/map/IMG/img.cpp +++ b/src/map/IMG/img.cpp @@ -1,6 +1,5 @@ #include #include -#include "map/osm.h" #include "vectortile.h" #include "img.h" @@ -169,11 +168,6 @@ IMG::IMG(const QString &fileName) : _file(fileName) tile->markAsBasemap(); } - // Limit world maps bounds so that the maps can be projected using - // the default Web Mercator projection - if (_bounds.height() > 120) - _bounds &= OSM::BOUNDS; - if (!_tileTree.Count()) _errorString = "No usable map tile found"; else diff --git a/src/map/imgmap.cpp b/src/map/imgmap.cpp index 40e7d17b..c881474f 100644 --- a/src/map/imgmap.cpp +++ b/src/map/imgmap.cpp @@ -16,6 +16,7 @@ #include "IMG/style.h" #include "IMG/img.h" #include "IMG/gmap.h" +#include "osm.h" #include "pcs.h" #include "rectd.h" #include "imgmap.h" @@ -244,6 +245,11 @@ IMGMap::IMGMap(const QString &fileName, QObject *parent) return; } + // Limit world maps bounds so that the maps can be projected using + // the default Web Mercator projection + _dataBounds = (_data->bounds().height() > 120) + ? _data->bounds() & OSM::BOUNDS : _data->bounds(); + _zoom = _data->zooms().min(); updateTransform(); @@ -305,7 +311,7 @@ Transform IMGMap::transform(int zoom) const { double scale = _projection.isGeographic() ? 360.0 / (1<bounds().topLeft())); + PointD topLeft(_projection.ll2xy(_dataBounds.topLeft())); return Transform(ReferencePoint(PointD(0, 0), topLeft), PointD(scale, scale)); } @@ -314,7 +320,7 @@ void IMGMap::updateTransform() { _transform = transform(_zoom); - RectD prect(_data->bounds(), _projection); + RectD prect(_dataBounds, _projection); _bounds = QRectF(_transform.proj2img(prect.topLeft()), _transform.proj2img(prect.bottomRight())); } diff --git a/src/map/imgmap.h b/src/map/imgmap.h index 1618fe36..a8e66b30 100644 --- a/src/map/imgmap.h +++ b/src/map/imgmap.h @@ -63,6 +63,7 @@ private: Projection _projection; Transform _transform; QRectF _bounds; + RectC _dataBounds; bool _valid; QString _errorString;