QAD::Map:

* add MapViewTileProviderBase - base class for tile server provider
 * migrate OSM to new class
 * add MapTiler provider
 * add offlineMode for MapView
This commit is contained in:
2025-03-18 12:16:10 +03:00
parent bf11ca21c0
commit 347104d512
14 changed files with 494 additions and 150 deletions

View File

@@ -1,7 +1,7 @@
/*
QAD - Qt ADvanced
Ivan Pelipenko peri4ko@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -28,16 +28,18 @@
#include <QWidget>
class OSMDownloader;
class OSMTileCache;
class MapViewTileDownloader;
class MapViewTileProviderBase;
class MapViewTileCache;
class QAD_MAP_EXPORT MapView: public QWidget {
Q_OBJECT
Q_PROPERTY(QPointF center READ center WRITE setCenter)
Q_PROPERTY(double zoom READ getZoom WRITE setZoom)
Q_PROPERTY(bool offlineMode READ isOfflineMode WRITE setOfflineMode)
friend class OSMDownloader;
friend class OSMTileCache;
friend class MapViewTileDownloader;
friend class MapViewTileCache;
friend class MapItemBase;
public:
@@ -61,9 +63,14 @@ public:
QString cachePath() const;
void setCachePath(const QString & p);
void setTileObsoleteTime(int secs);
bool isOfflineMode() const { return is_offline; }
void setOfflineMode(bool yes);
void downloadCurrentView(int target_zoom_level = 17, bool only_new = true);
void setTileObsoleteTime(int secs);
void setTileProvider(MapViewTileProviderBase * p);
MapViewTileProviderBase * tileProvider() const;
void downloadCurrentView(int target_zoom_level = 17, bool only_new = true, int parallel = 1);
protected:
QSize sizeHint() const override { return QSize(200, 200); }
@@ -89,17 +96,17 @@ private:
QPointF mapToNorm(QPoint screen) const;
QPoint mapFromNorm(QPointF norm) const;
OSMDownloader * downloader = nullptr;
OSMTileCache * cache = nullptr;
MapItemBase * hover = nullptr;
QPointF center_ = QPointF(0.5, 0.5);
QPointF last_click_coord = center_;
MapViewTileDownloader * downloader = nullptr;
MapViewTileCache * cache = nullptr;
MapItemBase * hover = nullptr;
QPointF center_ = QPointF(0.5, 0.5);
QPointF last_click_coord = center_;
QPoint press_point, zoom_anchor;
QPixmap background;
QRectF view_rect;
QVector<MapItemBase *> items_;
QBrush brush_tr;
bool is_pan = false, is_downloading = false;
bool is_pan = false, is_downloading = false, is_offline = false;
double zoom_ = 1., scale_ = 1., px2m = 1.;
int zoom_level = 0, tiles_side = 1, max_level = 19;