Skip to content

Commit

Permalink
ECC-1722: API: Allow setting integer key as missing via codes_set_string
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Nov 20, 2023
1 parent ddc1d47 commit 2d128f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions examples/C/grib_set_missing.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ int main(int argc, char** argv)
CODES_CHECK(codes_set_missing(h, "scaleFactorOfFirstFixedSurface"), 0);
CODES_CHECK(codes_set_missing(h, "scaledValueOfFirstFixedSurface"), 0);

/* Can also set to MISSING via codes_set_string */
CODES_CHECK(codes_set_string(h, "scaleFactorOfFirstFixedSurface", "missing", &str_len), 0);
CODES_CHECK(codes_set_string(h, "scaledValueOfFirstFixedSurface", "missing", &str_len), 0);

/* see GRIB-490 */
CODES_CHECK(codes_get_long(h, "Ni", &Ni), 0);
is_missing = codes_is_missing(h, "Ni", &err);
Expand Down
8 changes: 4 additions & 4 deletions src/grib_accessor_class_long.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
{
long v = 0; /* The converted value */

// Requires more work e.g. filter
//if (strcmp_nocase(val, "missing")==0) {
// return pack_missing(a);
//}
// ECC-1722
if (strcmp_nocase(val, "missing")==0) {
return pack_missing(a);
}

if (string_to_long(val, &v, 1) != GRIB_SUCCESS) {
grib_context_log(a->context, GRIB_LOG_ERROR,
Expand Down

0 comments on commit 2d128f5

Please sign in to comment.