|
|
|
@ -139,20 +139,30 @@ std::pair<const BaseParameters*, MString> LayeredData::Parameters(michlib_intern
|
|
|
|
|
real lon2 = ToGeoDomain(reg.lone, dom); |
|
|
|
|
real lat1 = reg.latb; |
|
|
|
|
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
|
|
|
|
|
if(global) |
|
|
|
|
{ |
|
|
|
|
if(lon1 < lonb) lon1 = lone; |
|
|
|
|
if(lon2 > lone) lon2 = lonb; |
|
|
|
|
|
|
|
|
|
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"}; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if(lon1 < lonb) lon1 = lonb; |
|
|
|
|
if(lon2 > lone) lon2 = lone; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ppar->xb = static_cast<size_t>(Floor((lon1 - 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(!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()) |
|
|
|
|
ppar->layer = (depth < 0.0) ? 0 : (depths.size() - 1); |
|
|
|
|