mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-31 17:15:14 +01:00
Added DEM data overview
This commit is contained in:
parent
c43b4060ca
commit
7920f0f245
@ -384,6 +384,9 @@ void GUI::createActions()
|
|||||||
_downloadDEMAction->setEnabled(false);
|
_downloadDEMAction->setEnabled(false);
|
||||||
_downloadDEMAction->setShortcut(DOWNLOAD_DEM_SHORTCUT);
|
_downloadDEMAction->setShortcut(DOWNLOAD_DEM_SHORTCUT);
|
||||||
connect(_downloadDEMAction, &QAction::triggered, this, &GUI::downloadDEM);
|
connect(_downloadDEMAction, &QAction::triggered, this, &GUI::downloadDEM);
|
||||||
|
_showDEMTilesAction = new QAction(tr("Show local DEM tiles"));
|
||||||
|
_showDEMTilesAction->setMenuRole(QAction::NoRole);
|
||||||
|
connect(_showDEMTilesAction, &QAction::triggered, this, &GUI::showDEMTiles);
|
||||||
|
|
||||||
// Graph actions
|
// Graph actions
|
||||||
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
||||||
@ -595,7 +598,7 @@ void GUI::createMenus()
|
|||||||
_poiMenu->addAction(_showPOIAction);
|
_poiMenu->addAction(_showPOIAction);
|
||||||
|
|
||||||
QMenu *demMenu = menuBar()->addMenu(tr("DEM"));
|
QMenu *demMenu = menuBar()->addMenu(tr("DEM"));
|
||||||
demMenu->addSeparator();
|
demMenu->addAction(_showDEMTilesAction);
|
||||||
demMenu->addAction(_downloadDEMAction);
|
demMenu->addAction(_downloadDEMAction);
|
||||||
|
|
||||||
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
|
QMenu *settingsMenu = menuBar()->addMenu(tr("&Settings"));
|
||||||
@ -1730,6 +1733,14 @@ void GUI::demLoaded()
|
|||||||
reloadFiles();
|
reloadFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::showDEMTiles()
|
||||||
|
{
|
||||||
|
_mapView->loadDEMs(DEM::tiles());
|
||||||
|
|
||||||
|
_fileActionGroup->setEnabled(true);
|
||||||
|
_reloadFileAction->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::updateStatusBarInfo()
|
void GUI::updateStatusBarInfo()
|
||||||
{
|
{
|
||||||
if (_files.count() == 0)
|
if (_files.count() == 0)
|
||||||
|
@ -76,6 +76,7 @@ private slots:
|
|||||||
void openOptions();
|
void openOptions();
|
||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
void downloadDEM();
|
void downloadDEM();
|
||||||
|
void showDEMTiles();
|
||||||
|
|
||||||
void mapChanged(QAction *action);
|
void mapChanged(QAction *action);
|
||||||
void graphChanged(int);
|
void graphChanged(int);
|
||||||
@ -234,6 +235,7 @@ private:
|
|||||||
QAction *_showCoordinatesAction;
|
QAction *_showCoordinatesAction;
|
||||||
QAction *_openOptionsAction;
|
QAction *_openOptionsAction;
|
||||||
QAction *_downloadDEMAction;
|
QAction *_downloadDEMAction;
|
||||||
|
QAction *_showDEMTilesAction;
|
||||||
QAction *_mapsEnd;
|
QAction *_mapsEnd;
|
||||||
QAction *_poisEnd;
|
QAction *_poisEnd;
|
||||||
|
|
||||||
|
@ -293,6 +293,23 @@ void MapView::loadMaps(const QList<MapAction *> &maps)
|
|||||||
centerOn(contentCenter());
|
centerOn(contentCenter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::loadDEMs(const QList<Area> &dems)
|
||||||
|
{
|
||||||
|
int zoom = _map->zoom();
|
||||||
|
|
||||||
|
for (int i = 0; i < dems.size(); i++)
|
||||||
|
addArea(dems.at(i));
|
||||||
|
|
||||||
|
if (fitMapZoom() != zoom)
|
||||||
|
rescale();
|
||||||
|
else
|
||||||
|
updatePOIVisibility();
|
||||||
|
|
||||||
|
updateZValues(_areas);
|
||||||
|
|
||||||
|
centerOn(contentCenter());
|
||||||
|
}
|
||||||
|
|
||||||
int MapView::fitMapZoom() const
|
int MapView::fitMapZoom() const
|
||||||
{
|
{
|
||||||
RectC br = _tr | _rr | _wr | _ar;
|
RectC br = _tr | _rr | _wr | _ar;
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
|
|
||||||
QList<PathItem *> loadData(const Data &data);
|
QList<PathItem *> loadData(const Data &data);
|
||||||
void loadMaps(const QList<MapAction*> &maps);
|
void loadMaps(const QList<MapAction*> &maps);
|
||||||
|
void loadDEMs(const QList<Area> &dems);
|
||||||
|
|
||||||
void setPalette(const Palette &palette);
|
void setPalette(const Palette &palette);
|
||||||
void setPOI(POI *poi);
|
void setPOI(POI *poi);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <private/qzipreader_p.h>
|
#include <private/qzipreader_p.h>
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
#include "dem.h"
|
#include "dem.h"
|
||||||
@ -138,6 +139,36 @@ qreal DEM::elevation(const Coordinates &c)
|
|||||||
return height(c, ba);
|
return height(c, ba);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Area> DEM::tiles()
|
||||||
|
{
|
||||||
|
QDir dir(_dir);
|
||||||
|
QFileInfoList files(dir.entryInfoList(QDir::Files | QDir::Readable));
|
||||||
|
QRegularExpression re("([NS])([0-9]{2})([EW])([0-9]{3})");
|
||||||
|
QList<Area> list;
|
||||||
|
|
||||||
|
for (int i = 0; i < files.size(); i++) {
|
||||||
|
QString basename(files.at(i).baseName());
|
||||||
|
QRegularExpressionMatch match(re.match(basename));
|
||||||
|
if (!match.hasMatch())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int lat = match.captured(2).toInt();
|
||||||
|
int lon = match.captured(4).toInt();
|
||||||
|
if (match.captured(1) == "S")
|
||||||
|
lat = -lat;
|
||||||
|
if (match.captured(3) == "W")
|
||||||
|
lon = -lon;
|
||||||
|
|
||||||
|
Area area(RectC(Coordinates(lon, lat + 1), Coordinates(lon + 1, lat)));
|
||||||
|
area.setName(basename);
|
||||||
|
area.setDescription(files.at(i).canonicalFilePath());
|
||||||
|
|
||||||
|
list.append(area);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
QDebug operator<<(QDebug dbg, const DEM::Tile &tile)
|
QDebug operator<<(QDebug dbg, const DEM::Tile &tile)
|
||||||
{
|
{
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QCache>
|
#include <QCache>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
|
#include "area.h"
|
||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
class Coordinates;
|
class Coordinates;
|
||||||
@ -37,6 +38,8 @@ public:
|
|||||||
static void clearCache();
|
static void clearCache();
|
||||||
static qreal elevation(const Coordinates &c);
|
static qreal elevation(const Coordinates &c);
|
||||||
|
|
||||||
|
static QList<Area> tiles();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QString fileName(const QString &baseName);
|
static QString fileName(const QString &baseName);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user