Skip to content

Commit c46c3e8

Browse files
committed
ECC-1586: grib_get_data: Invalid latitude values printed
1 parent 919d182 commit c46c3e8

3 files changed

+6
-6
lines changed

src/grib_iterator_class_latlon.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
171171
return err;
172172
if ((err = grib_get_double_internal(h, "latitudeLastInDegrees", &lat2)))
173173
return err;
174-
if ((err = grib_get_double_internal(h, s_jdir, &jdir)))
174+
if ((err = grib_get_double_internal(h, s_jdir, &jdir))) //can be GRIB_MISSING_DOUBLE
175175
return err;
176176
if ((err = grib_get_long_internal(h, s_jScansPos, &jScansPositively)))
177177
return err;
@@ -182,7 +182,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
182182

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

198198
if (jScansPositively) {

src/grib_iterator_class_regular.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
161161
return ret;
162162
if ((ret = grib_get_double_internal(h, "longitudeOfLastGridPointInDegrees", &lon2)))
163163
return ret;
164-
if ((ret = grib_get_double_internal(h, s_idir, &idir)))
164+
if ((ret = grib_get_double_internal(h, s_idir, &idir))) // can be GRIB_MISSING_DOUBLE
165165
return ret;
166166
if ((ret = grib_get_long_internal(h, s_Ni, &Ni)))
167167
return ret;

tests/grib_ecc-984.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ grib_check_key_equals $tempGrb jDirectionIncrementInDegrees MISSING
2525
${tools_dir}/grib_get_data -F%.2f $tempGrb >$tempOut 2>$tempErr
2626

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

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

0 commit comments

Comments
 (0)