From 74b51a2b5bea58c876429150903d8539e1b66ac8 Mon Sep 17 00:00:00 2001
From: matti <matthias@rauter.it>
Date: Mon, 11 Sep 2023 13:22:09 +0200
Subject: [PATCH] Also accept upperCase and mixedCase strings in grid files

---
 src/avalanche/gistools/gridfile.C | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/avalanche/gistools/gridfile.C b/src/avalanche/gistools/gridfile.C
index 0b77d98..a6e59b2 100644
--- a/src/avalanche/gistools/gridfile.C
+++ b/src/avalanche/gistools/gridfile.C
@@ -34,6 +34,7 @@ Author
 #include <sstream>
 #include <limits>
 #include <cmath>
+#include <algorithm>
 
 // Debugging output
 #undef  DebugInfo
@@ -166,6 +167,12 @@ int gridfile::read(const std::string& fname)
     {
         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;
 
         if ((i = line.find("ncols")) != std::string::npos)
@@ -207,7 +214,7 @@ int gridfile::read(const std::string& fname)
         {
             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));
             readheader = false;
-- 
GitLab