WSL/SLF GitLab Repository

Commit 19c29d0f authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Rounding azimuths to 0.1 and preventing azi=360, prefering azi=0 instead

parent 8bba4407
...@@ -489,30 +489,30 @@ bool convertString(Date& t, const std::string& str, const double& time_zone, std ...@@ -489,30 +489,30 @@ bool convertString(Date& t, const std::string& str, const double& time_zone, std
//extract date/time //extract date/time
const size_t date_beg = s.find_first_of(NUM); const size_t date_beg = s.find_first_of(NUM);
if(date_beg==npos || date_beg==in_len) return false; if (date_beg==npos || date_beg==in_len) return false;
size_t date_end = s.find_first_not_of(NUM, date_beg+1); size_t date_end = s.find_first_not_of(NUM, date_beg+1);
if(date_end==npos) date_end = in_len; if (date_end==npos) date_end = in_len;
const std::string date = s.substr(date_beg, date_end-date_beg); const std::string date = s.substr(date_beg, date_end-date_beg);
//parse date/time //parse date/time
const size_t date_len = date.length(); const size_t date_len = date.length();
if(date_len<10 || date_len>14) return false; if (date_len<10 || date_len>14) return false;
if( convertString(year,date.substr(0,4))==false ) return false; if (convertString(year,date.substr(0,4))==false) return false;
if( convertString(month,date.substr(4,2))==false ) return false; if (convertString(month,date.substr(4,2))==false) return false;
if( convertString(day,date.substr(6,2))==false ) return false; if (convertString(day,date.substr(6,2))==false) return false;
if( convertString(hour,date.substr(8,2))==false ) return false; if (convertString(hour,date.substr(8,2))==false) return false;
if(date_len==10) if (date_len==10)
minute=0; minute=0;
else { else {
if(date_len>=12) { if (date_len>=12) {
if( convertString(minute,date.substr(10,2))==false ) return false; if( convertString(minute,date.substr(10,2))==false ) return false;
} else } else
return false; return false;
if(date_len==12) if (date_len==12)
second=0; second=0;
else { else {
if(date_len==14) { if (date_len==14) {
if( convertString(second,date.substr(12,2))==false ) return false; if (convertString(second,date.substr(12,2))==false) return false;
} else } else
return false; return false;
} }
...@@ -521,9 +521,9 @@ bool convertString(Date& t, const std::string& str, const double& time_zone, std ...@@ -521,9 +521,9 @@ bool convertString(Date& t, const std::string& str, const double& time_zone, std
//extract potential ISO time zone string //extract potential ISO time zone string
double tz = time_zone; double tz = time_zone;
const size_t tz_beg = s.find_first_of("+-", date_end); const size_t tz_beg = s.find_first_of("+-", date_end);
if(tz_beg!=npos && tz_beg!=in_len) { if (tz_beg!=npos && tz_beg!=in_len) {
size_t tz_end = s.find_first_not_of("0123456789:", date_end+1); size_t tz_end = s.find_first_not_of("0123456789:", date_end+1);
if(tz_end==npos) tz_end = in_len; if (tz_end==npos) tz_end = in_len;
const std::string timezone_iso = s.substr(tz_beg, tz_end-tz_beg); const std::string timezone_iso = s.substr(tz_beg, tz_end-tz_beg);
if(!timezone_iso.empty()) tz = Date::parseTimeZone(timezone_iso); if(!timezone_iso.empty()) tz = Date::parseTimeZone(timezone_iso);
} }
......
...@@ -779,17 +779,12 @@ double DEMObject::CalculateAspect(const double& o_Nx, const double& o_Ny, const ...@@ -779,17 +779,12 @@ double DEMObject::CalculateAspect(const double& o_Nx, const double& o_Ny, const
if ( o_slope > 0. ) { //there is some slope if ( o_slope > 0. ) { //there is some slope
if ( o_Nx == 0. ) { //no E-W slope, so it is purely N-S if ( o_Nx == 0. ) { //no E-W slope, so it is purely N-S
if ( o_Ny < 0. ) { const double aspect = (o_Ny < 0.)? 180. : 0.;
return(180.); // south facing return aspect;
} else {
return (0.); // north facing
}
} else { //there is a E-W slope } else { //there is a E-W slope
if ( o_Nx > 0. ) { const double angle_deg = static_cast<double>(Optim::round( atan2(o_Ny, o_Nx)*Cst::to_deg * 10.)) / 10.; //round angle to 0.1
return (90. - atan(o_Ny/o_Nx)*Cst::to_deg); const double aspect = fmod( 90. - angle_deg + 360., 360.); //convert angle to bearing
} else { return aspect;
return (270. - atan(o_Ny/o_Nx)*Cst::to_deg);
}
} }
} else { // if slope = 0 } else { // if slope = 0
return (no_slope); // undefined or plain surface return (no_slope); // undefined or plain surface
......
Markdown is supported
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