WSL/SLF GitLab Repository

Commit 3872edb2 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

A bug has been fixed in the Winstral implementation that could lead to...

A bug has been fixed in the Winstral implementation that could lead to infinite loops for very small DEMs.
parent 64127666
......@@ -155,7 +155,8 @@ std::string getCWD()
{
char buffer[MAX_PATH+1];
const DWORD status = GetCurrentDirectoryA(sizeof(buffer), buffer);
if (status==0 || status>MAX_PATH) throw IOException("Can not get current working directory", AT);
if (status==0 || status>MAX_PATH)
throw IOException("Can not get current working directory", AT);
return std::string( buffer );
}
......@@ -201,7 +202,8 @@ void readDirectory(const std::string& path, std::list<std::string>& dirlist, con
std::string getCWD()
{
char buffer[1024];
if ( getcwd(buffer,sizeof(buffer))==NULL ) throw IOException("Can not get current working directory", AT);
if ( getcwd(buffer,sizeof(buffer))==NULL )
throw IOException("Can not get current working directory", AT);
return std::string( buffer );
}
......
......@@ -615,7 +615,6 @@ void Interpol2D::RyanWind(const DEMObject& dem, Grid2DObject& VW, Grid2DObject&
*/
double Interpol2D::getTanMaxSlope(const Grid2DObject& dem, const double& dmin, const double& dmax, const double& bearing, const size_t& i, const size_t& j)
{
//const double dmin = 20.; //cells closer than dmin don't play any role
const double inv_dmin = 1./dmin;
const double inv_dmax = 1./dmax;
const double alpha_rad = bearing*Cst::to_rad;
......@@ -634,13 +633,13 @@ double Interpol2D::getTanMaxSlope(const Grid2DObject& dem, const double& dmin, c
//compute local sx
const double delta_elev = altitude - ref_altitude;
const double inv_distance = Optim::invSqrt( cellsize_sq*(Optim::pow2(ll-ii) + Optim::pow2(mm-jj)) );
if(inv_distance>inv_dmin) continue; //don't consider cells closer than dmin
if(inv_distance<inv_dmax) break; //stop if distance>dmax
if(inv_distance<=inv_dmin) { //only for cells further than dmin
if(inv_distance<inv_dmax) break; //stop if distance>dmax
const double tan_slope = delta_elev*inv_distance;
//update max_tan_sx if necessary. We compare and tan(sx) in order to avoid computing atan()
if( fabs(tan_slope)>fabs(max_tan_slope) ) max_tan_slope = tan_slope;
const double tan_slope = delta_elev*inv_distance;
//update max_tan_sx if necessary. We compare and tan(sx) in order to avoid computing atan()
if( fabs(tan_slope)>fabs(max_tan_slope) ) max_tan_slope = tan_slope;
}
}
//move to next cell
......
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