From cc766f22b77d6a6055521b0de2e6112f5cdb8293 Mon Sep 17 00:00:00 2001
From: rinkk <karsten.rink@ufz.de>
Date: Thu, 5 Jan 2023 10:52:20 +0100
Subject: [PATCH] added pixel size checks

---
 Applications/FileIO/AsciiRasterInterface.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Applications/FileIO/AsciiRasterInterface.cpp b/Applications/FileIO/AsciiRasterInterface.cpp
index 0d2b0b7e8fc..095ce7bd549 100644
--- a/Applications/FileIO/AsciiRasterInterface.cpp
+++ b/Applications/FileIO/AsciiRasterInterface.cpp
@@ -253,7 +253,6 @@ GeoLib::Raster* AsciiRasterInterface::getRasterFromXyzFile(
         return nullptr;
     }
 
-    //in.open(fname.c_str());
     std::string line("");
     double x_old(0), y_old(0), x(0), y(0), z(0);
     GeoLib::RasterHeader header{0, 0, 1, GeoLib::Point{{0, 0, 0}}, 1, -9999};
@@ -289,10 +288,22 @@ GeoLib::Raster* AsciiRasterInterface::getRasterFromXyzFile(
         values.push_back(z);
         if (x > x_old)
         {
+            if (x - x_old != header.cell_size)
+            {
+                ERR("Varying cellsizes or unordered pixel vales found. "
+                    "Aborting...");
+                return nullptr;
+            }
             n_cols++;
         }
         else //new line
         {
+            if (y - y_old != header.cell_size)
+            {
+                ERR("Varying cellsizes or unordered pixel vales found. "
+                    "Aborting...");
+                return nullptr;
+            }
             n_rows++;
             // define #columns
             if (header.n_cols == 0)
-- 
GitLab