ECC-1858: Allow user to control encoding via optimizeScaleFactor (by default 0)

This commit is contained in:
shahramn 2024-08-08 13:37:07 +01:00
parent cbb4389334
commit f50d2c5884
2 changed files with 7 additions and 2 deletions

View File

@ -786,7 +786,7 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c
// long nvals_per_group = 0;
// long nbits_per_group_val = 0;
long binary_scale_factor, decimal_scale_factor, typeOfOriginalFieldValues;
long binary_scale_factor, decimal_scale_factor, typeOfOriginalFieldValues, optimize_scale_factor;
// long groupSplittingMethodUsed, numberOfGroupsOfDataValues, referenceForGroupWidths;
long missingValueManagementUsed, primaryMissingValueSubstitute, secondaryMissingValueSubstitute;
long numberOfBitsUsedForTheGroupWidths, numberOfBitsUsedForTheScaledGroupLengths, orderOfSpatialDifferencing;
@ -815,7 +815,10 @@ int grib_accessor_class_data_g22order_packing_t::pack_double(grib_accessor* a, c
if ((err = grib_get_long_internal(gh, self->decimal_scale_factor, &decimal_scale_factor)) != GRIB_SUCCESS)
return err;
int use_scale = 1;
if ((err = grib_get_long_internal(gh, self->optimize_scale_factor, &optimize_scale_factor)) != GRIB_SUCCESS)
return err;
int use_scale = !optimize_scale_factor;
if ((err = grib_get_long_internal(gh, self->binary_scale_factor, &binary_scale_factor)) != GRIB_SUCCESS)
return err;

View File

@ -127,6 +127,8 @@ ${tools_dir}/grib_copy -r $infile $temp2
${tools_dir}/grib_compare -R all=0.3 -c data:n $infile $temp2
grib_check_key_equals $temp2 bitsPerValue 9 # Note: The input file has bpv=9
${tools_dir}/grib_set -rs optimizeScaleFactor=1 $infile $temp2
${tools_dir}/grib_compare $infile $temp2
# Simple to grid_complex
tempComplex=temp.grib_bitmap.complex.grib