diff --git a/pragaProject/pragaProject.cpp b/pragaProject/pragaProject.cpp index 856b22cc0..dc447925c 100644 --- a/pragaProject/pragaProject.cpp +++ b/pragaProject/pragaProject.cpp @@ -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(); @@ -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 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; +} diff --git a/pragaProject/pragaProject.h b/pragaProject/pragaProject.h index 295063b7a..dc0aeb36d 100644 --- a/pragaProject/pragaProject.h +++ b/pragaProject/pragaProject.h @@ -49,7 +49,9 @@ void deleteSynchWidget(); public: + QString projectPragaFolder; QList users; + gis::Crit3DRasterGrid dataRaster; Crit3DDailyMeteoMaps* pragaDailyMaps; PragaHourlyMeteoMaps* pragaHourlyMaps; @@ -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; @@ -91,6 +98,9 @@ bool loadPragaProject(QString myFileName); bool loadPragaSettings(); + void closeOutputMeteoPointsDB(); + bool loadOutputMeteoPointsDB(QString fileName); + gis::Crit3DRasterGrid* getPragaMapFromVar(meteoVariable myVar); bool downloadDailyDataArkimet(QList variables, bool prec0024, QDate startDate, QDate endDate, bool showInfo); diff --git a/project/project.cpp b/project/project.cpp index 5db163a0a..93d146337 100644 --- a/project/project.cpp +++ b/project/project.cpp @@ -1124,6 +1124,7 @@ bool Project::loadMeteoPointsDB(QString fileName) return true; } + bool Project::loadAggregationDBAsMeteoPoints(QString fileName) { if (fileName == "") return false;