Merge remote-tracking branch 'origin/develop' into feature/mtg2_parameters

This commit is contained in:
Matthew Griffith 2024-12-23 09:51:01 +00:00
commit 49faac7c85
4 changed files with 22 additions and 15 deletions

View File

@ -22,6 +22,8 @@ void grib_accessor_evaluate_t::init(const long l, grib_arguments* c)
int grib_accessor_evaluate_t::unpack_long(long* val, size_t* len)
{
if (!arg_) return GRIB_INVALID_ARGUMENT;
grib_handle* h = grib_handle_of_accessor(this);
grib_expression* e = arg_->get_expression(h, 0);

View File

@ -31,14 +31,20 @@ GeoIterator::GeoIterator(grib_handle* h, unsigned long flags) :
CODES_CHECK(codes_get_size(h_, "values", &nv_), "");
ECCODES_ASSERT(nv_ > 0);
data_ = (flags_ & GRIB_GEOITERATOR_NO_VALUES) ? nullptr : static_cast<double*>(grib_context_malloc(h_->context, nv_ * sizeof(double)));
ECCODES_ASSERT(data_ != nullptr);
//long numberOfPoints = 0;
//grib_get_long_internal(h, "numberOfPoints", &numberOfPoints);
if (flags_ & GRIB_GEOITERATOR_NO_VALUES) {
data_ = nullptr;
} else {
data_ = static_cast<double*>(grib_context_malloc(h_->context, nv_ * sizeof(double)));
ECCODES_ASSERT(data_ != nullptr);
auto size = nv_;
CODES_CHECK(codes_get_double_array(h_, "values", data_, &size), "");
ECCODES_ASSERT(nv_ == size);
// Check numberOfPoints equals nv_
// if not, throw an exception
}
}
int GeoIterator::init(grib_handle*, grib_arguments*)
{

View File

@ -15,18 +15,12 @@
#include "eckit/geo/Grid.h"
// eccodes macros conflict with eckit
#ifdef Assert
#undef Assert
#endif
#include "geo/iterator/grib_iterator.h"
namespace eccodes::geo
{
class GeoIterator : public geo_iterator::Iterator
{
public:
@ -47,5 +41,4 @@ private:
geo_iterator::Iterator* create() const override;
};
} // namespace eccodes::geo

View File

@ -122,9 +122,15 @@ grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int
}
}
} static const init_main;
try {
i->iterator = new eccodes::geo::GeoIterator(const_cast<grib_handle*>(ch), flags);
}
catch(std::exception& e) {
grib_context_log(ch->context, GRIB_LOG_ERROR, "grib_iterator_new: Exception thrown (%s)", e.what());
*error = GRIB_GEOCALCULUS_PROBLEM;
return NULL;
}
}
else
#endif
{