Browse Source

Support for regional grids in the LayeredData class.

lintest
Michael Uleysky 12 months ago
parent
commit
d2d516aabb
  1. 20
      src/layereddata.cpp

20
src/layereddata.cpp

@ -139,20 +139,30 @@ std::pair<const BaseParameters*, MString> LayeredData::Parameters(michlib_intern
real lon2 = ToGeoDomain(reg.lone, dom); real lon2 = ToGeoDomain(reg.lone, dom);
real lat1 = reg.latb; real lat1 = reg.latb;
real lat2 = reg.late; real lat2 = reg.late;
bool global = lone - lonb + 1.5 * lonstep > 360.0;
// Special case when the longitude lies in a small sector between the end and the start // Special case when the longitude lies in a small sector between the end and the start
if(global)
{
if(lon1 < lonb) lon1 = lone; if(lon1 < lonb) lon1 = lone;
if(lon2 > lone) lon2 = lonb; if(lon2 > lone) lon2 = lonb;
}
ppar->yb = static_cast<size_t>(Floor((lat1 - latb) / latstep)); else
ppar->ye = static_cast<size_t>(Ceil((lat2 - latb) / latstep)); {
if(ppar->ye > dname.ny - 1) ppar->ye = dname.ny - 1; if(lon1 < lonb) lon1 = lonb;
if(ppar->yb >= ppar->ye) return {nullptr, "Latb must be lesser then late"}; if(lon2 > lone) lon2 = lone;
}
ppar->xb = static_cast<size_t>(Floor((lon1 - lonb) / lonstep)); ppar->xb = static_cast<size_t>(Floor((lon1 - lonb) / lonstep));
ppar->xe = static_cast<size_t>(Ceil((lon2 - lonb) / lonstep)); ppar->xe = static_cast<size_t>(Ceil((lon2 - lonb) / lonstep));
if(ppar->xb == ppar->xe) return {nullptr, "Lonb must be not equal late"}; if(ppar->xb == ppar->xe) return {nullptr, "Lonb must be not equal late"};
if(!global && ppar->xb > ppar->xe) return {nullptr, "Lonb must be lesser then lone"};
ppar->yb = static_cast<size_t>(Floor((lat1 - latb) / latstep));
ppar->ye = static_cast<size_t>(Ceil((lat2 - latb) / latstep));
if(ppar->ye > dname.ny - 1) ppar->ye = dname.ny - 1;
if(ppar->yb >= ppar->ye) return {nullptr, "Latb must be lesser then late"};
if(depth < 0.0 || depth > depths.back()) if(depth < 0.0 || depth > depths.back())
ppar->layer = (depth < 0.0) ? 0 : (depths.size() - 1); ppar->layer = (depth < 0.0) ? 0 : (depths.size() - 1);

Loading…
Cancel
Save