From 3b50dff9059c35cbc9b33886039955bda379db78 Mon Sep 17 00:00:00 2001 From: nwagenbrenner Date: Wed, 14 Aug 2024 08:36:40 -0600 Subject: [PATCH 01/12] fix typo in GUI About --- src/gui/mainWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index 4b3c23aa..688280d7 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -1224,7 +1224,7 @@ void mainWindow::aboutWindNinja() aboutText.append("

Developed by:

Jason Forthofer
" \ "Kyle Shannon
" \ "Natalie Wagenbrenner
" \ - "Bret Butler
" \ + "Bret Butler
"); \ aboutText.append("

Missoula Fire Sciences Laboratory
"); aboutText.append("Rocky Mountain Research Station
"); aboutText.append("USDA Forest Service
"); From 6a7d54a37706d8b80e2330056d980c9fa764541a Mon Sep 17 00:00:00 2001 From: nwagenbrenner Date: Wed, 14 Aug 2024 08:37:27 -0600 Subject: [PATCH 02/12] add PHONE_HOME_QUERIES_ENABLED check in NinjaInitialize --- src/ninja/ninja_init.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ninja/ninja_init.cpp b/src/ninja/ninja_init.cpp index 41c24ba4..1599df49 100644 --- a/src/ninja/ninja_init.cpp +++ b/src/ninja/ninja_init.cpp @@ -215,12 +215,13 @@ int NinjaInitialize(const char* typeofrun) { GDALAllRegister(); OGRRegisterAll(); + /* ** Silence warnings and errors in initialize. Sometimes we can't dial out, ** but that doesn't mean we are in trouble. */ CPLPushErrorHandler(CPLQuietErrorHandler); - int rc = 0; + int rc = 0; /* ** Setting the CURL_CA_BUNDLE variable through GDAL doesn't seem to work, ** but could be investigated in the future. CURL_CA_BUNDLE can only be set in GDAL @@ -239,17 +240,15 @@ int NinjaInitialize(const char* typeofrun) { char* dt = asctime(gmtm); std::string cpp_string(dt); - std::string url = "https://ninjastorm.firelab.org/sqlitetest/?time="; cpp_string.erase(std::remove_if(cpp_string.begin(), cpp_string.end(), ::isspace), cpp_string.end()); - std::string full = url + cpp_string + "&runtype=" + typeofrun; - const char *charStr = full.data(); +#ifdef PHONE_HOME_QUERIES_ENABLED CPLHTTPResult *poResult; CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES"); char **papszOptions = NULL; @@ -266,9 +265,8 @@ int NinjaInitialize(const char* typeofrun) { CPLHTTPDestroyResult(poResult); } +#endif } - - #ifdef WIN32 CPLDebug( "WINDNINJA", "Setting GDAL_DATA..." ); From 7e8731d3049646c7abb762c723be890e1aea8dcc Mon Sep 17 00:00:00 2001 From: nwagenbrenner Date: Wed, 14 Aug 2024 11:08:56 -0600 Subject: [PATCH 03/12] return right away if we can't reach ninjastorm server --- src/ninja/ninja_init.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ninja/ninja_init.cpp b/src/ninja/ninja_init.cpp index 1599df49..55d77d11 100644 --- a/src/ninja/ninja_init.cpp +++ b/src/ninja/ninja_init.cpp @@ -79,6 +79,11 @@ char * NinjaQueryServerMessages(bool checkAbort) { CPLHTTPResult *poResult = NULL; try{ CPLHTTPResult *poResult = CPLHTTPFetch(url, NULL); + if( !poResult || poResult->nStatus != 0 || poResult->nDataLen == 0 ) + { + CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); + return NULL; + } if (poResult != NULL) { const char* pszTextContent = reinterpret_cast(poResult->pabyData); @@ -131,12 +136,8 @@ char * NinjaQueryServerMessages(bool checkAbort) { std::cout << "can't fetch" << std::endl; } return NULL; - } - - - void NinjaCheckThreddsData( void *rc ) { int *r; From f63d31ffb9875019427e5589cdc9b307466b8e6f Mon Sep 17 00:00:00 2001 From: RuiZhang Date: Wed, 14 Aug 2024 11:45:17 -0600 Subject: [PATCH 04/12] ninjastorm server and offline fix final --- src/ninja/ninja_init.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ninja/ninja_init.cpp b/src/ninja/ninja_init.cpp index 55d77d11..27c00c18 100644 --- a/src/ninja/ninja_init.cpp +++ b/src/ninja/ninja_init.cpp @@ -256,16 +256,23 @@ int NinjaInitialize(const char* typeofrun) { // Fetch the URL with custom headers try { - poResult = CPLHTTPFetch(charStr, papszOptions); + poResult = CPLHTTPFetch(charStr, papszOptions); + if( !poResult || poResult->nStatus != 0 || poResult->nDataLen == 0 ) + { + CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); + return NULL; + } + else { + if (poResult) { + CPLHTTPDestroyResult(poResult); + + } + } } catch (std::exception& e) { std::cout << "can't fetch" << std::endl; } - if (poResult) { - CPLHTTPDestroyResult(poResult); - - } #endif } From c548561839da790ce0270327badb37bba9e590e2 Mon Sep 17 00:00:00 2001 From: nwagenbrenner Date: Wed, 14 Aug 2024 15:16:13 -0600 Subject: [PATCH 05/12] move phone home check so time zone, etc. is still set properly without internet --- src/ninja/ninja_init.cpp | 119 +++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 62 deletions(-) diff --git a/src/ninja/ninja_init.cpp b/src/ninja/ninja_init.cpp index 27c00c18..91cdd0b1 100644 --- a/src/ninja/ninja_init.cpp +++ b/src/ninja/ninja_init.cpp @@ -126,14 +126,14 @@ char * NinjaQueryServerMessages(bool checkAbort) { std::string resultingmessage = oss.str(); char* returnString = new char[resultingmessage.length() + 1]; - std::strcpy(returnString, resultingmessage.c_str()); + char returnString[resultingmessage.length() + 1]; CPLHTTPDestroyResult(poResult); return returnString; } } catch (std::exception& e) { - std::cout << "can't fetch" << std::endl; + CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); } return NULL; } @@ -211,9 +211,8 @@ int NinjaInitialize(const char *pszGdalData, const char *pszWindNinjaData) ** Initialize global singletons and environments. */ -int NinjaInitialize(const char* typeofrun) { - - +int NinjaInitialize(const char* typeofrun) +{ GDALAllRegister(); OGRRegisterAll(); @@ -223,6 +222,7 @@ int NinjaInitialize(const char* typeofrun) { */ CPLPushErrorHandler(CPLQuietErrorHandler); int rc = 0; + /* ** Setting the CURL_CA_BUNDLE variable through GDAL doesn't seem to work, ** but could be investigated in the future. CURL_CA_BUNDLE can only be set in GDAL @@ -232,50 +232,6 @@ int NinjaInitialize(const char* typeofrun) { */ CPLSetConfigOption( "GDAL_HTTP_UNSAFESSL", "YES"); - if (strcmp(typeofrun, "") != 0) { - - time_t now = time(0); - - // convert now to tm struct for UTC - tm *gmtm = gmtime(&now); - char* dt = asctime(gmtm); - std::string cpp_string(dt); - - std::string url = "https://ninjastorm.firelab.org/sqlitetest/?time="; - cpp_string.erase(std::remove_if(cpp_string.begin(), cpp_string.end(), ::isspace), - cpp_string.end()); - - std::string full = url + cpp_string + "&runtype=" + typeofrun; - - const char *charStr = full.data(); - -#ifdef PHONE_HOME_QUERIES_ENABLED - CPLHTTPResult *poResult; - CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES"); - char **papszOptions = NULL; - - // Fetch the URL with custom headers - try { - poResult = CPLHTTPFetch(charStr, papszOptions); - if( !poResult || poResult->nStatus != 0 || poResult->nDataLen == 0 ) - { - CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); - return NULL; - } - else { - if (poResult) { - CPLHTTPDestroyResult(poResult); - - } - } - } - catch (std::exception& e) { - std::cout << "can't fetch" << std::endl; - } - -#endif - } - #ifdef WIN32 CPLDebug( "WINDNINJA", "Setting GDAL_DATA..." ); std::string osGdalData; @@ -319,25 +275,64 @@ int NinjaInitialize(const char* typeofrun) { CPLFree( (void*)pszExecPath ); #endif /* defined(NINJAFOAM) && defined(FIRELAB_PACKAGE)*/ +#endif /* defined(WIN32) */ -#endif + /* + ** Set windninja data if it isn't set. + */ + if (!CSLTestBoolean(CPLGetConfigOption("WINDNINJA_DATA", "FALSE"))) { + std::string osDataPath; + osDataPath = FindDataPath("tz_world.zip"); + if (osDataPath != "") { + CPLSetConfigOption("WINDNINJA_DATA", CPLGetPath(osDataPath.c_str())); + } + } + globalTimeZoneDB.load_from_file(FindDataPath("date_time_zonespec.csv")); + CPLPopErrorHandler(); +#ifdef PHONE_HOME_QUERIES_ENABLED + if (strcmp(typeofrun, "") != 0) { + time_t now = time(0); -/* -** Set windninja data if it isn't set. -*/ -if (!CSLTestBoolean(CPLGetConfigOption("WINDNINJA_DATA", "FALSE"))) { - std::string osDataPath; - osDataPath = FindDataPath("tz_world.zip"); - if (osDataPath != "") { - CPLSetConfigOption("WINDNINJA_DATA", CPLGetPath(osDataPath.c_str())); - } -} + // convert now to tm struct for UTC + tm *gmtm = gmtime(&now); + char* dt = asctime(gmtm); + std::string cpp_string(dt); + + std::string url = "https://ninjastorm.firelab.org/sqlitetest/?time="; + cpp_string.erase(std::remove_if(cpp_string.begin(), cpp_string.end(), ::isspace), + cpp_string.end()); + std::string full = url + cpp_string + "&runtype=" + typeofrun; + + const char *charStr = full.data(); + + CPLHTTPResult *poResult; + CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES"); + char **papszOptions = NULL; + + // Fetch the URL with custom headers + try { + poResult = CPLHTTPFetch(charStr, papszOptions); + if( !poResult || poResult->nStatus != 0 || poResult->nDataLen == 0 ) + { + CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); + return 0; + } + else { + if (poResult) { + CPLHTTPDestroyResult(poResult); + } + } + } + catch (std::exception& e) { + CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); + return 0; + } + } +#endif - globalTimeZoneDB.load_from_file(FindDataPath("date_time_zonespec.csv")); - CPLPopErrorHandler(); return 0; } From 740cc27a7c60e454b60bd9dfc71dba2d4b3b03ba Mon Sep 17 00:00:00 2001 From: "RuiyuZhang.SD" <134260297+RuiZhang-kwf8@users.noreply.github.com> Date: Wed, 14 Aug 2024 15:31:44 -0600 Subject: [PATCH 06/12] fix valgrind memory leak --- src/gui/mainWindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index 688280d7..262710dd 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -125,15 +125,17 @@ void mainWindow::checkMessages(void) { if (strcmp(papszMsg, "TRUE\n") == 0) { mbox.setText("There is a fatal flaw in Windninja, it must close."); mbox.exec(); + delete[] papszMsg; abort(); } - + else { char *papszMsg = NinjaQueryServerMessages(false); if (papszMsg != NULL) { mbox.setText(papszMsg); mbox.exec(); + delete[] papszMsg; } } } From 2e2b4e47efeb5d7c4b6549f0b7167fc5ad3f6fc2 Mon Sep 17 00:00:00 2001 From: nwagenbrenner Date: Wed, 14 Aug 2024 15:31:54 -0600 Subject: [PATCH 07/12] fix typo --- src/ninja/ninja_init.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ninja/ninja_init.cpp b/src/ninja/ninja_init.cpp index 91cdd0b1..581ea265 100644 --- a/src/ninja/ninja_init.cpp +++ b/src/ninja/ninja_init.cpp @@ -126,7 +126,6 @@ char * NinjaQueryServerMessages(bool checkAbort) { std::string resultingmessage = oss.str(); char* returnString = new char[resultingmessage.length() + 1]; - char returnString[resultingmessage.length() + 1]; CPLHTTPDestroyResult(poResult); return returnString; From 24c333802ad297db8adfc4e172f7113835aa7332 Mon Sep 17 00:00:00 2001 From: "RuiyuZhang.SD" <134260297+RuiZhang-kwf8@users.noreply.github.com> Date: Wed, 14 Aug 2024 15:51:30 -0600 Subject: [PATCH 08/12] update --- src/ninja/ninja_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ninja/ninja_init.cpp b/src/ninja/ninja_init.cpp index 581ea265..c9fb38ab 100644 --- a/src/ninja/ninja_init.cpp +++ b/src/ninja/ninja_init.cpp @@ -126,7 +126,7 @@ char * NinjaQueryServerMessages(bool checkAbort) { std::string resultingmessage = oss.str(); char* returnString = new char[resultingmessage.length() + 1]; - + std::strcpy(returnString, resultingmessage.c_str()); CPLHTTPDestroyResult(poResult); return returnString; } From 6acd6a94b6e0077dd0eeb5f29447b53dd17af35d Mon Sep 17 00:00:00 2001 From: latwood Date: Wed, 14 Aug 2024 19:11:32 -0600 Subject: [PATCH 09/12] minor changes to the Windows build example config files. Most of it was text edits for consistency in appearance, but cli_pointInitialization_diurnal.cfg and cli_wxModelInitialization_diurnal.cfg also had a small correction to the windows elevation file path, example-files vs example_files. Also a few additions to the cli_momentumSolver_diurnal.cfg that aid in quicker testing on windows. --- data/cli_domainAverage.cfg | 4 ++-- data/cli_domainAverage_diurnal.cfg | 6 +++--- data/cli_momentumSolver_diurnal.cfg | 7 ++++--- data/cli_pointInitialization_diurnal.cfg | 4 ++-- data/cli_wxModelInitialization_diurnal.cfg | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/data/cli_domainAverage.cfg b/data/cli_domainAverage.cfg index ae17216b..ecc532da 100644 --- a/data/cli_domainAverage.cfg +++ b/data/cli_domainAverage.cfg @@ -11,8 +11,8 @@ num_threads = 1 # data file location if using Windows -#elevation_file = ../etc/windninja/example-files/missoula_valley.tif -#data file location if using Linux (adjust as needed) +#elevation_file = ../etc/windninja/example-files/missoula_valley.tif +# data file location if using Linux (adjust as needed) elevation_file = ../../../windninja/data/missoula_valley.tif initialization_method = domainAverageInitialization input_speed = 10.0 diff --git a/data/cli_domainAverage_diurnal.cfg b/data/cli_domainAverage_diurnal.cfg index 22e0e4ef..9dab180d 100644 --- a/data/cli_domainAverage_diurnal.cfg +++ b/data/cli_domainAverage_diurnal.cfg @@ -8,9 +8,9 @@ # num_threads = 1 -#data file location for Windows -#elevation_file = ../etc/windninja/example-files/missoula_valley.tif -#data file location for Linux (adjust as needed) +# data file location for Windows +#elevation_file = ../etc/windninja/example-files/missoula_valley.tif +# data file location for Linux (adjust as needed) elevation_file = ../../../windninja/data/missoula_valley.tif initialization_method = domainAverageInitialization time_zone = America/Denver diff --git a/data/cli_momentumSolver_diurnal.cfg b/data/cli_momentumSolver_diurnal.cfg index 52cd1a42..9d66a5a6 100644 --- a/data/cli_momentumSolver_diurnal.cfg +++ b/data/cli_momentumSolver_diurnal.cfg @@ -6,15 +6,16 @@ # num_threads = 1 +#num_threads = 4 # data file location for Windows -# elevation_file = ../etc/windninja/example-files/missoula_valley.tif -# +#elevation_file = ../etc/windninja/example-files/missoula_valley.tif # data file location for Linux (adjust as needed) elevation_file = ../../../windninja/data/missoula_valley.tif initialization_method = domainAverageInitialization momentum_flag = true number_of_iterations = 2000 -mesh_choice = fine +mesh_choice = coarse +#mesh_choice = fine time_zone = America/Denver input_speed = 10.0 input_speed_units = mph diff --git a/data/cli_pointInitialization_diurnal.cfg b/data/cli_pointInitialization_diurnal.cfg index a29745db..a21b7fba 100644 --- a/data/cli_pointInitialization_diurnal.cfg +++ b/data/cli_pointInitialization_diurnal.cfg @@ -8,8 +8,8 @@ # num_threads = 1 -#data file location if using Windows -# elevation_file = ../etc/windninja/example_files/missoula_valley.tif +# data file location if using Windows +#elevation_file = ../etc/windninja/example-files/missoula_valley.tif # data file location if using Linux (adjust as needed) elevation_file = ../../../windninja/data/missoula_valley.tif initialization_method = pointInitialization diff --git a/data/cli_wxModelInitialization_diurnal.cfg b/data/cli_wxModelInitialization_diurnal.cfg index b4c67c73..b109242c 100644 --- a/data/cli_wxModelInitialization_diurnal.cfg +++ b/data/cli_wxModelInitialization_diurnal.cfg @@ -8,8 +8,8 @@ # num_threads = 1 -#data file location if using Windows -# elevation_file = ../etc/windninja/example_files/missoula_valley.tif +# data file location if using Windows +#elevation_file = ../etc/windninja/example-files/missoula_valley.tif # data file location if using Linux (adjust as needed) elevation_file = ../../../windninja/data/missoula_valley.tif initialization_method = wxModelInitialization From 383805ee8634a8c013b4c2c372891fb4bb5e1a79 Mon Sep 17 00:00:00 2001 From: nwagenbrenner Date: Thu, 15 Aug 2024 10:01:23 -0600 Subject: [PATCH 10/12] update credits --- CREDITS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CREDITS.md b/CREDITS.md index 16030306..632d38f4 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -4,5 +4,6 @@ ### Special Thanks - OpenFOAM Foundation -- MesoWest/SynopticLabs +- Synoptic Data PBC +- OpenTopography - High Performance Computing Applications for Science and Engineering, Universitat Autònoma de Barcelona From 2ff1d4119852950fa08f6af051cb34eec93fd0f9 Mon Sep 17 00:00:00 2001 From: nwagenbrenner Date: Thu, 15 Aug 2024 10:38:17 -0600 Subject: [PATCH 11/12] cleanup --- src/ninja/ninja_init.cpp | 124 ++++++++++++++++++--------------------- 1 file changed, 56 insertions(+), 68 deletions(-) diff --git a/src/ninja/ninja_init.cpp b/src/ninja/ninja_init.cpp index c9fb38ab..3385f2e5 100644 --- a/src/ninja/ninja_init.cpp +++ b/src/ninja/ninja_init.cpp @@ -74,66 +74,61 @@ bool NinjaCheckVersions(char * mostrecentversion, char * localversion) { } -char * NinjaQueryServerMessages(bool checkAbort) { +char * NinjaQueryServerMessages(bool checkAbort) +{ + CPLSetConfigOption( "GDAL_HTTP_TIMEOUT", "5" ); const char* url = "https://ninjastorm.firelab.org/sqlitetest/messages.txt"; - CPLHTTPResult *poResult = NULL; - try{ - CPLHTTPResult *poResult = CPLHTTPFetch(url, NULL); - if( !poResult || poResult->nStatus != 0 || poResult->nDataLen == 0 ) - { - CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); - return NULL; - } + CPLSetConfigOption( "GDAL_HTTP_TIMEOUT", NULL ); + CPLHTTPResult *poResult = CPLHTTPFetch(url, NULL); + if( !poResult || poResult->nStatus != 0 || poResult->nDataLen == 0 ) + { + CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); + return NULL; + } - if (poResult != NULL) { - const char* pszTextContent = reinterpret_cast(poResult->pabyData); - std::vector messages; - std::istringstream iss(pszTextContent); - std::string message; + const char* pszTextContent = reinterpret_cast(poResult->pabyData); + std::vector messages; + std::istringstream iss(pszTextContent); + std::string message; - // Read all lines into the vector - while (std::getline(iss, message)) { - messages.push_back(message); - } + // Read all lines into the vector + while (std::getline(iss, message)) { + messages.push_back(message); + } - // Process all lines except the last two - std::ostringstream oss; - if (checkAbort) { - for (size_t i = 0; i < messages.size(); ++i) { - if (i == messages.size()-1) { // check final line - oss << messages[i] << "\n"; - } - } + // Process all lines except the last two + std::ostringstream oss; + if (checkAbort) { + for (size_t i = 0; i < messages.size(); ++i) { + if (i == messages.size()-1) { // check final line + oss << messages[i] << "\n"; } - else { - bool versionisuptodate = NinjaCheckVersions(const_cast(messages[1].c_str()), const_cast(NINJA_VERSION_STRING)); - if (!versionisuptodate) { - oss << messages[0] << "\n"; - oss << "You are using an outdated WindNinja version, please update to version: " << messages[1] << "\n" << "\n"; - } - - if (messages[4].empty() == false) { - for (size_t i = 3; i < messages.size() - 2; ++i) { - if (!messages[i].empty()) { - oss << messages[i] << "\n"; - } - } - } - if (messages[4].empty() && versionisuptodate) { - return NULL; + } + } + else { + bool versionisuptodate = NinjaCheckVersions(const_cast(messages[1].c_str()), const_cast(NINJA_VERSION_STRING)); + if (!versionisuptodate) { + oss << messages[0] << "\n"; + oss << "You are using an outdated WindNinja version, please update to version: " << messages[1] << "\n" << "\n"; + } + if (messages[4].empty() == false) { + for (size_t i = 3; i < messages.size() - 2; ++i) { + if (!messages[i].empty()) { + oss << messages[i] << "\n"; } } - - std::string resultingmessage = oss.str(); - char* returnString = new char[resultingmessage.length() + 1]; - std::strcpy(returnString, resultingmessage.c_str()); - CPLHTTPDestroyResult(poResult); - return returnString; + } + if (messages[4].empty() && versionisuptodate) { + return NULL; } } - catch (std::exception& e) { - CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); - } + + std::string resultingmessage = oss.str(); + char* returnString = new char[resultingmessage.length() + 1]; + std::strcpy(returnString, resultingmessage.c_str()); + CPLHTTPDestroyResult(poResult); + return returnString; + return NULL; } @@ -183,7 +178,6 @@ int NinjaInitialize(const char *pszGdalData, const char *pszWindNinjaData) GDALAllRegister(); OGRRegisterAll(); - if(!CPLCheckForFile(CPLStrdup(CPLFormFilename(CPLStrdup(pszGdalData), "gdalicon.png", NULL)), NULL)) { CPLDebug("WINDNINJA", "Invalid path for GDAL_DATA: %s", pszGdalData); @@ -246,7 +240,6 @@ int NinjaInitialize(const char* typeofrun) CPLDebug("WINDNINJA", "Setting GDAL_DRIVER_PATH: %s", pszPlugins); CPLSetConfigOption("GDAL_DRIVER_PATH", pszPlugins); - #endif /* defined(FIRELAB_PACKAGE) */ #if defined(NINJAFOAM) && defined(FIRELAB_PACKAGE) @@ -309,27 +302,22 @@ int NinjaInitialize(const char* typeofrun) const char *charStr = full.data(); CPLHTTPResult *poResult; - CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES"); char **papszOptions = NULL; + CPLSetConfigOption( "GDAL_HTTP_TIMEOUT", "5" ); // Fetch the URL with custom headers - try { - poResult = CPLHTTPFetch(charStr, papszOptions); - if( !poResult || poResult->nStatus != 0 || poResult->nDataLen == 0 ) - { - CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); - return 0; - } - else { - if (poResult) { - CPLHTTPDestroyResult(poResult); - } - } - } - catch (std::exception& e) { + poResult = CPLHTTPFetch(charStr, papszOptions); + CPLSetConfigOption( "GDAL_HTTP_TIMEOUT", NULL ); + if( !poResult || poResult->nStatus != 0 || poResult->nDataLen == 0 ) + { CPLDebug( "NINJA", "Failed to reach the ninjastorm server." ); return 0; } + else { + if (poResult) { + CPLHTTPDestroyResult(poResult); + } + } } #endif From 3160589b67bac308efd587fac2f4270fbf291ab2 Mon Sep 17 00:00:00 2001 From: nwagenbrenner Date: Thu, 15 Aug 2024 10:40:57 -0600 Subject: [PATCH 12/12] update NEWS --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 737ed3d9..dd427472 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,9 @@ WindNinja 3.11.0 - Added additional time zones from Python timezone finder - Disabled automatic output buffering unless the FARSITE/FlamMap atmosphere file is written (#511) + +- Re-enable server communications (#295, #450, #481) + WindNinja 3.10.0 --------------- - Update CLI documentation, example cfg files, and test data (#415, #434, #270, #252)