From 2c503a24063d1822bc8157c1110f1cc7222e07f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 17 Feb 2020 09:47:47 +0100 Subject: [PATCH] Enable world basemap projection in web mercator projection --- src/common/rectc.h | 3 +++ src/map/IMG/gmap.cpp | 6 ++++++ src/map/IMG/img.cpp | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/src/common/rectc.h b/src/common/rectc.h index 8ae217ee..848f99d2 100644 --- a/src/common/rectc.h +++ b/src/common/rectc.h @@ -28,6 +28,9 @@ public: double left() const {return _tl.lon();} double right() const {return _br.lon();} + double width() const {return (right() - left());} + double height() const {return (top() - bottom());} + void setLeft(double val) {_tl.rlon() = val;} void setRight(double val) {_br.rlon() = val;} void setTop(double val) {_tl.rlat() = val;} diff --git a/src/map/IMG/gmap.cpp b/src/map/IMG/gmap.cpp index 64a1e512..2fddafae 100644 --- a/src/map/IMG/gmap.cpp +++ b/src/map/IMG/gmap.cpp @@ -1,5 +1,6 @@ #include #include +#include "map/osm.h" #include "vectortile.h" #include "gmap.h" @@ -103,6 +104,11 @@ 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 13c66d2f..3a75dcc4 100644 --- a/src/map/IMG/img.cpp +++ b/src/map/IMG/img.cpp @@ -1,5 +1,6 @@ #include #include +#include "map/osm.h" #include "vectortile.h" #include "img.h" @@ -168,6 +169,11 @@ 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