From 07609e6c4e34a972f943a6d2cec4798743ec4979 Mon Sep 17 00:00:00 2001 From: Stefanie Reuter Date: Thu, 16 Apr 2026 10:24:02 +0000 Subject: [PATCH 1/3] Fix Healpix encoding --- .../concepts/representation/representationEncoding.h | 8 ++++---- .../concepts/representation/representationMatcher.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/metkit/mars2grib/backend/concepts/representation/representationEncoding.h b/src/metkit/mars2grib/backend/concepts/representation/representationEncoding.h index f3c969ad..d0c362c1 100644 --- a/src/metkit/mars2grib/backend/concepts/representation/representationEncoding.h +++ b/src/metkit/mars2grib/backend/concepts/representation/representationEncoding.h @@ -439,15 +439,15 @@ void RepresentationOp(const MarsDict_t& mars, const ParDict_t& par, const OptDic const std::unique_ptr genericGrid(eckit::geo::GridFactory::build(gridSpec)); const auto* grid = dynamic_cast(genericGrid.get()); - const auto nside = static_cast(grid->Nside()); - const auto orderingConvention = grid->order() == eckit::geo::order::HEALPix::RING ? 0L : 1L; + const auto nside = static_cast(grid->Nside()); + const auto orderingConvention = grid->order(); const auto longitudeOfFirstGridPointInDegrees = std::get(grid->first_point()).lon(); // Encoding set_or_throw(out, "resolutionAndComponentFlags", 0); // Flag table 3.3 - set_or_throw(out, "nside", nside); - set_or_throw(out, "orderingConvention", orderingConvention); + set_or_throw(out, "Nside", nside); + set_or_throw(out, "orderingConvention", orderingConvention); set_or_throw(out, "longitudeOfFirstGridPointInDegrees", longitudeOfFirstGridPointInDegrees); } else if constexpr (Variant == RepresentationType::Orca) { diff --git a/src/metkit/mars2grib/backend/concepts/representation/representationMatcher.h b/src/metkit/mars2grib/backend/concepts/representation/representationMatcher.h index ab226695..aa8a4d53 100644 --- a/src/metkit/mars2grib/backend/concepts/representation/representationMatcher.h +++ b/src/metkit/mars2grib/backend/concepts/representation/representationMatcher.h @@ -36,6 +36,9 @@ std::size_t representationMatcher(const MarsDict_t& mars, const OptDict_t& opt) else if (gridType == "ORCA") { return static_cast(RepresentationType::Orca); } + else if (gridType == "healpix") { + return static_cast(RepresentationType::Healpix); + } throw utils::exceptions::Mars2GribMatcherException( "Cannot match grid \"" + marsGrid + "\" with grid type \"" + gridType + "\"! ", Here()); From 946d00137bfcb74aa0a32368a4522da6d601f42b Mon Sep 17 00:00:00 2001 From: Kevin Nobel Date: Fri, 17 Apr 2026 08:34:15 +0000 Subject: [PATCH 2/3] Run clang-format --- .../backend/concepts/representation/representationEncoding.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/metkit/mars2grib/backend/concepts/representation/representationEncoding.h b/src/metkit/mars2grib/backend/concepts/representation/representationEncoding.h index d0c362c1..f9747d47 100644 --- a/src/metkit/mars2grib/backend/concepts/representation/representationEncoding.h +++ b/src/metkit/mars2grib/backend/concepts/representation/representationEncoding.h @@ -439,8 +439,8 @@ void RepresentationOp(const MarsDict_t& mars, const ParDict_t& par, const OptDic const std::unique_ptr genericGrid(eckit::geo::GridFactory::build(gridSpec)); const auto* grid = dynamic_cast(genericGrid.get()); - const auto nside = static_cast(grid->Nside()); - const auto orderingConvention = grid->order(); + const auto nside = static_cast(grid->Nside()); + const auto orderingConvention = grid->order(); const auto longitudeOfFirstGridPointInDegrees = std::get(grid->first_point()).lon(); From 2047694d47d45740fadeeaff6a60ca09d919bfeb Mon Sep 17 00:00:00 2001 From: Philipp Geier Date: Wed, 29 Apr 2026 12:34:54 +0000 Subject: [PATCH 3/3] Fix CodesHandle::getBytes for bitmap --- src/metkit/codes/api/CodesAPI.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/metkit/codes/api/CodesAPI.cc b/src/metkit/codes/api/CodesAPI.cc index 9137ccb1..dff4cc05 100644 --- a/src/metkit/codes/api/CodesAPI.cc +++ b/src/metkit/codes/api/CodesAPI.cc @@ -407,7 +407,12 @@ std::vector OwningCodesHandle::getStringArray(const std::string& ke std::vector OwningCodesHandle::getBytes(const std::string& key) const { std::vector ret; - std::size_t ksize = length(key) / 2; + /// Note: The returned length for bytes often is much higher than needed. + /// For UIDs (i.e. "uuidOfHGrid"), the native type is BYTES, but length returns the number of characters in its + /// string representation - which is twice the number of bytes. However, in contrast for fields like "bitmap" it + /// directly returns the number of bytes. It has been discussed with Shahram several times without a change taking + /// in. + std::size_t ksize = length(key); ret.resize(ksize); throwOnError(codes_get_bytes(raw(), key.c_str(), ret.data(), &ksize), Here(), "CodesHandle::getBytes(string)", key); ret.resize(ksize);