From 122948121c4a70cbbba031f1334341466de0a7ad Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Thu, 23 Nov 2023 13:24:37 +0000 Subject: [PATCH] ECC-1708: grib_get_data returns offset longitudes in some cases --- src/grib_iterator_class_regular.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/grib_iterator_class_regular.cc b/src/grib_iterator_class_regular.cc index 857112261..64033b8de 100644 --- a/src/grib_iterator_class_regular.cc +++ b/src/grib_iterator_class_regular.cc @@ -233,10 +233,14 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args) self->los[loi] = lon1; lon1 += idir; } - /* ECC-1406: Due to rounding, errors can accumulate. - * So we ensure the last longitude is longitudeOfLastGridPointInDegrees - */ - self->los[Ni-1] = normalise_longitude_in_degrees(lon2); // Also see ECC-1671 + + // ECC-1406: Due to rounding, errors can accumulate. + // So we ensure the last longitude is longitudeOfLastGridPointInDegrees + // Also see ECC-1671, ECC-1708 + if (lon2 > 0) { + lon2 = normalise_longitude_in_degrees(lon2); + } + self->los[Ni-1] = lon2; return ret; }