From bb5c00de5a0bd84005cf44757433a17ef7b7924d Mon Sep 17 00:00:00 2001 From: Pedro Maciel Date: Tue, 14 Jul 2020 14:35:04 +0100 Subject: [PATCH] Set packingType=grid_ieee via grib_util_set_spec (experimental) --- src/eccodes.h | 1 + src/grib_api.h | 1 + src/grib_util.c | 8 ++++++++ tests/grib_util_set_spec.c | 2 ++ 4 files changed, 12 insertions(+) diff --git a/src/eccodes.h b/src/eccodes.h index 1c0958490..cff69f0db 100644 --- a/src/eccodes.h +++ b/src/eccodes.h @@ -1253,6 +1253,7 @@ int codes_points_get_values(codes_handle* h, codes_points* points, double* val); #define CODES_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX #define CODES_UTIL_PACKING_TYPE_GRID_SECOND_ORDER GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER #define CODES_UTIL_PACKING_TYPE_CCSDS GRIB_UTIL_PACKING_TYPE_CCSDS +#define CODES_UTIL_PACKING_TYPE_IEEE GRIB_UTIL_PACKING_TYPE_IEEE #define CODES_UTIL_PACKING_SAME_AS_INPUT GRIB_UTIL_PACKING_SAME_AS_INPUT #define CODES_UTIL_PACKING_USE_PROVIDED GRIB_UTIL_PACKING_USE_PROVIDED diff --git a/src/grib_api.h b/src/grib_api.h index 34e3a49fb..c5fd1747c 100644 --- a/src/grib_api.h +++ b/src/grib_api.h @@ -1522,6 +1522,7 @@ typedef struct grib_util_grid_spec2 #define GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE_MATRIX 6 #define GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER 7 #define GRIB_UTIL_PACKING_TYPE_CCSDS 8 +#define GRIB_UTIL_PACKING_TYPE_IEEE 9 #define GRIB_UTIL_PACKING_SAME_AS_INPUT 0 #define GRIB_UTIL_PACKING_USE_PROVIDED 1 diff --git a/src/grib_util.c b/src/grib_util.c index 9e76d22f4..6fb8e194e 100644 --- a/src/grib_util.c +++ b/src/grib_util.c @@ -974,6 +974,10 @@ grib_handle* grib_util_set_spec2(grib_handle* h, if (strcmp(input_packing_type, "grid_ccsds") && !strcmp(input_packing_type, "grid_simple")) SET_STRING_VALUE("packingType", "grid_ccsds"); break; + case GRIB_UTIL_PACKING_TYPE_IEEE: + if (strcmp(input_packing_type, "grid_ieee") && !strcmp(input_packing_type, "grid_simple")) + SET_STRING_VALUE("packingType", "grid_ieee"); + break; case GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER: /* we delay the set of grid_second_order because we don't want to do it on a field with bitsPerValue=0 */ @@ -1402,6 +1406,10 @@ grib_handle* grib_util_set_spec2(grib_handle* h, if (strcmp(input_packing_type, "grid_ccsds") && !strcmp(input_packing_type, "grid_simple")) setCcsdsPacking = 1; break; + case GRIB_UTIL_PACKING_TYPE_IEEE: + if (strcmp(input_packing_type, "grid_ieee") && !strcmp(input_packing_type, "grid_simple")) + SET_STRING_VALUE("packingType", "grid_ieee"); + break; case GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER: /* we delay the set of grid_second_order because we don't want to do it on a field with bitsPerValue=0 */ diff --git a/tests/grib_util_set_spec.c b/tests/grib_util_set_spec.c index fdcccb01a..805fbec69 100644 --- a/tests/grib_util_set_spec.c +++ b/tests/grib_util_set_spec.c @@ -28,6 +28,8 @@ static int get_packing_type_code(const char* packingType) result = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE; else if (STR_EQUAL(packingType, "grid_second_order")) result = GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER; + else if (STR_EQUAL(packingType, "grid_ieee")) + result = GRIB_UTIL_PACKING_TYPE_IEEE; return result; }