ECC-938: BUFR keys iterator: key 'ident' from ECMWF local header is not included

This commit is contained in:
Shahram Najm 2019-06-06 16:55:03 +01:00
parent 88db347a21
commit 8616c07c53
4 changed files with 31 additions and 9 deletions

View File

@ -12,23 +12,22 @@ set -x
. ./include.sh
#Define a common label for all the tmp files
# Define a common label for all the tmp files
label="bufr_keys_iterator_test_c"
#Define tmp file
# Define tmp file
fTmp=${label}".tmp.txt"
rm -f $fTmp
REDIRECT=/dev/null
f=${data_dir}/bufr/syno_1.bufr
#Dump the keys
${examples_dir}/c_bufr_keys_iterator $f 2> $REDIRECT > $fTmp
#TODO: check the output
# Check the output
grep -q 'ident=91334' $fTmp
grep -q '#5#cloudAmount->percentConfidence=70' $fTmp
grep -q 'unexpandedDescriptors=(array of 10)' $fTmp
#Clean up
# Clean up
rm -f $fTmp

View File

@ -24,6 +24,7 @@ f=${data_dir}/bufr/syno_1.bufr
$PYTHON $examples_src/bufr_keys_iterator.py $f 2> $REDIRECT > $fTmp
# Check the output
grep -q 'ident' $fTmp
grep -q '#6#cloudType->percentConfidence' $fTmp
grep -q '#2#verticalSignificanceSurfaceObservations->percentConfidence' $fTmp

View File

@ -360,7 +360,7 @@ class TestBufrMessage(unittest.TestCase):
msg = BufrMessage(bufr_file)
msg.unpack()
msg_keys = list(msg.keys())
self.assertEqual(len(msg_keys), 200)
self.assertEqual(len(msg_keys), 201)
for key in KNOWN_BUFR_KEYS:
assert key in msg_keys
# Size of message in bytes

View File

@ -82,13 +82,31 @@ int codes_bufr_keys_iterator_rewind(bufr_keys_iterator* ki)
return GRIB_SUCCESS;
}
static int is_ident_key(bufr_keys_iterator* kiter)
{
if (kiter->current->sub_section)
return 0;
if (GRIB_ACCESSOR_FLAG_HIDDEN == kiter->current->flags &&
strcmp(kiter->current->name, "keyMore")==0 &&
grib_is_defined(kiter->handle, "ls.ident"))
{
return 1;
}
return 0;
}
static int skip(bufr_keys_iterator* kiter)
{
if(kiter->current->sub_section)
return 1;
if(kiter->current->flags & kiter->accessor_flags_skip)
if(kiter->current->flags & kiter->accessor_flags_skip) {
/* The "ident" key deserves special treatment */
if (is_ident_key(kiter))
return 0;
return 1;
}
if(kiter->accessor_flags_only == (kiter->current->flags & kiter->accessor_flags_only)) {
mark_seen(kiter,kiter->current->name);
@ -206,7 +224,11 @@ char* codes_bufr_keys_iterator_get_name(bufr_keys_iterator* kiter)
r=(int*)grib_trie_get(kiter->seen,kiter->current->name);
sprintf(ret,"#%d#%s",*r,kiter->current->name);
} else {
strcpy(ret,kiter->current->name);
if (is_ident_key(kiter)) {
strcpy(ret, "ident");
} else {
strcpy(ret,kiter->current->name);
}
}
}