From b39ae740696874c595e0c72f1ecaf92bbb709d45 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Tue, 26 Jan 2021 13:06:39 +0100 Subject: [PATCH] [A/IO/AsciiRasterInterface] Impr. writing ASC data. --- Applications/FileIO/AsciiRasterInterface.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Applications/FileIO/AsciiRasterInterface.cpp b/Applications/FileIO/AsciiRasterInterface.cpp index 6c426a54bb0..0ccbff1fbdd 100644 --- a/Applications/FileIO/AsciiRasterInterface.cpp +++ b/Applications/FileIO/AsciiRasterInterface.cpp @@ -247,20 +247,23 @@ void AsciiRasterInterface::writeRasterAsASC(GeoLib::Raster const& raster, std::s std::ofstream out(file_name); out << "ncols " << nCols << "\n"; out << "nrows " << nRows << "\n"; + auto const default_precision = out.precision(); + out.precision(std::numeric_limits<double>::digits10); out << "xllcorner " << origin[0] << "\n"; out << "yllcorner " << origin[1] << "\n"; out << "cellsize " << header.cell_size << "\n"; + out.precision(default_precision); out << "NODATA_value " << header.no_data << "\n"; // write data double const*const elevation(raster.begin()); for (unsigned row(0); row < nRows; ++row) { - for (unsigned col(0); col < nCols; ++col) + for (unsigned col(0); col < nCols-1; ++col) { - out << elevation[(nRows-row-1) * nCols + col] << " "; + out << elevation[(nRows - row - 1) * nCols + col] << " "; } - out << "\n"; + out << elevation[(nRows - row) * nCols - 1] << "\n"; } out.close(); } -- GitLab