From bc218c9f65dcd338b537417367b3985cfc0a90ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 26 Nov 2017 22:52:50 +0100 Subject: [PATCH] Moved the datums initialization where it belongs --- src/GUI/app.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/GUI/app.h | 2 ++ src/GUI/gui.cpp | 47 ----------------------------------------------- src/GUI/gui.h | 1 - 4 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/GUI/app.cpp b/src/GUI/app.cpp index 38850442..ac08922a 100644 --- a/src/GUI/app.cpp +++ b/src/GUI/app.cpp @@ -6,8 +6,11 @@ #include #include "map/onlinemap.h" #include "map/downloader.h" +#include "map/ellipsoid.h" +#include "map/datum.h" #include "opengl.h" #include "gui.h" +#include "config.h" #include "app.h" @@ -31,6 +34,7 @@ App::App(int &argc, char **argv) : QApplication(argc, argv), QNetworkProxyFactory::setUseSystemConfiguration(true); OnlineMap::setDownloader(new Downloader(this)); OPENGL_SET_SAMPLES(4); + loadDatums(); _gui = new GUI(); } @@ -59,3 +63,47 @@ bool App::event(QEvent *event) return QApplication::event(event); } + +void App::loadDatums() +{ + QString ef, df; + bool ok = false; + + if (QFile::exists(USER_ELLIPSOID_FILE)) + ef = USER_ELLIPSOID_FILE; + else if (QFile::exists(GLOBAL_ELLIPSOID_FILE)) + ef = GLOBAL_ELLIPSOID_FILE; + else + qWarning("No ellipsoids file found."); + + if (QFile::exists(USER_DATUM_FILE)) + df = USER_DATUM_FILE; + else if (QFile::exists(GLOBAL_DATUM_FILE)) + df = GLOBAL_DATUM_FILE; + else + qWarning("No datums file found."); + + if (!ef.isNull() && !df.isNull()) { + if (!Ellipsoid::loadList(ef)) { + if (Ellipsoid::errorLine()) + qWarning("%s: parse error on line %d: %s", qPrintable(ef), + Ellipsoid::errorLine(), qPrintable(Ellipsoid::errorString())); + else + qWarning("%s: %s", qPrintable(ef), qPrintable( + Ellipsoid::errorString())); + } else { + if (!Datum::loadList(df)) { + if (Datum::errorLine()) + qWarning("%s: parse error on line %d: %s", qPrintable(ef), + Datum::errorLine(), qPrintable(Datum::errorString())); + else + qWarning("%s: %s", qPrintable(ef), qPrintable( + Datum::errorString())); + } else + ok = true; + } + } + + if (!ok) + qWarning("Maps based on a datum different from WGS84 won't work."); +} diff --git a/src/GUI/app.h b/src/GUI/app.h index f1477833..f416a237 100644 --- a/src/GUI/app.h +++ b/src/GUI/app.h @@ -18,6 +18,8 @@ protected: bool event(QEvent *event); private: + void loadDatums(); + int &_argc; char **_argv; GUI *_gui; diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index d59dc946..0e689529 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -23,8 +23,6 @@ #include #include #include "data/data.h" -#include "map/ellipsoid.h" -#include "map/datum.h" #include "map/map.h" #include "map/maplist.h" #include "map/emptymap.h" @@ -49,7 +47,6 @@ GUI::GUI() { - loadDatums(); loadMaps(); loadPOIs(); @@ -102,50 +99,6 @@ GUI::~GUI() } } -void GUI::loadDatums() -{ - QString ef, df; - bool ok = false; - - if (QFile::exists(USER_ELLIPSOID_FILE)) - ef = USER_ELLIPSOID_FILE; - else if (QFile::exists(GLOBAL_ELLIPSOID_FILE)) - ef = GLOBAL_ELLIPSOID_FILE; - else - qWarning("No ellipsoids file found."); - - if (QFile::exists(USER_DATUM_FILE)) - df = USER_DATUM_FILE; - else if (QFile::exists(GLOBAL_DATUM_FILE)) - df = GLOBAL_DATUM_FILE; - else - qWarning("No datums file found."); - - if (!ef.isNull() && !df.isNull()) { - if (!Ellipsoid::loadList(ef)) { - if (Ellipsoid::errorLine()) - qWarning("%s: parse error on line %d: %s", qPrintable(ef), - Ellipsoid::errorLine(), qPrintable(Ellipsoid::errorString())); - else - qWarning("%s: %s", qPrintable(ef), qPrintable( - Ellipsoid::errorString())); - } else { - if (!Datum::loadList(df)) { - if (Datum::errorLine()) - qWarning("%s: parse error on line %d: %s", qPrintable(ef), - Datum::errorLine(), qPrintable(Datum::errorString())); - else - qWarning("%s: %s", qPrintable(ef), qPrintable( - Datum::errorString())); - } else - ok = true; - } - } - - if (!ok) - qWarning("Maps based on a datum different from WGS84 won't work."); -} - void GUI::loadMaps() { _ml = new MapList(this); diff --git a/src/GUI/gui.h b/src/GUI/gui.h index e7cc0913..f6db125c 100644 --- a/src/GUI/gui.h +++ b/src/GUI/gui.h @@ -81,7 +81,6 @@ private slots: private: typedef QPair DateRange; - void loadDatums(); void loadMaps(); void loadPOIs(); void closeFiles();