Default native step type is string. It's long if unit is not shown.

This commit is contained in:
Eugen Betke 2024-01-19 09:29:16 +00:00
parent afc918b3f0
commit b8830c337b
2 changed files with 16 additions and 15 deletions

View File

@ -744,14 +744,15 @@ static int pack_string(grib_accessor* a, const char* val, size_t* len)
static int get_native_type(grib_accessor* a)
{
// TODO: Still experimental.
// Change the type to depend on the stepUnits for backward compatibility
grib_handle* h = grib_handle_of_accessor(a);
long step_units = 0;
if (grib_get_long_internal(h, "stepUnits", &step_units) == GRIB_SUCCESS) {
if (step_units == 1) {
return GRIB_TYPE_LONG;
int show_hours = a->context->show_hour_stepunit;
if (!show_hours) {
long step_units = 0;
if (grib_get_long_internal(h, "stepUnits", &step_units) == GRIB_SUCCESS) {
if (eccodes::Unit{step_units} == eccodes::Unit::Value::HOUR) {
return GRIB_TYPE_LONG;
}
}
}

View File

@ -349,16 +349,16 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
static int get_native_type(grib_accessor* a)
{
// TODO: Still experimental.
// Change the type to depend on the stepUnits for backward compatibility
grib_handle* h = grib_handle_of_accessor(a);
long step_units = 0;
if (grib_get_long_internal(h, "stepUnits", &step_units) == GRIB_SUCCESS) {
if (step_units == 1) {
return GRIB_TYPE_LONG;
int show_hours = a->context->show_hour_stepunit;
if (!show_hours) {
long step_units = 0;
if (grib_get_long_internal(h, "stepUnits", &step_units) == GRIB_SUCCESS) {
if (eccodes::Unit{step_units} == eccodes::Unit::Value::HOUR) {
return GRIB_TYPE_LONG;
}
}
}
return GRIB_TYPE_STRING;
}