From df3e8430ed1855a84b858b07fae3544f73b51319 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 23 Jun 2020 20:49:04 +0100 Subject: [PATCH] Refactoring and DebugAssert --- src/grib_iterator_class_lambert_conformal.c | 6 ++++-- src/grib_iterator_class_mercator.c | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/grib_iterator_class_lambert_conformal.c b/src/grib_iterator_class_lambert_conformal.c index eb05b7fa6..153d9455a 100644 --- a/src/grib_iterator_class_lambert_conformal.c +++ b/src/grib_iterator_class_lambert_conformal.c @@ -360,9 +360,11 @@ static int init_oblate(grib_handle* h, latRad = -M_PI_2; } lonRad = adjust_lon_radians(theta / ns + LoVInRadians); + if (i == 0 && j == 0) { + DebugAssert(fabs(latFirstInRadians - latRad) <= EPSILON); + } latDeg = latRad * RAD2DEG; /* Convert to degrees */ - lonDeg = lonRad * RAD2DEG; - lonDeg = normalise_longitude_in_degrees(lonDeg); + lonDeg = normalise_longitude_in_degrees(lonRad * RAD2DEG); self->lons[index] = lonDeg; self->lats[index] = latDeg; } diff --git a/src/grib_iterator_class_mercator.c b/src/grib_iterator_class_mercator.c index 561ae8345..9ca68126e 100644 --- a/src/grib_iterator_class_mercator.c +++ b/src/grib_iterator_class_mercator.c @@ -215,10 +215,12 @@ static int init_mercator(grib_handle* h, grib_context_free(h->context, self->lons); return err; } - lonRad = adjust_lon_radians(orientationInRadians + _x / (earthMajorAxisInMetres * m1)); + lonRad = adjust_lon_radians(orientationInRadians + _x / (earthMajorAxisInMetres * m1)); + if (i == 0 && j == 0) { + DebugAssert(fabs(latFirstInRadians - latRad) <= EPSILON); + } latDeg = latRad * RAD2DEG; /* Convert to degrees */ - lonDeg = lonRad * RAD2DEG; - lonDeg = normalise_longitude_in_degrees(lonDeg); + lonDeg = normalise_longitude_in_degrees(lonRad * RAD2DEG); self->lons[index] = lonDeg; self->lats[index] = latDeg; }