Skip to content

Commit

Permalink
eckit::geo iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Nov 20, 2024
1 parent e549585 commit 4d41a4b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions eccodes_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
#cmakedefine HAVE_NETCDF

#cmakedefine HAVE_GEOGRAPHY
#cmakedefine HAVE_ECKIT_GEO
#cmakedefine HAVE_MEMFS
#cmakedefine HAVE_FORTRAN

Expand Down
39 changes: 39 additions & 0 deletions src/grib_iterator_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/

#include "eccodes_config.h"

#ifdef HAVE_ECKIT_GEO
#include <memory>
#include "eccodes/geo/GribSpec.h"

// eccodes macros conflict with eckit
#ifdef Assert
#undef Assert
#endif
#endif

#include "grib_iterator_factory.h"
#include "accessor/grib_accessor_class_iterator.h"

Expand Down Expand Up @@ -60,8 +72,35 @@ static const struct table_entry table[] = {
{ "unstructured", &grib_iterator_unstructured, },
};

#ifdef HAVE_ECKIT_GEO
class GeoIterator : public eccodes::geo_iterator::Iterator
{
public:
GeoIterator(grib_handle* h) :
spec_(new eccodes::geo::GribSpec(h)) {}

private:
std::unique_ptr<eckit::geo::Spec> spec_;

int init(grib_handle*, grib_arguments*) override { NOTIMP; }
int next(double*, double*, double*) const override { NOTIMP; }
int previous(double*, double*, double*) const override { NOTIMP; }
int reset() override { NOTIMP; }
int destroy() override { NOTIMP; }
bool has_next() const override { NOTIMP; }
Iterator* create() const override { NOTIMP; }
};
#endif

eccodes::geo_iterator::Iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* error)
{
#ifdef HAVE_ECKIT_GEO
static const auto* eckit_geo = codes_getenv("ECCODES_ECKIT_GEO");
if (eckit_geo != NULL && strcmp(eckit_geo, "1") == 0) {
return new GeoIterator(h);
}
#endif

size_t i = 0, num_table_entries = 0;
const char* type = (char*)grib_arguments_get_name(h, args, 0);
*error = GRIB_NOT_IMPLEMENTED;
Expand Down

0 comments on commit 4d41a4b

Please sign in to comment.