Skip to content
Snippets Groups Projects
Commit 74b51a2b authored by Matti Rauter's avatar Matti Rauter
Browse files

Also accept upperCase and mixedCase strings in grid files

parent 54d15f2f
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,7 @@ Author ...@@ -34,6 +34,7 @@ Author
#include <sstream> #include <sstream>
#include <limits> #include <limits>
#include <cmath> #include <cmath>
#include <algorithm>
// Debugging output // Debugging output
#undef DebugInfo #undef DebugInfo
...@@ -166,6 +167,12 @@ int gridfile::read(const std::string& fname) ...@@ -166,6 +167,12 @@ int gridfile::read(const std::string& fname)
{ {
std::getline(pFile, line); std::getline(pFile, line);
std::transform(line.begin(), line.end(), line.begin(),
[](unsigned char c){ return std::tolower(c); }
); //https://en.cppreference.com/w/cpp/string/byte/tolower
DebugInfo << "line=" << line << std::endl;
std::string::size_type i = std::string::npos; std::string::size_type i = std::string::npos;
if ((i = line.find("ncols")) != std::string::npos) if ((i = line.find("ncols")) != std::string::npos)
...@@ -207,7 +214,7 @@ int gridfile::read(const std::string& fname) ...@@ -207,7 +214,7 @@ int gridfile::read(const std::string& fname)
{ {
this->dy_ = std::stod(line.substr(i + 2)); this->dy_ = std::stod(line.substr(i + 2));
} }
else if ((i = line.find("NODATA_value")) != std::string::npos) else if ((i = line.find("nodata_value")) != std::string::npos)
{ {
this->NODATA_value_ = std::stod(line.substr(i + 12)); this->NODATA_value_ = std::stod(line.substr(i + 12));
readheader = false; readheader = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment