Skip to content
Snippets Groups Projects
Commit b39ae740 authored by Tom Fischer's avatar Tom Fischer Committed by Dmitri Naumov
Browse files

[A/IO/AsciiRasterInterface] Impr. writing ASC data.

parent 475c0bf0
No related branches found
No related tags found
No related merge requests found
...@@ -247,20 +247,23 @@ void AsciiRasterInterface::writeRasterAsASC(GeoLib::Raster const& raster, std::s ...@@ -247,20 +247,23 @@ void AsciiRasterInterface::writeRasterAsASC(GeoLib::Raster const& raster, std::s
std::ofstream out(file_name); std::ofstream out(file_name);
out << "ncols " << nCols << "\n"; out << "ncols " << nCols << "\n";
out << "nrows " << nRows << "\n"; out << "nrows " << nRows << "\n";
auto const default_precision = out.precision();
out.precision(std::numeric_limits<double>::digits10);
out << "xllcorner " << origin[0] << "\n"; out << "xllcorner " << origin[0] << "\n";
out << "yllcorner " << origin[1] << "\n"; out << "yllcorner " << origin[1] << "\n";
out << "cellsize " << header.cell_size << "\n"; out << "cellsize " << header.cell_size << "\n";
out.precision(default_precision);
out << "NODATA_value " << header.no_data << "\n"; out << "NODATA_value " << header.no_data << "\n";
// write data // write data
double const*const elevation(raster.begin()); double const*const elevation(raster.begin());
for (unsigned row(0); row < nRows; ++row) 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(); out.close();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment