Skip to content

Commit

Permalink
add output points to pragaProject
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Nov 27, 2023
1 parent 80bcab3 commit 6ff14d3
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
76 changes: 76 additions & 0 deletions pragaProject/pragaProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ void PragaProject::initializePragaProject()
pragaDailyMaps = nullptr;
users.clear();
lastElabTargetisGrid = false;

outputMeteoPointsDbHandler = nullptr;
outputMeteoPointsDbFileName = "";
outputMeteoPointsLoaded = false;
}

void PragaProject::clearPragaProject()
{
if (isProjectLoaded) clearProject();

closeOutputMeteoPointsDB();

users.clear();

dataRaster.clear();
Expand Down Expand Up @@ -3542,3 +3548,73 @@ bool PragaProject::saveLogProceduresGrid(QString nameProc, QDate date)
}
return true;
}


void PragaProject::closeOutputMeteoPointsDB()
{
if (outputMeteoPointsDbHandler != nullptr)
{
delete outputMeteoPointsDbHandler;
outputMeteoPointsDbHandler = nullptr;
}

outputMeteoPointsLoaded = false;
outputPoints.clear();
}


bool PragaProject::loadOutputMeteoPointsDB(QString fileName)
{
if (fileName.isEmpty())
return false;

closeOutputMeteoPointsDB();
errorString = "";
logInfo("Load output meteo points = " + fileName);

QString outputDbName = getCompleteFileName(fileName, PATH_METEOPOINT);
if (! QFile(outputDbName).exists())
{
errorString = "Output meteo points DB does not exists:\n" + outputDbName;
return false;
}

outputMeteoPointsDbHandler = new Crit3DMeteoPointsDbHandler(outputDbName);
if (! outputMeteoPointsDbHandler->error.isEmpty())
{
errorString = "Function loadOutputMeteoPointsDB:\n" + outputDbName
+ "\n" + outputMeteoPointsDbHandler->error;
return false;
}

QList<Crit3DMeteoPoint> listMeteoPoints;
if (! outputMeteoPointsDbHandler->getPropertiesFromDb(listMeteoPoints, gisSettings, errorString))
{
errorString = "Error in reading table 'point_properties'\n" + errorString;
return false;
}

if (listMeteoPoints.empty())
{
errorString = "Missing data in the table 'point_properties'";
return false;
}
// set output points
outputPoints.resize(listMeteoPoints.size());
for (int i=0; i < listMeteoPoints.size(); i++)
{
outputPoints[i].id = listMeteoPoints[i].id;
outputPoints[i].latitude = listMeteoPoints[i].latitude;
outputPoints[i].longitude = listMeteoPoints[i].longitude;
outputPoints[i].utm = listMeteoPoints[i].point.utm;
outputPoints[i].z = listMeteoPoints[i].point.z;
outputPoints[i].active = listMeteoPoints[i].active;
}
listMeteoPoints.clear();

outputMeteoPointsDbFileName = outputDbName;
outputMeteoPointsLoaded = true;
logInfo("Output meteo points DB = " + outputMeteoPointsDbFileName);

return true;
}
12 changes: 11 additions & 1 deletion pragaProject/pragaProject.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
void deleteSynchWidget();

public:
QString projectPragaFolder;
QList<QString> users;

gis::Crit3DRasterGrid dataRaster;
Crit3DDailyMeteoMaps* pragaDailyMaps;
PragaHourlyMeteoMaps* pragaHourlyMaps;
Expand All @@ -71,9 +73,14 @@
Crit3DPointStatisticsWidget* pointStatisticsWidget;
Crit3DHomogeneityWidget* homogeneityWidget;
Crit3DSynchronicityWidget* synchronicityWidget;

std::string synchReferencePoint;

ImportDataXML* importData;
QString projectPragaFolder;

Crit3DMeteoPointsDbHandler* outputMeteoPointsDbHandler;
QString outputMeteoPointsDbFileName;
bool outputMeteoPointsLoaded;

#ifdef NETCDF
NetCDFHandler netCDF;
Expand All @@ -91,6 +98,9 @@
bool loadPragaProject(QString myFileName);
bool loadPragaSettings();

void closeOutputMeteoPointsDB();
bool loadOutputMeteoPointsDB(QString fileName);

gis::Crit3DRasterGrid* getPragaMapFromVar(meteoVariable myVar);

bool downloadDailyDataArkimet(QList<QString> variables, bool prec0024, QDate startDate, QDate endDate, bool showInfo);
Expand Down
1 change: 1 addition & 0 deletions project/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,7 @@ bool Project::loadMeteoPointsDB(QString fileName)
return true;
}


bool Project::loadAggregationDBAsMeteoPoints(QString fileName)
{
if (fileName == "") return false;
Expand Down

0 comments on commit 6ff14d3

Please sign in to comment.