WSL/SLF GitLab Repository

Commit 79629021 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Still size_t stuff...

parent 3933137d
......@@ -856,7 +856,7 @@ double DEMObject::getCurvature(double A[4][4]) {
count++;
}
if(count != 0.) return 1./count * sum;
if(count != 0.) return 1./(double)count * sum;
}
curvature_failures++;
return IOUtils::nodata;
......@@ -967,15 +967,15 @@ double DEMObject::avgHeight(const double& z1, const double &z2, const double& z3
void DEMObject::getNeighbours(const size_t i, const size_t j, double A[4][4]) {
//this fills a 3x3 table containing the neighboring values
A[1][1] = safeGet(i-1, j+1);
A[1][2] = safeGet(i, j+1);
A[1][3] = safeGet(i+1, j+1);
A[2][1] = safeGet(i-1, j);
A[2][2] = safeGet(i, j);
A[2][3] = safeGet(i+1, j);
A[3][1] = safeGet(i-1, j-1);
A[3][2] = safeGet(i, j-1);
A[3][3] = safeGet(i+1, j-1);
A[1][1] = safeGet((signed)i-1, (signed)j+1);
A[1][2] = safeGet((signed)i, (signed)j+1);
A[1][3] = safeGet((signed)i+1, (signed)j+1);
A[2][1] = safeGet((signed)i-1, (signed)j);
A[2][2] = safeGet((signed)i, (signed)j);
A[2][3] = safeGet((signed)i+1, (signed)j);
A[3][1] = safeGet((signed)i-1, (signed)j-1);
A[3][2] = safeGet((signed)i, (signed)j-1);
A[3][3] = safeGet((signed)i+1, (signed)j-1);
}
double DEMObject::safeGet(const int i, const int j)
......
......@@ -30,8 +30,8 @@ namespace mio {
const Grid2DObject ResamplingAlgorithms2D::BilinearResampling(const Grid2DObject &i_grid, const double &factor)
{
const double cellsize = i_grid.cellsize/factor;
const size_t ncols = (size_t)Optim::round( i_grid.ncols*factor );
const size_t nrows = (size_t)Optim::round( i_grid.nrows*factor );
const size_t ncols = static_cast<size_t>(Optim::round( static_cast<double>(i_grid.ncols)*factor ));
const size_t nrows = static_cast<size_t>(Optim::round( static_cast<double>(i_grid.nrows)*factor ));
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
Bilinear(o_grid, i_grid); //GridObjects always keep nodata
......@@ -41,8 +41,8 @@ const Grid2DObject ResamplingAlgorithms2D::BilinearResampling(const Grid2DObject
const Grid2DObject ResamplingAlgorithms2D::cubicBSplineResampling(const Grid2DObject &i_grid, const double &factor)
{
const double cellsize = i_grid.cellsize/factor;
const size_t ncols = (size_t)Optim::round( i_grid.ncols*factor );
const size_t nrows = (size_t)Optim::round( i_grid.nrows*factor );
const size_t ncols = static_cast<size_t>(Optim::round( static_cast<double>(i_grid.ncols)*factor ));
const size_t nrows = static_cast<size_t>(Optim::round( static_cast<double>(i_grid.nrows)*factor ));
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
cubicBSpline(o_grid, i_grid); //GridObjects always keep nodata
......@@ -52,8 +52,8 @@ const Grid2DObject ResamplingAlgorithms2D::cubicBSplineResampling(const Grid2DOb
const Grid2DObject ResamplingAlgorithms2D::NearestNeighbour(const Grid2DObject &i_grid, const double &factor)
{
const double cellsize = i_grid.cellsize/factor;
const size_t ncols = (size_t)Optim::round( i_grid.ncols*factor );
const size_t nrows = (size_t)Optim::round( i_grid.nrows*factor );
const size_t ncols = static_cast<size_t>(Optim::round( static_cast<double>(i_grid.ncols)*factor ));
const size_t nrows = static_cast<size_t>(Optim::round( static_cast<double>(i_grid.nrows)*factor ));
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
NearestNeighbour(o_grid, i_grid); //GridObjects always keep nodata
......
......@@ -141,8 +141,8 @@ bool FitLeastSquare::computeFit() {
Matrix dLambda; //parameters variations
initDLambda(dLambda);
Matrix A((unsigned int)nPts, (unsigned int)nParam);
Matrix dBeta(nPts,(unsigned int)1);
Matrix A(nPts, nParam);
Matrix dBeta(nPts, (size_t)1);
unsigned int iter = 0;
do {
......
......@@ -352,11 +352,13 @@ void ARCIO::write2DGrid(const Grid2DObject& grid_in, const std::string& name)
fout << "cellsize " << setw(23-9) << setprecision(3) << grid_in.cellsize << "\n";
fout << "NODATA_value " << (int)(IOUtils::nodata) << "\n";
for (unsigned int kk=grid_in.nrows-1; kk < grid_in.nrows; kk--) {
for (unsigned int ll=0; ll < grid_in.ncols; ll++){
fout << grid_in.grid2D(ll, kk) << " ";
if(grid_in.nrows>0) {
for (size_t kk=grid_in.nrows-1; kk < grid_in.nrows; kk--) {
for (size_t ll=0; ll < grid_in.ncols; ll++){
fout << grid_in.grid2D(ll, kk) << " ";
}
fout << "\n";
}
fout << "\n";
}
} catch(...) {
cerr << "[E] error when writing ARC grid \"" << full_name << "\" " << AT << ": "<< endl;
......
......@@ -239,30 +239,32 @@ void GrassIO::write2DGrid(const Grid2DObject& grid_in, const std::string& name)
fout << setprecision(6) << fixed;
try {
fout << "north:" << (llcorner.getNorthing()+grid_in.cellsize*grid_in.nrows) << "\n";
fout << "north:" << (llcorner.getNorthing()+grid_in.cellsize*(double)grid_in.nrows) << "\n";
fout << "south:" << llcorner.getNorthing() << "\n";
fout << "east:" << (llcorner.getEasting()+grid_in.cellsize*grid_in.ncols) << "\n";
fout << "east:" << (llcorner.getEasting()+grid_in.cellsize*(double)grid_in.ncols) << "\n";
fout << "west:" << llcorner.getEasting() << "\n";
fout << "rows:" << grid_in.nrows << "\n";
fout << "cols:" << grid_in.ncols << "\n";
for (unsigned int kk=grid_in.nrows-1; kk < grid_in.nrows; kk--) {
unsigned int ll = 0;
for (ll=0; ll < (grid_in.ncols-1); ll++){
if(grid_in.nrows>0) {
for (size_t kk=grid_in.nrows-1; kk < grid_in.nrows; kk--) {
size_t ll = 0;
for (ll=0; ll < (grid_in.ncols-1); ll++){
if (grid_in.grid2D(ll,kk) == IOUtils::nodata) {
fout << "* ";
} else {
fout << grid_in.grid2D(ll, kk) << " ";
}
}
//The last value in a line does not have a trailing " "
if (grid_in.grid2D(ll,kk) == IOUtils::nodata) {
fout << "* ";
fout << "*";
} else {
fout << grid_in.grid2D(ll, kk) << " ";
fout << grid_in.grid2D(ll, kk);
}
fout << "\n";
}
//The last value in a line does not have a trailing " "
if (grid_in.grid2D(ll,kk) == IOUtils::nodata) {
fout << "*";
} else {
fout << grid_in.grid2D(ll, kk);
}
fout << "\n";
}
} catch(const std::exception& e) {
cerr << "[E] " << AT << ": " << e.what() << std::endl;
......
......@@ -278,15 +278,17 @@ void PGMIO::write2DGrid(const Grid2DObject& grid_in, const std::string& name)
fout << nr_colors << "\n";
//writing the data
for (unsigned int kk=grid_in.nrows-1; kk < grid_in.nrows; kk--) {
for (unsigned int ll=0; ll < grid_in.ncols; ll++) {
const double value = grid_in.grid2D(ll, kk);
if(value!=IOUtils::nodata)
fout << static_cast<unsigned int>( floor((grid_in.grid2D(ll, kk)-min_value)*scaling)+1 ) << " ";
else
fout << "0" << " ";
if(grid_in.nrows>0) {
for (size_t kk=grid_in.nrows-1; kk < grid_in.nrows; kk--) {
for (size_t ll=0; ll < grid_in.ncols; ll++) {
const double value = grid_in.grid2D(ll, kk);
if(value!=IOUtils::nodata)
fout << static_cast<unsigned int>( floor((grid_in.grid2D(ll, kk)-min_value)*scaling)+1 ) << " ";
else
fout << "0" << " ";
}
fout << "\n";
}
fout << "\n";
}
} catch(...) {
cerr << "[E] error when writing PGM grid \"" << full_name << "\" " << AT << ": "<< endl;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment