From c79edbbaef8d5afc07f03f0fe0389cfbf92b8fbf Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Thu, 27 Apr 2023 19:45:17 +1000 Subject: [PATCH] Fixed a bug when the longitude lies in a small sector between the end and start --- src/AVISOLOCAL.cpp | 4 ++++ src/layereddata.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/AVISOLOCAL.cpp b/src/AVISOLOCAL.cpp index 69aa683..0d92a26 100644 --- a/src/AVISOLOCAL.cpp +++ b/src/AVISOLOCAL.cpp @@ -183,6 +183,10 @@ template AVISOLOCALData::Data AVISOLOCALData::ReadVarRaw(const N real lat1 = p->latb; 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(Floor((lat1 - latb) / latstep)); auto ye = static_cast(Ceil((lat2 - latb) / latstep)); if(ye > dn.ny - 1) ye = dn.ny - 1; diff --git a/src/layereddata.cpp b/src/layereddata.cpp index c7eada3..bfc646c 100644 --- a/src/layereddata.cpp +++ b/src/layereddata.cpp @@ -142,6 +142,10 @@ std::pair LayeredData::Parameters(michlib_intern real lat1 = args.at("latb").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(Floor((lat1 - latb) / latstep)); ppar->ye = static_cast(Ceil((lat2 - latb) / latstep)); if(ppar->ye > dname.ny - 1) ppar->ye = dname.ny - 1;