ECC-1868: Nearest neighbour

This commit is contained in:
shahramn 2024-07-12 20:08:03 +01:00
parent 9808b03d76
commit 39f73fda5c
5 changed files with 63 additions and 49 deletions

View File

@ -52,7 +52,7 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int
{
*error = GRIB_FUNCTIONALITY_NOT_ENABLED;
grib_context_log(ch->context, GRIB_LOG_ERROR,
"Geoiterator support not enabled. Please rebuild with -DENABLE_GEOGRAPHY=ON");
"Geoiterator functionality not enabled. Please rebuild with -DENABLE_GEOGRAPHY=ON");
return NULL;
}

View File

@ -27,6 +27,7 @@ void grib_accessor_class_nearest_t::dump(grib_accessor* a, grib_dumper* dumper)
grib_dump_label(dumper, a, NULL);
}
#if defined(HAVE_GEOGRAPHY)
grib_nearest* grib_nearest_new(const grib_handle* ch, int* error)
{
grib_handle* h = (grib_handle*)ch;
@ -47,3 +48,13 @@ grib_nearest* grib_nearest_new(const grib_handle* ch, int* error)
return n;
}
#else
grib_nearest* grib_nearest_new(const grib_handle* ch, int* error)
{
*error = GRIB_FUNCTIONALITY_NOT_ENABLED;
grib_context_log(ch->context, GRIB_LOG_ERROR,
"Nearest neighbour functionality not enabled. Please rebuild with -DENABLE_GEOGRAPHY=ON");
return NULL;
}
#endif

View File

@ -35,44 +35,43 @@ grep -q "Nh (Key/value not found)" $tempText
# Nearest
# ---------
set +e
${tools_dir}/grib_get -l abc $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Wrong latitude value" $tempText
if [ $HAVE_GEOGRAPHY -eq 1 ]; then
set +e
${tools_dir}/grib_get -l abc $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Wrong latitude value" $tempText
set +e
${tools_dir}/grib_get -s Nj=MISSING -l 0,0,1 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Key Nj cannot be 'missing'" $tempText
set +e
${tools_dir}/grib_get -s Nj=MISSING -l 0,0,1 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Key Nj cannot be 'missing'" $tempText
set +e
${tools_dir}/grib_get -s Nj=0 -l 0,0,1 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Key Nj cannot be 0" $tempText
set +e
${tools_dir}/grib_get -s Nj=0 -l 0,0,1 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Key Nj cannot be 0" $tempText
set +e
${tools_dir}/grib_get -l 0,0,5 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib2.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Wrong mode given" $tempText
set +e
${tools_dir}/grib_get -l 0,0,5 $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib2.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Wrong mode given" $tempText
set +e
${tools_dir}/grib_get -l 0,0,1,nonexistingmask $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
cat $tempText
grep -q "unable to open mask file" $tempText
set +e
${tools_dir}/grib_get -l 0,0,1,nonexistingmask $ECCODES_SAMPLES_PATH/reduced_ll_sfc_grib1.tmpl > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
cat $tempText
grep -q "unable to open mask file" $tempText
fi
# ------------------------
# Unreadable message

View File

@ -76,14 +76,15 @@ set -e
[ $status -ne 0 ]
grep -q "Invalid pl array: entry at index=3 is zero" $tempText
${tools_dir}/grib_filter -o $tempGrib $tempFilt $sample1
set +e
${tools_dir}/grib_get -l 0,0 $tempGrib > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Invalid pl array: entry at index=3 is zero" $tempText
if [ $HAVE_GEOGRAPHY -eq 1 ]; then
${tools_dir}/grib_filter -o $tempGrib $tempFilt $sample1
set +e
${tools_dir}/grib_get -l 0,0 $tempGrib > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Invalid pl array: entry at index=3 is zero" $tempText
fi
# Clean up
rm -f $tempGrib $tempText $tempFilt

View File

@ -67,12 +67,15 @@ cat > $tempFilt <<EOF
write;
EOF
${tools_dir}/grib_filter -o $tempGrib $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl
set +e
${tools_dir}/grib_ls -l 0,0 $tempGrib > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Nearest neighbour functionality is not supported for grid: Variable resolution latitude/longitude" $tempText
if [ $HAVE_GEOGRAPHY -eq 1 ]; then
set +e
${tools_dir}/grib_ls -l 0,0 $tempGrib > $tempText 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "Nearest neighbour functionality is not supported for grid: Variable resolution latitude/longitude" $tempText
fi
# Check the keys isSpectral and isGridded
# ----------------------------------------