From 01a89b394b0be6b3e9f8d83204c97f1ae42a3a09 Mon Sep 17 00:00:00 2001
From: Pedro Maciel <Pedro.Maciel@ecmwf.int>
Date: Thu, 29 Feb 2024 12:41:41 +0000
Subject: [PATCH] MIR-645 HEALPix support for earthkit-regrid

---
 src/mir/repres/proxy/HEALPix.cc             |  2 +-
 src/mir/repres/unsupported/HEALPixNested.cc | 11 +++--------
 src/mir/repres/unsupported/HEALPixNested.h  |  1 -
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/mir/repres/proxy/HEALPix.cc b/src/mir/repres/proxy/HEALPix.cc
index 27a0da477..394e25974 100644
--- a/src/mir/repres/proxy/HEALPix.cc
+++ b/src/mir/repres/proxy/HEALPix.cc
@@ -286,7 +286,7 @@ void HEALPix::json(eckit::JSON& j) const {
 
 
 void HEALPix::print(std::ostream& out) const {
-    out << "HEALPix[name=" << name() << "]";
+    out << "HEALPix[name=" << name() << ",ordering=" << orderingConvention_ << "]";
 }
 
 
diff --git a/src/mir/repres/unsupported/HEALPixNested.cc b/src/mir/repres/unsupported/HEALPixNested.cc
index 284e0cb38..f1f3f4090 100644
--- a/src/mir/repres/unsupported/HEALPixNested.cc
+++ b/src/mir/repres/unsupported/HEALPixNested.cc
@@ -25,13 +25,8 @@
 namespace mir::repres::unsupported {
 
 
-std::string HEALPixNested::name() const {
-    return "H" + std::to_string(ring_.Nside()) + "_nested";
-}
-
-
 void HEALPixNested::makeName(std::ostream& out) const {
-    out << name();
+    out << "H" << std::to_string(ring_.Nside()) << "_nested";
 }
 
 
@@ -47,7 +42,7 @@ void HEALPixNested::fillGrib(grib_info& info) const {
 
 void HEALPixNested::json(eckit::JSON& j) const {
     j.startObject();
-    j << "grid" << name();
+    j << "grid" << ring_.uniqueName();
     j << "type" << "healpix";
     j << "ordering" << "nested";
     j.endObject();
@@ -55,7 +50,7 @@ void HEALPixNested::json(eckit::JSON& j) const {
 
 
 void HEALPixNested::print(std::ostream& out) const {
-    out << "HEALPixNested[name=" << name() << "]";
+    out << "HEALPixNested[name=" << ring_.uniqueName() << "]";
 }
 
 
diff --git a/src/mir/repres/unsupported/HEALPixNested.h b/src/mir/repres/unsupported/HEALPixNested.h
index 78507106b..f9a7e2dbe 100644
--- a/src/mir/repres/unsupported/HEALPixNested.h
+++ b/src/mir/repres/unsupported/HEALPixNested.h
@@ -63,7 +63,6 @@ class HEALPixNested final : public Gridded {
     // -- Methods
 
     inline const Representation& ring() const { return static_cast<const Representation&>(ring_); }
-    std::string name() const;
 
     // -- Overridden methods