mirror of https://github.com/ecmwf/eccodes.git
API: Allow setting code table keys as missing via codes_set_string
This commit is contained in:
parent
fdc57f8c26
commit
a2adea7b81
|
@ -62,6 +62,8 @@ int main(int argc, char** argv)
|
|||
/* 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);
|
||||
/* Set a Code Table key to missing via codes_set_string */
|
||||
CODES_CHECK(codes_set_string(h, "typeOfFirstFixedSurface", "missing", &str_len), 0);
|
||||
|
||||
/* see GRIB-490 */
|
||||
CODES_CHECK(codes_get_long(h, "Ni", &Ni), 0);
|
||||
|
|
|
@ -20,6 +20,10 @@ if [ -f "${tools_dir}/grib_get" ]; then
|
|||
[ "$sf" = "MISSING" ]
|
||||
sf=`${tools_dir}/grib_get -p scaledValueOfFirstFixedSurface $tempGrib`
|
||||
[ "$sf" = "MISSING" ]
|
||||
|
||||
# Code Table key being set to missing
|
||||
sf=`${tools_dir}/grib_get -p typeOfFirstFixedSurface:i, $tempGrib`
|
||||
[ "$sf" = "255" ]
|
||||
fi
|
||||
|
||||
rm -f $tempGrib
|
||||
|
|
|
@ -737,6 +737,10 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
|
|||
return grib_pack_long(a, &lValue, &l);
|
||||
}
|
||||
|
||||
if (STR_EQUAL_NOCASE(buffer, "missing")) {
|
||||
return pack_missing(a);
|
||||
}
|
||||
|
||||
grib_accessor_codetable* self = (grib_accessor_codetable*)a;
|
||||
grib_codetable* table;
|
||||
long i;
|
||||
|
|
|
@ -258,7 +258,7 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
|||
long v = 0; /* The converted value */
|
||||
|
||||
// ECC-1722
|
||||
if (strcmp_nocase(val, "missing")==0) {
|
||||
if (STR_EQUAL_NOCASE(val, "missing")) {
|
||||
return pack_missing(a);
|
||||
}
|
||||
|
||||
|
|
|
@ -201,6 +201,8 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type);
|
|||
|
||||
/* Return true if two strings are equal */
|
||||
#define STR_EQUAL(a, b) (strcmp((a), (b)) == 0)
|
||||
/* Return true if two strings are equal, ignoring case */
|
||||
#define STR_EQUAL_NOCASE(a, b) (strcmp_nocase((a), (b)) == 0)
|
||||
|
||||
#include "grib_api.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue