diff --git a/QRadioPredict/settingsdialog.cpp b/QRadioPredict/settingsdialog.cpp index df60a0f..3e39412 100644 --- a/QRadioPredict/settingsdialog.cpp +++ b/QRadioPredict/settingsdialog.cpp @@ -66,12 +66,12 @@ void SettingsDialog::fillEmptyFields() { this->ui->ITMCheckBox->setChecked(true); } - this->ui->windowXEdit->setText(QString::number(p->_windowX)); - this->ui->windowYEdit->setText(QString::number(p->_windowY)); + this->ui->windowXEdit->setValue(p->_windowX); + this->ui->windowYEdit->setValue(p->_windowY); this->ui->aprsServerEdit->setText(p->_aprs_server); this->ui->aprsSettingsEdit->setText(p->_aprs_settings); - this->ui->aprsRangeEdit->setText(QString::number(p->_aprs_filter_range)); - this->ui->plotRangeEdit->setText(QString::number(p->_plot_range)); + this->ui->aprsRangeEdit->setValue(p->_aprs_filter_range); + this->ui->plotRangeEdit->setValue(p->_plot_range); this->ui->initialLatEdit->setText(QString::number(p->_init_latitude)); this->ui->initialLongEdit->setText(QString::number(p->_init_longitude)); delete p; @@ -81,6 +81,8 @@ void SettingsDialog::fillEmptyFields() void SettingsDialog::saveData() { + qDebug( "Saving Settings" ); + FlightgearPrefs *p = new FlightgearPrefs; p->_fgfs_bin = this->ui->fgfsEdit->text(); p->_fgdata_path= this->ui->fgdataEdit->text(); @@ -129,11 +131,11 @@ void SettingsDialog::saveData() { p->_itm_radio_performance =0; } - p->_windowX = this->ui->windowXEdit->text().toInt(); - p->_windowY = this->ui->windowYEdit->text().toInt(); + p->_windowX = this->ui->windowXEdit->value(); + p->_windowY = this->ui->windowYEdit->value(); p->_aprs_server = this->ui->aprsServerEdit->text(); p->_aprs_settings = this->ui->aprsSettingsEdit->text(); - p->_aprs_filter_range = this->ui->aprsRangeEdit->text().toInt(); + p->_aprs_filter_range = this->ui->aprsRangeEdit->value(); p->_plot_range = this->ui->plotRangeEdit->text().toInt(); p->_init_latitude = this->ui->initialLatEdit->text().toDouble(); p->_init_longitude = this->ui->initialLongEdit->text().toDouble(); @@ -141,3 +143,48 @@ void SettingsDialog::saveData() emit updatePlotDistance(); delete p; } + +void SettingsDialog::chooseDirectory(QString desc,QLineEdit *field){ + QString path = QFileDialog::getExistingDirectory(this, desc, ".", QFileDialog::ReadOnly); + field->setText(path); +} + +void SettingsDialog::chooseFile(QString desc,QLineEdit *field){ + QString path = QFileDialog::getOpenFileName(this, desc, "."); + field->setText(path); +} + +void SettingsDialog::on_fgDataDirDialog_clicked() +{ + chooseDirectory(tr("Flightgear Data Directory"), this->ui->fgdataEdit); +} + +void SettingsDialog::on_sceneryEditDialog_clicked() +{ + chooseDirectory(tr("Scenery Directory"), this->ui->sceneryEdit); +} + +void SettingsDialog::on_srtmPathLineEditDialog_clicked() +{ + chooseDirectory(tr("SRTM Directory"), this->ui->srtmPathLineEdit); +} + +void SettingsDialog::on_shapePathLineEditDialog_clicked() +{ + chooseDirectory(tr("Shapefile Directory"), this->ui->shapePathLineEdit); +} + +void SettingsDialog::on_fgfsEditDialog_clicked() +{ + chooseFile(tr("Flightgear Executable"), this->ui->fgfsEdit); +} + +void SettingsDialog::on_AircraftEditDialog_clicked() +{ + chooseFile(tr("Aircraft "), this->ui->aircraftEdit); +} + +void SettingsDialog::on_airportEditDialog_clicked() +{ + chooseFile(tr("Airport "), this->ui->airportEdit); +} diff --git a/QRadioPredict/settingsdialog.h b/QRadioPredict/settingsdialog.h index 950400c..5aa15c5 100644 --- a/QRadioPredict/settingsdialog.h +++ b/QRadioPredict/settingsdialog.h @@ -19,6 +19,7 @@ #include #include +#include #include "databaseapi.h" namespace Ui { @@ -35,6 +36,20 @@ class SettingsDialog : public QDialog private slots: void saveData(); + void chooseDirectory(QString desc, QLineEdit *field); + void chooseFile(QString desc,QLineEdit *field); + + //buttons for PATH dialog + void on_fgDataDirDialog_clicked(); + void on_sceneryEditDialog_clicked(); + void on_srtmPathLineEditDialog_clicked(); + void on_shapePathLineEditDialog_clicked(); + + //buttons for FILE dialog + void on_fgfsEditDialog_clicked(); + void on_AircraftEditDialog_clicked(); + void on_airportEditDialog_clicked(); + void on_buttonBox_accepted(); signals: void updatePlotDistance(); diff --git a/QRadioPredict/settingsdialog.ui b/QRadioPredict/settingsdialog.ui index 7360cdf..6a00e83 100644 --- a/QRadioPredict/settingsdialog.ui +++ b/QRadioPredict/settingsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 610 - 661 + 630 + 886 @@ -23,8 +23,8 @@ - 30 - 620 + 260 + 830 341 32 @@ -33,7 +33,10 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + false @@ -41,33 +44,72 @@ 20 50 - 580 - 557 + 581 + 754 - - + + - Terrain resolution scaled inversely with distance + Browse... - - + + + + Browse... + + + + + + + Browse... + + + + + + + Browse... + + + + + + + + 75 true + true - FGDATA path + APRS Settings - - + + + + Browse... + + + + + + + Terrain resolution scaled inversely with distance + + + + + 75 @@ -75,21 +117,20 @@ - Shapefile path + FGDATA path - - + + 75 true - true - APRS Settings + Shapefile path @@ -106,6 +147,9 @@ + + + @@ -113,8 +157,12 @@ - - + + + + Qt::DefaultContextMenu + + @@ -123,8 +171,8 @@ - - + + @@ -139,13 +187,10 @@ - - - - - + + - + @@ -170,9 +215,6 @@ - - - @@ -186,8 +228,8 @@ - - + + @@ -218,8 +260,12 @@ - - + + + + + + @@ -247,13 +293,6 @@ - - - - - - - @@ -296,7 +335,10 @@ - + + + + @@ -322,9 +364,6 @@ - - - @@ -338,18 +377,9 @@ - - - - - - - - - @@ -357,6 +387,9 @@ + + + @@ -377,10 +410,10 @@ - - + + - + @@ -405,10 +438,10 @@ - - + + - + @@ -433,8 +466,47 @@ - - + + + + Browse... + + + + + + + Browse... + + + + + + + 10000 + + + + + + + 200 + + + + + + + 10000 + + + + + + + 200 + + diff --git a/QRadioPredict/shpreader.cpp b/QRadioPredict/shpreader.cpp index f627672..f7aa903 100644 --- a/QRadioPredict/shpreader.cpp +++ b/QRadioPredict/shpreader.cpp @@ -208,11 +208,15 @@ QString ShpReader::openShapefile(QString &name, QString &terrain_type) { OGRRegisterAll(); + GDALAllRegister(); + QString file = name; file.append(".shp"); - OGRDataSource *poDS; + GDALDataset *poDS; + + poDS = (GDALDataset *) GDALOpen( file.toStdString().c_str(), GA_ReadOnly ); - poDS = OGRSFDriverRegistrar::Open( file.toStdString().c_str(), FALSE ); + //poDS = OGRSFDriverRegistrar::Open( file.toStdString().c_str(), FALSE, NULL ); if( poDS == NULL ) { qDebug() << "Shapefile opening failed: " << name; @@ -225,7 +229,7 @@ QString ShpReader::openShapefile(QString &name, QString &terrain_type) if(poLayer == NULL) { qDebug() << "Shapefile layer is fubar: " << poLayer->GetName(); - OGRDataSource::DestroyDataSource( poDS ); + GDALClose( poDS ); return QString("None"); } @@ -277,7 +281,7 @@ QString ShpReader::openShapefile(QString &name, QString &terrain_type) qDebug() << "Using GEOS for: " << terrain_type; delete [] buffer; OGRFeature::DestroyFeature( poFeature ); - OGRDataSource::DestroyDataSource( poDS ); + GDALClose( poDS ); return terrain_type; } delete[] buffer; @@ -339,7 +343,7 @@ QString ShpReader::openShapefile(QString &name, QString &terrain_type) if(poly) delete poly; OGRFeature::DestroyFeature( poFeature ); - OGRDataSource::DestroyDataSource( poDS ); + GDALClose( poDS ); return terrain_type; } @@ -373,7 +377,7 @@ QString ShpReader::openShapefile(QString &name, QString &terrain_type) OGRFeature::DestroyFeature( poFeature ); } - OGRDataSource::DestroyDataSource( poDS ); + GDALClose( poDS ); return QString("None"); } diff --git a/QRadioPredict/shpreader.h b/QRadioPredict/shpreader.h index a77f3b4..9e123e8 100644 --- a/QRadioPredict/shpreader.h +++ b/QRadioPredict/shpreader.h @@ -21,8 +21,8 @@ #include #include #include -#include -#include +#include +#include #include "databaseapi.h" #include "flightgearprefs.h" diff --git a/data/DATA.md b/data/DATA.md new file mode 100644 index 0000000..ef63cdf --- /dev/null +++ b/data/DATA.md @@ -0,0 +1,31 @@ +# Data for qRadioPredict + +For the calculation of the propagation model, it is important to have a altitude model of the surroundings. +As such altitude data is not provided as such, we need a source for such a digital elevation model (DEM). +Such data is provided in so called tiles, which cover only a certain area. +Another factor that plays into radio propagation is the land cover. +Eg. wether we have grassland, forest or urban area. + +## Script for getting DEM tiles +The provided script will fetch a whole continent from the shuttle SRTM data. +``` +./get-datafiles.sh -c "Eurasia" +``` +will fetch all tiles for Europe and Asia. + +Valid continents are `North_America`, `South_America`, `Africa`, + `Eurasia`, `Australia` and `Islands` +### Data size +Take care, a whole continent can take up quite a lot of space. +`Eurasia` will take approximately 16GB of diskspace. + +### DEM Sources +Today there are many different provider of such data: +- Shuttle SRTM: http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/ +- Higher Res: http://e4ftl01.cr.usgs.gov/SRTM/SRTMGL1.003/2000.02.11/ +- European DEM: https://www.eea.europa.eu/data-and-maps/data/eu-dem + +## Land Cover Shapefile +The land cover is provided as shapefile by the CIGAR project. +https://www.eea.europa.eu/data-and-maps/data/clc-2006-vector-data-version-2 + diff --git a/data/get-datafiles.sh b/data/get-datafiles.sh new file mode 100755 index 0000000..e360b72 --- /dev/null +++ b/data/get-datafiles.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +# get the SRTM data files and convert them for splat use + +# License: Public domain / CC-0 + +# Takes one parameter: the continent to retrieve. Valid values: +# +# Africa +# Australia +# Eurasia +# Islands +# North_America +# South_America + +# path to topgraphy datafiles +TOPOFILEDIR=./ +# local hgt file archive +HGTFILEDIR=raw-data + + +INDEXFILE=`mktemp` +FILELIST=`mktemp` + +#URLs from where to fetch the tiles +SRTM3URL="http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/" + +#higher res data, currently not implemented +#SRTM1URL="http://e4ftl01.cr.usgs.gov/SRTM/SRTMGL1.003/2000.02.11/" + +#Default options: +CONTINENT=unknown + + +# Check if all prerequisites are installed +if [ ! -x `which wget` ]; then + echo "error: not found in path: wget" + exit 1 +fi + +if [ ! -x `which unzip` ]; then + echo "error: not found in path: unzip" + exit 1 +fi + + +helptext() { +cat <&2 + helptext + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + helptext + exit 1 + ;; + esac +done + + +# Start to download tiles: +echo "getting index.. from $INDEXURL" +wget -q -O - $INDEXURL | \ +sed -r -e '/hgt.zip/!d; s/.* ([NSWE0-9]+\.?hgt\.zip).*$/\1/;' \ +> $FILELIST + +#cp $FILELIST ./filelist + +mkdir -p $HGTFILEDIR +mkdir -p $TOPOFILEDIR + +echo "retrieving files..." +FILECOUNT=`wc -l $FILELIST` + + +echo "Starting processing of ${FILECOUNT} Files" + +for FILE in $(cat $FILELIST); do + echo "Downloading: ${FILE}" + + #TODO maybe check if file already exists in TOPODIR + + #download the tile + wget -P $HGTFILEDIR -nv -N $INDEXURL$FILE + + #direct conversion + echo "Unzip $FILE and then delete zip" + unzip -o $HGTFILEDIR/$FILE -d $TOPOFILEDIR + rm $HGTFILEDIR/$FILE + + # TODO comment for prod: + #break; +done + +#delete tempfiles +#rm $INDEXFILE +#rm $FILELIST + +echo "Complete. The files in $HGTFILEDIR may be removed." diff --git a/data/notes-to-get-data b/data/notes-to-get-data deleted file mode 100644 index cdfd568..0000000 --- a/data/notes-to-get-data +++ /dev/null @@ -1,3 +0,0 @@ -wget http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/North_America/N33W104.hgt.zip; unzip *.zip; rm *.zip - -