mirror of https://github.com/ecmwf/eccodes.git
Geoiterator for unstructured grids (disabled)
This commit is contained in:
parent
2b0efc1129
commit
562cf2a4a0
|
@ -14,3 +14,5 @@ unsigned[1] numberOfGridInReference : dump;
|
|||
byte[16] uuidOfHGrid : dump;
|
||||
|
||||
template_nofail unstructuredGrid "grib2/localConcepts/[centre:s]/unstructuredGrid.def";
|
||||
|
||||
# iterator unstructured(numberOfPoints, missingValue, values, uuidOfHGrid);
|
||||
|
|
|
@ -350,6 +350,7 @@ list( APPEND eccodes_src_files
|
|||
geo_iterator/grib_iterator_class_polar_stereographic.cc
|
||||
geo_iterator/grib_iterator_class_regular.cc
|
||||
geo_iterator/grib_iterator_class_space_view.cc
|
||||
geo_iterator/grib_iterator_class_unstructured.cc
|
||||
grib_expression.cc
|
||||
codes_util.cc
|
||||
grib_util.cc
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* (C) Copyright 2005- ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#include "grib_iterator_class_unstructured.h"
|
||||
|
||||
eccodes::geo_iterator::Unstructured _grib_iterator_unstructured{};
|
||||
eccodes::geo_iterator::Iterator* grib_iterator_unstructured = &_grib_iterator_unstructured;
|
||||
|
||||
namespace eccodes::geo_iterator {
|
||||
|
||||
#define ITER "Unstructured grid Geoiterator"
|
||||
|
||||
int Unstructured::next(double* lat, double* lon, double* val) const
|
||||
{
|
||||
if ((long)e_ >= (long)(nv_ - 1))
|
||||
return 0;
|
||||
e_++;
|
||||
|
||||
*lat = lats_[e_];
|
||||
*lon = lons_[e_];
|
||||
if (val && data_) {
|
||||
*val = data_[e_];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Unstructured::init(grib_handle* h, grib_arguments* args)
|
||||
{
|
||||
int ret = GRIB_SUCCESS;
|
||||
if ((ret = Gen::init(h, args)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
const char* s_uuidOfHGrid = grib_arguments_get_name(h, args, carg_++);
|
||||
char uuidOfHGrid[32] = {0,};
|
||||
auto slen = sizeof(uuidOfHGrid);
|
||||
if ((ret = grib_get_string_internal(h, s_uuidOfHGrid, uuidOfHGrid, &slen)) != GRIB_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
lats_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
|
||||
if (!lats_) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %zu bytes", ITER, nv_ * sizeof(double));
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
}
|
||||
lons_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
|
||||
if (!lons_) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "%s: Error allocating %zu bytes", ITER, nv_ * sizeof(double));
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
e_ = -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Unstructured::destroy()
|
||||
{
|
||||
DEBUG_ASSERT(h_);
|
||||
const grib_context* c = h_->context;
|
||||
grib_context_free(c, lats_);
|
||||
grib_context_free(c, lons_);
|
||||
|
||||
return Gen::destroy();
|
||||
}
|
||||
|
||||
} // namespace eccodes::geo_iterator
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* (C) Copyright 2005- ECMWF.
|
||||
*
|
||||
* This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "grib_iterator_class_gen.h"
|
||||
|
||||
namespace eccodes::geo_iterator {
|
||||
|
||||
class Unstructured : public Gen
|
||||
{
|
||||
public:
|
||||
Unstructured() :
|
||||
Gen() { class_name_ = "unstructured"; }
|
||||
Iterator* create() const override { return new Unstructured(); }
|
||||
|
||||
int init(grib_handle*, grib_arguments*) override;
|
||||
int next(double*, double*, double*) const override;
|
||||
int destroy() override;
|
||||
};
|
||||
|
||||
} // namespace eccodes::geo_iterator
|
|
@ -57,6 +57,7 @@ static const struct table_entry table[] = {
|
|||
{ "polar_stereographic", &grib_iterator_polar_stereographic, },
|
||||
{ "regular", &grib_iterator_regular, },
|
||||
{ "space_view", &grib_iterator_space_view, },
|
||||
{ "unstructured", &grib_iterator_unstructured, },
|
||||
};
|
||||
|
||||
eccodes::geo_iterator::Iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* error)
|
||||
|
|
|
@ -24,6 +24,7 @@ extern eccodes::geo_iterator::Iterator* grib_iterator_mercator;
|
|||
extern eccodes::geo_iterator::Iterator* grib_iterator_polar_stereographic;
|
||||
extern eccodes::geo_iterator::Iterator* grib_iterator_regular;
|
||||
extern eccodes::geo_iterator::Iterator* grib_iterator_space_view;
|
||||
extern eccodes::geo_iterator::Iterator* grib_iterator_unstructured;
|
||||
|
||||
|
||||
eccodes::geo_iterator::Iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* error);
|
||||
|
|
Loading…
Reference in New Issue