Fix tests when HAVE_GEOGRAPHY=0

This commit is contained in:
shahramn 2024-12-26 17:27:06 +00:00
parent 7776c36348
commit 35274a1c4e
4 changed files with 17 additions and 8 deletions

View File

@ -93,6 +93,8 @@ static int check_geoiterator(grib_handle* h)
{
//printf("DEBUG %s \n", __func__);
int err = 0;
#if defined(HAVE_GEOGRAPHY)
grib_iterator* iter = grib_iterator_new(h, 0, &err);
if (err == GRIB_NOT_IMPLEMENTED || err == GRIB_SUCCESS) {
grib_iterator_delete(iter);
@ -101,6 +103,8 @@ static int check_geoiterator(grib_handle* h)
grib_context_log(h->context, GRIB_LOG_ERROR, "%s", grib_get_error_message(err));
grib_iterator_delete(iter);
#endif
return err;
}

View File

@ -166,7 +166,8 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int
int grib_iterator_delete(grib_iterator* i)
{
grib_context_log(ch->context, GRIB_LOG_ERROR,
grib_context* c = grib_context_get_default();
grib_context_log(c, GRIB_LOG_ERROR,
"Geoiterator functionality not enabled. Please rebuild with -DENABLE_GEOGRAPHY=ON");
return GRIB_FUNCTIONALITY_NOT_ENABLED;
}

View File

@ -24,15 +24,17 @@ grib_check_key_equals $ECCODES_SAMPLES_PATH/GRIB2.tmpl isMessageValid 1
${tools_dir}/grib_set -s PVPresent=1,NV=6 $ECCODES_SAMPLES_PATH/reduced_gg_pl_128_grib2.tmpl $tempGrib
grib_check_key_equals $tempGrib isMessageValid 0 2>$tempText
grep -q "Section 5 is missing" $tempText
grep -q "Error instantiating iterator gaussian_reduced" $tempText
if [ $HAVE_GEOGRAPHY -eq 1 ]; then
grep -q "Error instantiating iterator gaussian_reduced" $tempText
fi
# Check regular lat/lon
# ------------------------------
${tools_dir}/grib_set -s Nj=0 $data_dir/sample.grib2 $tempGrib
grib_check_key_equals $tempGrib isMessageValid 0 2>$tempText
grep -q "Regular grid Geoiterator" $tempText
if [ $HAVE_GEOGRAPHY -eq 1 ]; then
${tools_dir}/grib_set -s Nj=0 $data_dir/sample.grib2 $tempGrib
grib_check_key_equals $tempGrib isMessageValid 0 2>$tempText
grep -q "Regular grid Geoiterator" $tempText
fi
# Check reduced Gaussian grid Ni
# ------------------------------

View File

@ -52,7 +52,9 @@ cat > $tempFilt <<EOF
write;
EOF
${tools_dir}/grib_filter -o $tempGrib $tempFilt $sample2
${tools_dir}/grib_get_data $tempGrib
if [ $HAVE_GEOGRAPHY -eq 1 ]; then
${tools_dir}/grib_get_data $tempGrib
fi
${tools_dir}/grib_dump $tempGrib
grib_check_key_equals $tempGrib packingType spectral_complex
grib_check_key_equals $tempGrib gridType sh