Skip to content

Commit

Permalink
Fix #2844
Browse files Browse the repository at this point in the history
  • Loading branch information
StasJ committed Jan 12, 2022
1 parent eb5f3a4 commit 39ffcd2
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions apps/vaporgui/MainForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,23 +559,27 @@ template<class T> bool MainForm::isDatasetValidFormat(const std::vector<std::str

bool MainForm::determineDatasetFormat(const std::vector<std::string> &paths, std::string *fmt) const
{
if (isDatasetValidFormat<VDCNetCDF>(paths))
*fmt = "vdc";
else if (isDatasetValidFormat<DCWRF>(paths))
*fmt = "wrf";
else if (isDatasetValidFormat<DCMPAS>(paths))
*fmt = "mpas";
else if (isDatasetValidFormat<DCP>(paths))
*fmt = "dcp";
else if (isDatasetValidFormat<DCUGRID>(paths))
*fmt = "ugrid";
else if (isDatasetValidFormat<DCCF>(paths))
*fmt = "cf";
else if (isDatasetValidFormat<DCBOV>(paths))
*fmt = "bov";
else
return false;
return true;
vector<pair<string, bool>> formats = {
{"vdc", isDatasetValidFormat<VDCNetCDF>(paths)},
{"wrf", isDatasetValidFormat<DCWRF>(paths)},
{"mpas", isDatasetValidFormat<DCMPAS>(paths)},
{"dcp", isDatasetValidFormat<DCP>(paths)},
{"ugrid", isDatasetValidFormat<DCUGRID>(paths)},
{"cf", isDatasetValidFormat<DCCF>(paths)},
{"bov", isDatasetValidFormat<DCBOV>(paths)},
};

int nOk = 0;
for (auto &f : formats) {
if (f.second) {
nOk++;
*fmt = f.first;
}
}
if (nOk == 1)
return true;
MyBase::SetErrMsg("Unable to confidently determine the dataset format. Please load it manually in the GUI");
return false;
}

void MainForm::CheckForUpdates()
Expand Down

0 comments on commit 39ffcd2

Please sign in to comment.