Skip to content

Commit 9d91fe1

Browse files
authored
Merge pull request #590 from firelab/improve-WINDNINJA_DATA-warnings
Improvement to WINDNINJA_DATA warnings and error messages tested, and the code doesn't break windows builds
2 parents 1025fcd + b14dd02 commit 9d91fe1

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/ninja/ninja_init.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,19 @@ int NinjaInitialize(const char* typeofrun)
299299
/*
300300
** Set windninja data if it isn't set.
301301
*/
302-
if (!CSLTestBoolean(CPLGetConfigOption("WINDNINJA_DATA", "FALSE"))) {
302+
std::string wnDataPath = CPLGetConfigOption("WINDNINJA_DATA", "FALSE");
303+
if( !CPLCheckForFile((char*)CPLFormFilename(wnDataPath.c_str(),"tz_world.zip",NULL), NULL) )
304+
{
305+
CPLDebug( "WINDNINJA", "WINDNINJA_DATA \"%s\" is not valid, attempting to find valid WINDNINJA_DATA", wnDataPath.c_str() );
303306
std::string osDataPath;
304307
osDataPath = FindDataPath("tz_world.zip");
305-
if (osDataPath != "") {
308+
if (osDataPath != "")
309+
{
310+
CPLDebug( "WINDNINJA", "found WINDNINJA_DATA \"%s\"", CPLGetPath(osDataPath.c_str()) );
306311
CPLSetConfigOption("WINDNINJA_DATA", CPLGetPath(osDataPath.c_str()));
312+
} else
313+
{
314+
throw std::runtime_error("no valid WINDNINJA_DATA found, please set valid WINDNINJA_DATA");
307315
}
308316
}
309317

src/ninja/ninjafoam.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ bool NinjaFoam::simulate_wind()
132132
foamVersion = CPLGetConfigOption("WM_PROJECT_VERSION", "");
133133
#endif
134134
CPLDebug("NINJAFOAM", CPLSPrintf("foamVersion = \"%s\"",foamVersion.c_str()));
135-
135+
136+
std::string pszWnDataPath = CPLGetConfigOption( "WINDNINJA_DATA", NULL );
137+
if( !CPLCheckForFile((char*)CPLFormFilename(pszWnDataPath.c_str(),"tz_world.zip",NULL), NULL) )
138+
{
139+
throw std::runtime_error("invalid WINDNINJA_DATA path for ninjafoam.");
140+
}
141+
136142
if(CSLTestBoolean(CPLGetConfigOption("WRITE_TURBULENCE", "FALSE")))
137143
{
138144
CPLDebug("NINJAFOAM", "Writing turbulence output...");

0 commit comments

Comments
 (0)