Skip to content

Commit

Permalink
Height files must now be placed in configuration direcotry
Browse files Browse the repository at this point in the history
  • Loading branch information
BourgeoisLab committed Aug 25, 2019
1 parent e087cf4 commit 28b0b30
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 172 deletions.
2 changes: 1 addition & 1 deletion GPXLab/GPXLab.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): cache()

ORGANISATION = BourgeoisLab
TARGET = GPXLab
VERSION = 0.5.0
VERSION = 0.6.0
TEMPLATE = app

DEFINES += ORGANISATION=\\\"$$ORGANISATION\\\" TARGET=\\\"$$TARGET\\\" VERSION=\\\"$$VERSION\\\"
Expand Down
16 changes: 13 additions & 3 deletions GPXLab/dialogs/dialog_srtm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ Dialog_srtm::Dialog_srtm(const GPX_wrapper *gpxmw, QWidget *parent) :
gpxmw(gpxmw)
{
// create new SRTM class
srtm = new SRTM();
QString dir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
srtm = new SRTM();
srtm->setDirectory(dir.toStdString());
QDir tempDir;
tempDir.mkpath(dir);

// setup UI
ui->setupUi(this);
ui->labelDownload->setTextFormat(Qt::RichText);
ui->labelDownload->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->labelDownload->setOpenExternalLinks(true);
ui->labelDownloadLocation->setTextFormat(Qt::RichText);
ui->labelDownloadLocation->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->labelDownloadLocation->setOpenExternalLinks(true);
ui->widgetDownload->setVisible(false);
ui->labelKernelSize->setText(QString::number(ui->horizontalSliderKernelSize->value()));
ui->labelNumPasses->setText(QString::number(ui->horizontalSliderNumPasses->value()));

Expand Down Expand Up @@ -155,8 +163,7 @@ void Dialog_srtm::on_pushButtonFetchData_clicked()
// generate altitude values from SRTM database
if (generateSRTMAltitudeValues(option))
{
ui->labelNotFound->setText("");
ui->labelDownload->setText("");
ui->widgetDownload->setVisible(false);

// average data
for (int n = 0; n < ui->horizontalSliderNumPasses->value(); ++n)
Expand All @@ -172,8 +179,11 @@ void Dialog_srtm::on_pushButtonFetchData_clicked()
else
{
QString url = QString::fromStdString(srtm->getFileURL());
QString dir = QString::fromStdString(srtm->getDirectory());
ui->labelNotFound->setText(tr("Height file not found: ") + QString::fromStdString(srtm->getFileName()));
ui->labelDownload->setText(tr("Download file here: ") + "<a href=\"" + url + "\">" + url + "</a>");
ui->labelDownloadLocation->setText(tr("Unzip and put file here: ") + "<a href=\"" + QUrl::fromLocalFile(dir).toString() + "\">" + dir + "</a>");
ui->widgetDownload->setVisible(true);
}
}

Expand Down
256 changes: 92 additions & 164 deletions GPXLab/dialogs/dialog_srtm.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="title">
<string>Assign SRTM data to points with...</string>
</property>
Expand Down Expand Up @@ -89,18 +77,6 @@
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>70</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>70</height>
</size>
</property>
<property name="title">
<string>Average data</string>
</property>
Expand All @@ -109,18 +85,6 @@
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_3">
<property name="minimumSize">
<size>
<width>110</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>110</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
Expand All @@ -145,18 +109,6 @@
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>70</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>70</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
Expand Down Expand Up @@ -229,18 +181,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>75</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>75</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>Get Data</string>
</property>
Expand All @@ -249,110 +189,98 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelNotFound">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelDownload">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="widgetDownload" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelNotFound">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelDownload">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelDownloadLocation">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
Expand Down
13 changes: 12 additions & 1 deletion GPXLab/functions/srtm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const string SRTM::folders[] = {"", "Eurasia", "North_America", "Australia",
"Islands", "South_America", "Africa"};

SRTM::SRTM(SRTMModel model) :
directory(),
tileSize((int)model),
iLatitude(-1),
iLongitude(-1),
Expand All @@ -41,6 +42,16 @@ SRTM::~SRTM()
delete lookup;
}

string SRTM::getDirectory() const
{
return directory;
}

void SRTM::setDirectory(const string& directory)
{
this->directory = directory;
}

string SRTM::getFileName() const
{
stringstream ss;
Expand Down Expand Up @@ -74,7 +85,7 @@ bool SRTM::parseHGT()
ifstream file;

// open HGT file
file.open(getFileName().c_str());
file.open(directory + "/" + getFileName().c_str());
if (!file)
{
failed = true;
Expand Down
Loading

0 comments on commit 28b0b30

Please sign in to comment.