Skip to content

Commit

Permalink
ECC-1586: grib_get_data: Invalid latitude values printed
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed May 12, 2023
1 parent 919d182 commit c46c3e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/grib_iterator_class_latlon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
return err;
if ((err = grib_get_double_internal(h, "latitudeLastInDegrees", &lat2)))
return err;
if ((err = grib_get_double_internal(h, s_jdir, &jdir)))
if ((err = grib_get_double_internal(h, s_jdir, &jdir))) //can be GRIB_MISSING_DOUBLE
return err;
if ((err = grib_get_long_internal(h, s_jScansPos, &jScansPositively)))
return err;
Expand All @@ -182,7 +182,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)

/* ECC-984: If jDirectionIncrement is missing, then we cannot use it (See jDirectionIncrementGiven) */
/* So try to compute the increment */
if (grib_is_missing(h, s_jdir, &err) && err == GRIB_SUCCESS) {
if ( (grib_is_missing(h, s_jdir, &err) && err == GRIB_SUCCESS) || (jdir == GRIB_MISSING_DOUBLE) ) {
const long Nj = self->Nj;
Assert(Nj > 1);
if (lat1 > lat2) {
Expand All @@ -191,8 +191,8 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
else {
jdir = (lat2 - lat1) / (Nj - 1);
}
grib_context_log(h->context, GRIB_LOG_INFO,
"%s is missing (See jDirectionIncrementGiven). Using value of %.6f obtained from La1, La2 and Nj", s_jdir, jdir);
grib_context_log(h->context, GRIB_LOG_DEBUG,
"Cannot use jDirectionIncrement. Using value of %.6f obtained from La1, La2 and Nj", jdir);
}

if (jScansPositively) {
Expand Down
2 changes: 1 addition & 1 deletion src/grib_iterator_class_regular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
return ret;
if ((ret = grib_get_double_internal(h, "longitudeOfLastGridPointInDegrees", &lon2)))
return ret;
if ((ret = grib_get_double_internal(h, s_idir, &idir)))
if ((ret = grib_get_double_internal(h, s_idir, &idir))) // can be GRIB_MISSING_DOUBLE
return ret;
if ((ret = grib_get_long_internal(h, s_Ni, &Ni)))
return ret;
Expand Down
2 changes: 1 addition & 1 deletion tests/grib_ecc-984.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ grib_check_key_equals $tempGrb jDirectionIncrementInDegrees MISSING
${tools_dir}/grib_get_data -F%.2f $tempGrb >$tempOut 2>$tempErr

grep -q "2.000 20.000 302.53" $tempOut
grep -q "DjInDegrees is missing" $tempErr
# grep -q "Cannot use jDirectionIncrement" $tempErr

# Clean up
rm -f $tempGrb $tempOut $tempErr

0 comments on commit c46c3e8

Please sign in to comment.