ECC-887: BUFR: Search by condition does not work for floating point value

This commit is contained in:
Shahram Najm 2019-02-12 13:26:24 +00:00
parent d85acaabd1
commit ac551a7a9c
3 changed files with 35 additions and 2 deletions

View File

@ -179,10 +179,10 @@ static char* get_condition(const char* name,codes_condition* condition)
end=NULL;
lval=strtol(str,&end,10);
if (*end != 0) {
if (*end != 0) { /* strtol failed. Not an integer */
double dval;
dval=strtod(str,&end);
if (*end != 0) {
if (*end == 0) { /* strtod passed. So a double */
condition->rightType=GRIB_TYPE_DOUBLE;
condition->rightDouble=dval;
}

View File

@ -94,6 +94,7 @@ list( APPEND tests_data_reqd
bufr_ecc-433
bufr_ecc-750
bufr_ecc-875
bufr_ecc-887
grib_ecc-490
grib_ecc-756
grib_ecc-873

32
tests/bufr_ecc-887.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
# Copyright 2005-2018 ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.sh
# ---------------------------------------------------------
# This is the test for the JIRA issue ECC-887
# BUFR: Search by condition does not work for floating point value
# ---------------------------------------------------------
label="bufr_ecc-887-test"
tempOut=temp.${label}.out
tempRules=temp.${label}.filter
input=${data_dir}/bufr/temp_101.bufr
cat > $tempRules <<EOF
set unpack=1;
print "[/airTemperature=272.1/windDirection]";
EOF
res=`${tools_dir}/codes_bufr_filter $tempRules $input`
[ "$res" = "355 2147483647" ]
# Clean up
rm -f $tempRules