ECC-441: MeteoFrance contribution: GRIB1 second order packing. Final

This commit is contained in:
Shahram Najm 2017-04-04 17:44:24 +01:00
parent c1bfa3e19b
commit 3c60e2a4b9
1 changed files with 8 additions and 23 deletions

View File

@ -610,7 +610,9 @@ static void grib_split_long_groups(grib_handle* hand, grib_context* c,long* numb
grib_context_free(c,localFirstOrderValues);
}
static int pack_double_standard(grib_accessor* a, const double* val, size_t *len)
#if 0
// Old implementation. Now superseded. See ECC-441 and ECC-261
static int pack_double_old(grib_accessor* a, const double* val, size_t *len)
{
grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a;
int ret=0;
@ -1213,8 +1215,9 @@ static int pack_double_standard(grib_accessor* a, const double* val, size_t *len
return ret;
}
#endif
static int pack_double_optimised(grib_accessor* a, const double* val, size_t *len)
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a;
int ret=0;
@ -1258,8 +1261,6 @@ static int pack_double_optimised(grib_accessor* a, const double* val, size_t *le
long decimal_scale_factor;
grib_handle* handle = grib_handle_of_accessor(a);
long optimize_scaling_factor = 0;
grib_context* c=handle->context;
int compat_gribex = c->gribex_mode_on && self->edition==1;
self->dirty=1;
@ -1280,9 +1281,11 @@ static int pack_double_optimised(grib_accessor* a, const double* val, size_t *le
if (optimize_scaling_factor)
{
const int compat_gribex = handle->context->gribex_mode_on && self->edition==1;
const int compat_32bit = 1;
if((ret=grib_optimize_decimal_factor (a, self->reference_value,
max, min, bits_per_value,
compat_gribex, 1,
compat_gribex, compat_32bit,
&decimal_scale_factor, &binary_scale_factor, &reference_value)) != GRIB_SUCCESS)
return ret;
@ -1844,24 +1847,6 @@ static int pack_double_optimised(grib_accessor* a, const double* val, size_t *le
return ret;
}
/* The driver pack routine. See ECC-261 */
static int pack_double(grib_accessor* a, const double* val, size_t *len)
{
grib_accessor_data_g1second_order_general_extended_packing* self = (grib_accessor_data_g1second_order_general_extended_packing*)a;
int ret = GRIB_SUCCESS;
grib_handle* handle = grib_handle_of_accessor(a);
long optimize_scaling_factor = 0;
if((ret = grib_get_long_internal(handle,self->optimize_scaling_factor, &optimize_scaling_factor)) != GRIB_SUCCESS)
return ret;
if (optimize_scaling_factor) {
return pack_double_optimised(a,val,len);
} else {
return pack_double_standard(a,val,len);
}
}
static void destroy(grib_context* context,grib_accessor* a)
{
grib_accessor_data_g1second_order_general_extended_packing *self =(grib_accessor_data_g1second_order_general_extended_packing*)a;