Skip to content

Commit 694950a

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents 6abffb8 + e62c4b8 commit 694950a

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

bin/mainWindow.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7381,7 +7381,30 @@ void MainWindow::on_actionExport_precipitation_for_selected_points_triggered()
73817381
return;
73827382
}
73837383

7384-
//meteoSettings->getRainfallThreshold()
7384+
bool hasSelected = false;
7385+
for (int i = 0; i < myProject.meteoPoints.size(); i++)
7386+
{
7387+
if (myProject.meteoPoints[i].selected)
7388+
{
7389+
hasSelected = true;
7390+
break;
7391+
}
7392+
}
7393+
7394+
if (! hasSelected)
7395+
{
7396+
myProject.logWarning("No Point selected!");
7397+
return;
7398+
}
7399+
7400+
QString outputPath = myProject.getProjectPath() + PATH_OUTPUT;
7401+
QString fileName = QFileDialog::getSaveFileName(this, tr("Output file"), outputPath, tr("CSV (*.csv)"));
7402+
if (fileName.isEmpty())
7403+
return;
7404+
7405+
bool isSelectedPoints = true;
7406+
if (! myProject.exportMeteoPointsHourlyPrecipitation(fileName, isSelectedPoints))
7407+
myProject.logError();
73857408
}
73867409

73877410

src/pragaProject/pragaProject.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6178,6 +6178,31 @@ bool PragaProject::writeMeteoPointsProperties(const QList<QString> &joinedProper
61786178
}
61796179

61806180

6181+
bool PragaProject::exportMeteoPointsHourlyPrecipitation(QString fileName, bool isSelectedPoints)
6182+
{
6183+
QFile myFile(fileName);
6184+
// WriteOnly + Truncate = apre in scrittura e svuota il file se esiste
6185+
if (! myFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
6186+
{
6187+
errorString = "Error opening file.\n" + myFile.errorString();
6188+
return false;
6189+
}
6190+
6191+
QTextStream out(&myFile);
6192+
6193+
for (int i = 0; i < meteoPoints.size(); i++)
6194+
{
6195+
if (!isSelectedPoints || meteoPoints[i].selected)
6196+
{
6197+
out << QString::fromStdString(meteoPoints[i].id) << "\n";
6198+
}
6199+
}
6200+
6201+
myFile.close();
6202+
return true;
6203+
}
6204+
6205+
61816206
bool PragaProject::shiftMeteoPointsData(bool isAllPoints)
61826207
{
61836208
QList<QString> pointList;

src/pragaProject/pragaProject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@
185185

186186
bool shiftMeteoPointsData(bool isAllPoints);
187187

188+
bool exportMeteoPointsHourlyPrecipitation(QString fileName, bool isSelectedPoints);
189+
188190
#ifdef NETCDF
189191
bool exportMeteoGridToNetCDF(QString fileName, QString title, QString variableName, std::string variableUnit, Crit3DDate myDate, int nDays, int refYearStart, int refYearEnd);
190192
bool exportXMLElabGridToNetcdf(QString xmlName);

0 commit comments

Comments
 (0)