Browse Source

Fixed a bug when the longitude lies in a small sector between the end and start

interpolate
Michael Uleysky 2 years ago
parent
commit
c79edbbaef
  1. 4
      src/AVISOLOCAL.cpp
  2. 4
      src/layereddata.cpp

4
src/AVISOLOCAL.cpp

@ -183,6 +183,10 @@ template<class DataType> AVISOLOCALData::Data AVISOLOCALData::ReadVarRaw(const N
real lat1 = p->latb; real lat1 = p->latb;
real lat2 = p->late; real lat2 = p->late;
// Special case when the longitude lies in a small sector between the end and the start
if(lon1 < lonb) lon1 = lone;
if(lon2 > lone) lon2 = lonb;
auto yb = static_cast<size_t>(Floor((lat1 - latb) / latstep)); auto yb = static_cast<size_t>(Floor((lat1 - latb) / latstep));
auto ye = static_cast<size_t>(Ceil((lat2 - latb) / latstep)); auto ye = static_cast<size_t>(Ceil((lat2 - latb) / latstep));
if(ye > dn.ny - 1) ye = dn.ny - 1; if(ye > dn.ny - 1) ye = dn.ny - 1;

4
src/layereddata.cpp

@ -142,6 +142,10 @@ std::pair<const BaseParameters*, MString> LayeredData::Parameters(michlib_intern
real lat1 = args.at("latb").ToReal(); real lat1 = args.at("latb").ToReal();
real lat2 = args.at("late").ToReal(); real lat2 = args.at("late").ToReal();
// Special case when the longitude lies in a small sector between the end and the start
if(lon1 < lonb) lon1 = lone;
if(lon2 > lone) lon2 = lonb;
ppar->yb = static_cast<size_t>(Floor((lat1 - latb) / latstep)); ppar->yb = static_cast<size_t>(Floor((lat1 - latb) / latstep));
ppar->ye = static_cast<size_t>(Ceil((lat2 - 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->ye > dname.ny - 1) ppar->ye = dname.ny - 1;

Loading…
Cancel
Save