Modernisation: Change namespace and move lats_ and lons_ to base class

This commit is contained in:
Eugen Betke 2024-10-21 17:19:39 +02:00
parent 80cc5a421b
commit f2c1a83c2b
33 changed files with 172 additions and 368 deletions

View File

@ -434,7 +434,12 @@ endforeach()
### include directories
include_directories( ${ECCODES_INCLUDE_DIRS} ${ECCODES_EXTRA_INCLUDE_DIRS} )
include_directories(
"accessor"
"geo_iterator"
${ECCODES_INCLUDE_DIRS}
${ECCODES_EXTRA_INCLUDE_DIRS}
)
add_subdirectory( definitions ) # must be before memfs
add_subdirectory( memfs )

View File

@ -331,20 +331,20 @@ list( APPEND eccodes_src_files
grib_nearest_class_mercator.cc
grib_nearest_class_polar_stereographic.cc
grib_nearest_class_space_view.cc
iterator/grib_iterator_class_polar_stereographic.cc
iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc
iterator/grib_iterator_class_lambert_conformal.cc
iterator/grib_iterator_class_mercator.cc
iterator/grib_iterator.cc
geo_iterator/grib_iterator_class_polar_stereographic.cc
geo_iterator/grib_iterator_class_lambert_azimuthal_equal_area.cc
geo_iterator/grib_iterator_class_lambert_conformal.cc
geo_iterator/grib_iterator_class_mercator.cc
geo_iterator/grib_iterator.cc
grib_iterator_class.cc
iterator/grib_iterator_class_gaussian.cc
iterator/grib_iterator_class_gaussian_reduced.cc
iterator/grib_iterator_class_latlon_reduced.cc
iterator/grib_iterator_class_gen.cc
iterator/grib_iterator_class_latlon.cc
iterator/grib_iterator_class_regular.cc
iterator/grib_iterator_class_space_view.cc
iterator/grib_iterator_class_healpix.cc
geo_iterator/grib_iterator_class_gaussian.cc
geo_iterator/grib_iterator_class_gaussian_reduced.cc
geo_iterator/grib_iterator_class_latlon_reduced.cc
geo_iterator/grib_iterator_class_gen.cc
geo_iterator/grib_iterator_class_latlon.cc
geo_iterator/grib_iterator_class_regular.cc
geo_iterator/grib_iterator_class_space_view.cc
geo_iterator/grib_iterator_class_healpix.cc
grib_expression.cc
codes_util.cc
grib_util.cc

View File

@ -23,5 +23,5 @@ public:
private:
grib_arguments* args_;
friend eccodes::grib::geo::Iterator* eccodes::grib::geo::gribIteratorNew(const grib_handle*, unsigned long, int*);
friend eccodes::geo_iterator::Iterator* eccodes::geo_iterator::gribIteratorNew(const grib_handle*, unsigned long, int*);
};

View File

@ -820,7 +820,7 @@ int grib_get_data(const grib_handle* h, double* lats, double* lons, double* valu
//int grib_iterator_delete(grib_iterator* i);
/* grib_iterator_class.cc */
eccodes::grib::geo::Iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* error);
eccodes::geo_iterator::Iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* error);
/* grib_iterator_class_gen.cc */
int transform_iterator_data(grib_context* c, double* data, long iScansNegatively, long jScansPositively, long jPointsAreConsecutive, long alternativeRowScanning, size_t numPoints, long nx, long ny);

View File

@ -12,15 +12,9 @@
* Jean Baptiste Filippi - 01.11.2005 *
***************************************************************************/
#include "grib_iterator.h"
#include "../accessor/grib_accessor_class_iterator.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
#include "accessor/grib_accessor_class_iterator.h"
namespace eccodes::geo_iterator {
int Iterator::init(grib_handle* h, grib_arguments* args)
{
@ -36,7 +30,7 @@ int Iterator::destroy()
return GRIB_SUCCESS;
}
eccodes::grib::geo::Iterator* gribIteratorNew(const grib_handle* ch, unsigned long flags, int* error)
eccodes::geo_iterator::Iterator* gribIteratorNew(const grib_handle* ch, unsigned long flags, int* error)
{
grib_handle* h = (grib_handle*)ch;
grib_accessor* a = NULL;
@ -48,7 +42,7 @@ eccodes::grib::geo::Iterator* gribIteratorNew(const grib_handle* ch, unsigned lo
if (!a)
return NULL;
eccodes::grib::geo::Iterator* iter = grib_iterator_factory(h, ita->args_, flags, error);
eccodes::geo_iterator::Iterator* iter = grib_iterator_factory(h, ita->args_, flags, error);
if (iter)
*error = GRIB_SUCCESS;
@ -56,7 +50,7 @@ eccodes::grib::geo::Iterator* gribIteratorNew(const grib_handle* ch, unsigned lo
return iter;
}
int gribIteratorDelete(eccodes::grib::geo::Iterator* i)
int gribIteratorDelete(eccodes::geo_iterator::Iterator* i)
{
if (i)
i->destroy();
@ -64,9 +58,7 @@ int gribIteratorDelete(eccodes::grib::geo::Iterator* i)
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator
/*
@ -104,7 +96,7 @@ int grib_iterator_destroy(grib_context* c, grib_iterator* i)
grib_iterator* grib_iterator_new(const grib_handle* ch, unsigned long flags, int* error)
{
grib_iterator* i = (grib_iterator*)grib_context_malloc_clear(ch->context, sizeof(grib_iterator));
i->iterator = eccodes::grib::geo::gribIteratorNew(ch, flags, error);
i->iterator = eccodes::geo_iterator::gribIteratorNew(ch, flags, error);
if (!i->iterator) {
grib_context_free(ch->context, i);
return NULL;

View File

@ -16,12 +16,7 @@
\ingroup grib_iterator
*/
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class Iterator
{
@ -51,9 +46,7 @@ private:
int inited_;
};
eccodes::grib::geo::Iterator* gribIteratorNew(const grib_handle*, unsigned long, int*);
int gribIteratorDelete(eccodes::grib::geo::Iterator*);
eccodes::geo_iterator::Iterator* gribIteratorNew(const grib_handle*, unsigned long, int*);
int gribIteratorDelete(eccodes::geo_iterator::Iterator*);
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -10,15 +10,10 @@
#include "grib_iterator_class_gaussian.h"
eccodes::grib::geo::Gaussian _grib_iterator_gaussian{};
eccodes::grib::geo::Iterator* grib_iterator_gaussian = &_grib_iterator_gaussian;
eccodes::geo_iterator::Gaussian _grib_iterator_gaussian{};
eccodes::geo_iterator::Iterator* grib_iterator_gaussian = &_grib_iterator_gaussian;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
static void binary_search_gaussian_latitudes(const double xx[], const unsigned long n, double x, long* j);
@ -81,13 +76,13 @@ int Gaussian::init(grib_handle* h, grib_arguments* args)
if (jScansPositively) {
for (lai = 0; lai < Nj_; lai++) {
DEBUG_ASSERT(istart >= 0);
las_[lai] = lats[istart--];
lats_[lai] = lats[istart--];
if (istart < 0) istart = size - 1;
}
}
else {
for (lai = 0; lai < Nj_; lai++) {
las_[lai] = lats[istart++];
lats_[lai] = lats[istart++];
if (istart > size - 1)
istart = 0;
}
@ -152,6 +147,4 @@ static void binary_search_gaussian_latitudes(const double array[], const unsigne
// *j = jl;
// }
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_regular.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class Gaussian : public Regular
{
@ -29,6 +24,5 @@ public:
int init(grib_handle*, grib_arguments*) override;
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -11,15 +11,10 @@
#include "grib_iterator_class_gaussian_reduced.h"
#include <cmath>
eccodes::grib::geo::GaussianReduced _grib_iterator_gaussian_reduced{};
eccodes::grib::geo::Iterator* grib_iterator_gaussian_reduced = &_grib_iterator_gaussian_reduced;
eccodes::geo_iterator::GaussianReduced _grib_iterator_gaussian_reduced{};
eccodes::geo_iterator::Iterator* grib_iterator_gaussian_reduced = &_grib_iterator_gaussian_reduced;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
#define ITER "Reduced Gaussian grid Geoiterator"
@ -31,8 +26,8 @@ int GaussianReduced::next(double* lat, double* lon, double* val) const
return 0;
e_++;
ret_lat = las_[e_];
ret_lon = los_[e_];
ret_lat = lats_[e_];
ret_lon = lons_[e_];
if (val && data_) {
*val = data_[e_];
}
@ -141,8 +136,8 @@ int GaussianReduced::iterate_reduced_gaussian_subarea_legacy(grib_handle* h,
return GRIB_WRONG_GRID;
}
los_[e_] = ((i) * 360.0) / pl[j];
las_[e_] = lats[j + l];
lons_[e_] = ((i) * 360.0) / pl[j];
lats_[e_] = lats[j + l];
e_++;
k++;
if (k >= row_count) {
@ -205,9 +200,9 @@ int GaussianReduced::iterate_reduced_gaussian_subarea(grib_handle* h,
"%s (sub-area). Num points=%zu, size(values)=%zu", ITER, np, nv_);
return GRIB_WRONG_GRID;
}
los_[e_] = lon2;
lons_[e_] = lon2;
DEBUG_ASSERT(j + l < numlats);
las_[e_] = lats[j + l];
lats_[e_] = lats[j + l];
e_++;
}
}
@ -308,11 +303,11 @@ int GaussianReduced::init(grib_handle* h, grib_arguments* args)
grib_get_long_array_internal(h, spl, pl, &plsize);
las_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
if (!las_)
lats_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
if (!lats_)
return GRIB_OUT_OF_MEMORY;
los_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
if (!los_)
lons_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
if (!lons_)
return GRIB_OUT_OF_MEMORY;
while (lon_last < 0)
@ -354,8 +349,8 @@ int GaussianReduced::init(grib_handle* h, grib_arguments* args)
goto finalise;
}
los_[e_] = (i * 360.0) / row_count;
las_[e_] = lats[j];
lons_[e_] = (i * 360.0) / row_count;
lats_[e_] = lats[j];
e_++;
}
}
@ -373,12 +368,10 @@ int GaussianReduced::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, las_);
grib_context_free(c, los_);
grib_context_free(c, lats_);
grib_context_free(c, lons_);
return Gen::destroy();
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class GaussianReduced : public Gen
{
@ -31,8 +26,6 @@ public:
int destroy() override;
private:
double* las_;
double* los_;
long Nj_;
long isRotated_;
double angleOfRotation_;
@ -51,6 +44,4 @@ private:
double*, long*, size_t, size_t);
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -10,12 +10,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
int Gen::init(grib_handle* h, grib_arguments* args)
{
@ -124,6 +119,4 @@ int Gen::next(double*, double*, double*) const
// return 1;
//}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class Gen : public Iterator
{
@ -35,12 +30,12 @@ public:
protected:
int carg_;
double* lats_;
double* lons_;
private:
const char* missingValue_;
// int get(double*, double*, double*);
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -14,18 +14,12 @@
#include <bitset>
#include <cmath>
#include <cstdint>
#include <tuple>
#include <vector>
eccodes::grib::geo::Healpix _grib_iterator_healpix;
eccodes::grib::geo::Iterator* grib_iterator_healpix = &_grib_iterator_healpix;
eccodes::geo_iterator::Healpix _grib_iterator_healpix;
eccodes::geo_iterator::Iterator* grib_iterator_healpix = &_grib_iterator_healpix;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
#define ITER "HEALPix Geoiterator"
constexpr double RAD2DEG = 57.29577951308232087684; // 180 over pi
@ -361,6 +355,4 @@ int Healpix::destroy()
return Gen::destroy();
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class Healpix : public Gen
{
@ -31,14 +26,10 @@ public:
int destroy() override;
private:
double* lats_;
double* lons_;
long Nsides_;
bool nested_;
int iterate_healpix(long N);
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -10,15 +10,10 @@
#include "grib_iterator_class_lambert_azimuthal_equal_area.h"
eccodes::grib::geo::LambertAzimuthalEqualArea _grib_iterator_lambert_azimuthal_equal_area{};
eccodes::grib::geo::Iterator* grib_iterator_lambert_azimuthal_equal_area = &_grib_iterator_lambert_azimuthal_equal_area;
eccodes::geo_iterator::LambertAzimuthalEqualArea _grib_iterator_lambert_azimuthal_equal_area{};
eccodes::geo_iterator::Iterator* grib_iterator_lambert_azimuthal_equal_area = &_grib_iterator_lambert_azimuthal_equal_area;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
#define ITER "Lambert azimuthal equal area Geoiterator"
@ -442,6 +437,4 @@ int LambertAzimuthalEqualArea::destroy()
return Gen::destroy();
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class LambertAzimuthalEqualArea : public Gen
{
@ -31,8 +26,6 @@ public:
int destroy() override;
private:
double* lats_;
double* lons_;
long Nj_;
int init_sphere(grib_handle*,
@ -50,6 +43,4 @@ private:
long, long, long);
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -11,15 +11,10 @@
#include "grib_iterator_class_lambert_conformal.h"
#include <cmath>
eccodes::grib::geo::LambertConformal _grib_iterator_lambert_conformal{};
eccodes::grib::geo::Iterator* grib_iterator_lambert_conformal = &_grib_iterator_lambert_conformal;
eccodes::geo_iterator::LambertConformal _grib_iterator_lambert_conformal{};
eccodes::geo_iterator::Iterator* grib_iterator_lambert_conformal = &_grib_iterator_lambert_conformal;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
#define ITER "Lambert conformal Geoiterator"
#define EPSILON 1.0e-10
@ -491,6 +486,4 @@ int LambertConformal::destroy()
return Gen::destroy();
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class LambertConformal : public Gen
{
@ -31,8 +26,6 @@ public:
int destroy() override;
private:
double* lats_;
double* lons_;
long Nj_;
int init_sphere(const grib_handle*,
@ -53,6 +46,4 @@ private:
double);
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -10,15 +10,10 @@
#include "grib_iterator_class_latlon.h"
eccodes::grib::geo::Latlon _grib_iterator_latlon{};
eccodes::grib::geo::Iterator* grib_iterator_latlon = &_grib_iterator_latlon;
eccodes::geo_iterator::Latlon _grib_iterator_latlon{};
eccodes::geo_iterator::Iterator* grib_iterator_latlon = &_grib_iterator_latlon;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
int Latlon::next(double* lat, double* lon, double* val) const
{
@ -34,15 +29,15 @@ int Latlon::next(double* lat, double* lon, double* val) const
*/
if (!jPointsAreConsecutive_) {
/* Adjacent points in i (x) direction are consecutive */
ret_lat = las_[(long)floor(e_ / Ni_)];
ret_lon = los_[(long)e_ % Ni_];
ret_lat = lats_[(long)floor(e_ / Ni_)];
ret_lon = lons_[(long)e_ % Ni_];
if (data_)
ret_val = data_[e_];
}
else {
/* Adjacent points in j (y) direction is consecutive */
ret_lon = los_[(long)e_ / Nj_];
ret_lat = las_[(long)floor(e_ % Nj_)];
ret_lon = lons_[(long)e_ / Nj_];
ret_lat = lats_[(long)floor(e_ % Nj_)];
if (data_)
ret_val = data_[e_];
}
@ -147,18 +142,16 @@ int Latlon::init(grib_handle* h, grib_arguments* args)
}
for (lai = 0; lai < Nj_; lai++) {
las_[lai] = lat1;
lats_[lai] = lat1;
lat1 -= jdir;
}
/* ECC-1406: Due to rounding, errors can accumulate.
* So we ensure the last latitude is latitudeOfLastGridPointInDegrees
*/
las_[Nj_ - 1] = lat2;
lats_[Nj_ - 1] = lat2;
e_ = -1;
return err;
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_regular.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class Latlon : public Regular
{
@ -30,6 +25,4 @@ public:
int next(double*, double*, double*) const override;
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -10,15 +10,10 @@
#include "grib_iterator_class_latlon_reduced.h"
eccodes::grib::geo::LatlonReduced _grib_iterator_latlon_reduced{};
eccodes::grib::geo::Iterator* grib_iterator_latlon_reduced = &_grib_iterator_latlon_reduced;
eccodes::geo_iterator::LatlonReduced _grib_iterator_latlon_reduced{};
eccodes::geo_iterator::Iterator* grib_iterator_latlon_reduced = &_grib_iterator_latlon_reduced;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
int LatlonReduced::next(double* lat, double* lon, double* val) const
{
@ -26,8 +21,8 @@ int LatlonReduced::next(double* lat, double* lon, double* val) const
return 0;
e_++;
*lat = las_[e_];
*lon = los_[e_];
*lat = lats_[e_];
*lon = lons_[e_];
if (val && data_) {
*val = data_[e_];
}
@ -83,8 +78,8 @@ int LatlonReduced::init(grib_handle* h, grib_arguments* args)
pl = (long*)grib_context_malloc(h->context, plsize * sizeof(long));
grib_get_long_array_internal(h, plac, pl, &plsize);
las_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
los_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
lats_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
lons_ = (double*)grib_context_malloc(h->context, nv_ * sizeof(double));
plmax = pl[0];
for (j = 0; j < nlats; j++)
@ -119,8 +114,8 @@ int LatlonReduced::init(grib_handle* h, grib_arguments* args)
nlons2 = 1;
idirinc = dlon / nlons2;
for (ii = 0; ii < nlons; ii++) {
las_[k] = laf;
los_[k] = tlof;
lats_[k] = laf;
lons_[k] = tlof;
tlof += idirinc;
k++;
}
@ -137,12 +132,10 @@ int LatlonReduced::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, las_);
grib_context_free(c, los_);
grib_context_free(c, lats_);
grib_context_free(c, lons_);
return Gen::destroy();
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class LatlonReduced : public Gen
{
@ -27,14 +22,8 @@ public:
Iterator* create() const override { return new LatlonReduced(); }
int init(grib_handle*, grib_arguments*) override;
int next(double* lat, double* lon, double* val) const override;
int next(double*, double*, double*) const override;
int destroy() override;
private:
double* las_;
double* los_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -10,15 +10,10 @@
#include "grib_iterator_class_mercator.h"
eccodes::grib::geo::Mercator _grib_iterator_mercator{};
eccodes::grib::geo::Iterator* grib_iterator_mercator = &_grib_iterator_mercator;
eccodes::geo_iterator::Mercator _grib_iterator_mercator{};
eccodes::geo_iterator::Iterator* grib_iterator_mercator = &_grib_iterator_mercator;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
#define ITER "Mercator Geoiterator"
#define EPSILON 1.0e-10
@ -286,6 +281,4 @@ int Mercator::destroy()
return Gen::destroy();
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class Mercator : public Gen
{
@ -26,12 +21,10 @@ public:
Iterator* create() const override { return new Mercator(); }
int init(grib_handle*, grib_arguments*) override;
int next(double* lat, double* lon, double* val) const override;
int next(double*, double*, double*) const override;
int destroy() override;
private:
double* lats_;
double* lons_;
long Nj_;
int init_mercator(grib_handle*,
@ -43,6 +36,4 @@ private:
double, double);
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -10,15 +10,10 @@
#include "grib_iterator_class_polar_stereographic.h"
eccodes::grib::geo::PolarStereographic _grib_iterator_polar_stereographic{};
eccodes::grib::geo::Iterator* grib_iterator_polar_stereographic = &_grib_iterator_polar_stereographic;
eccodes::geo_iterator::PolarStereographic _grib_iterator_polar_stereographic{};
eccodes::geo_iterator::Iterator* grib_iterator_polar_stereographic = &_grib_iterator_polar_stereographic;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
#define ITER "Polar stereographic Geoiterator"
@ -315,6 +310,4 @@ int PolarStereographic::destroy()
return Gen::destroy();
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class PolarStereographic : public Gen
{
@ -31,11 +26,7 @@ public:
int destroy() override;
private:
double* lats_;
double* lons_;
long Nj_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -10,15 +10,10 @@
#include "grib_iterator_class_regular.h"
eccodes::grib::geo::Regular _grib_iterator_regular{};
eccodes::grib::geo::Iterator* grib_iterator_regular = &_grib_iterator_regular;
eccodes::geo_iterator::Regular _grib_iterator_regular{};
eccodes::geo_iterator::Iterator* grib_iterator_regular = &_grib_iterator_regular;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
#define ITER "Regular grid Geoiterator"
@ -29,8 +24,8 @@ int Regular::next(double* lat, double* lon, double* val) const
e_++;
*lat = las_[(long)floor(e_ / Ni_)];
*lon = los_[(long)e_ % Ni_];
*lat = lats_[(long)floor(e_ / Ni_)];
*lon = lons_[(long)e_ % Ni_];
if (val && data_) {
*val = data_[e_];
}
@ -41,8 +36,8 @@ int Regular::previous(double* lat, double* lon, double* val) const
{
if (e_ < 0)
return 0;
*lat = las_[(long)floor(e_ / Ni_)];
*lon = los_[e_ % Ni_];
*lat = lats_[(long)floor(e_ / Ni_)];
*lon = lons_[e_ % Ni_];
if (val && data_) {
*val = data_[e_];
}
@ -54,8 +49,8 @@ int Regular::previous(double* lat, double* lon, double* val) const
int Regular::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, las_);
grib_context_free(c, los_);
grib_context_free(c, lats_);
grib_context_free(c, lons_);
return Gen::destroy();
}
@ -141,15 +136,15 @@ int Regular::init(grib_handle* h, grib_arguments* args)
Ni_ = Ni;
Nj_ = Nj;
las_ = (double*)grib_context_malloc(h->context, Nj * sizeof(double));
los_ = (double*)grib_context_malloc(h->context, Ni * sizeof(double));
lats_ = (double*)grib_context_malloc(h->context, Nj * sizeof(double));
lons_ = (double*)grib_context_malloc(h->context, Ni * sizeof(double));
if (idir != idir_coded) {
grib_context_log(h->context, GRIB_LOG_DEBUG, "%s: Using idir=%g (coded value=%g)", ITER, idir, idir_coded);
}
for (loi = 0; loi < Ni; loi++) {
los_[loi] = lon1;
lons_[loi] = lon1;
lon1 += idir;
}
@ -159,11 +154,9 @@ int Regular::init(grib_handle* h, grib_arguments* args)
if (lon2 > 0) {
lon2 = normalise_longitude_in_degrees(lon2);
}
los_[Ni - 1] = lon2;
lons_[Ni - 1] = lon2;
return ret;
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class Regular : public Gen
{
@ -26,15 +21,13 @@ public:
Iterator* create() const override { return new Regular(); }
int init(grib_handle*, grib_arguments*) override;
int next(double* lat, double* lon, double* val) const override;
int previous(double* lat, double* lon, double* val) const override;
int next(double*, double*, double*) const override;
int previous(double*, double*, double*) const override;
int destroy() override;
protected:
long Ni_;
long Nj_;
double* las_;
double* los_;
long iScansNegatively_;
long isRotated_;
double angleOfRotation_;
@ -44,6 +37,4 @@ protected:
long disableUnrotate_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -10,15 +10,10 @@
#include "grib_iterator_class_space_view.h"
eccodes::grib::geo::SpaceView _grib_iterator_space_view{};
eccodes::grib::geo::Iterator* grib_iterator_space_view = &_grib_iterator_space_view;
eccodes::geo_iterator::SpaceView _grib_iterator_space_view{};
eccodes::geo_iterator::Iterator* grib_iterator_space_view = &_grib_iterator_space_view;
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
#define ITER "Space view Geoiterator"
@ -326,6 +321,4 @@ int SpaceView::destroy()
return Gen::destroy();
}
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -12,12 +12,7 @@
#include "grib_iterator_class_gen.h"
namespace eccodes
{
namespace grib
{
namespace geo
{
namespace eccodes::geo_iterator {
class SpaceView : public Gen
{
@ -30,11 +25,7 @@ public:
int destroy() override;
private:
double* lats_;
double* lons_;
long Nj_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes
} // namespace eccodes::geo_iterator

View File

@ -248,12 +248,12 @@ typedef struct grib_codetable grib_codetable;
typedef struct grib_smart_table grib_smart_table;
class grib_accessor;
namespace eccodes::grib::geo {
namespace eccodes::geo_iterator {
class Iterator;
}
typedef struct grib_iterator {
eccodes::grib::geo::Iterator* iterator;
eccodes::geo_iterator::Iterator* iterator;
} grib_iterator;
typedef struct grib_nearest_class grib_nearest_class;
@ -1254,7 +1254,7 @@ typedef struct j2k_encode_helper
}
#include "accessor/grib_accessor.h"
#include "accessor/grib_accessors_list.h"
#include "iterator/grib_iterator.h"
#include "geo_iterator/grib_iterator.h"
#endif
#endif

View File

@ -14,8 +14,8 @@
***************************************************************************/
#include "grib_api_internal.h"
#include "./iterator/grib_iterator.h"
#include "./accessor/grib_accessor_class_iterator.h"
#include "geo_iterator/grib_iterator.h"
#include "accessor/grib_accessor_class_iterator.h"
/* This file is generated by ./make_class.pl */
#include "grib_iterator_class.h"
@ -51,7 +51,7 @@ static void init_mutex()
struct table_entry
{
const char* type;
eccodes::grib::geo::Iterator** iterator;
eccodes::geo_iterator::Iterator** iterator;
};
static const struct table_entry table[] = {
@ -60,7 +60,7 @@ static const struct table_entry table[] = {
};
eccodes::grib::geo::Iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* error)
eccodes::geo_iterator::Iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* error)
{
size_t i = 0, num_table_entries = 0;
const char* type = (char*)grib_arguments_get_name(h, args, 0);
@ -69,8 +69,8 @@ eccodes::grib::geo::Iterator* grib_iterator_factory(grib_handle* h, grib_argumen
num_table_entries = sizeof(table) / sizeof(table[0]);
for (i = 0; i < num_table_entries; i++) {
if (strcmp(type, table[i].type) == 0) {
eccodes::grib::geo::Iterator* builder = *(table[i].iterator);
eccodes::grib::geo::Iterator* it = builder->create();
eccodes::geo_iterator::Iterator* builder = *(table[i].iterator);
eccodes::geo_iterator::Iterator* it = builder->create();
it->flags_ = flags;
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
@ -95,10 +95,10 @@ eccodes::grib::geo::Iterator* grib_iterator_factory(grib_handle* h, grib_argumen
int grib_get_data(const grib_handle* h, double* lats, double* lons, double* values)
{
int err = 0;
eccodes::grib::geo::Iterator* iter = NULL;
eccodes::geo_iterator::Iterator* iter = NULL;
double *lat, *lon, *val;
iter = eccodes::grib::geo::gribIteratorNew(h, 0, &err);
iter = eccodes::geo_iterator::gribIteratorNew(h, 0, &err);
if (!iter || err != GRIB_SUCCESS)
return err;

View File

@ -1,13 +1,13 @@
/* This file is automatically generated by ./make_class.pl, do not edit */
extern eccodes::grib::geo::Iterator* grib_iterator_gaussian;
extern eccodes::grib::geo::Iterator* grib_iterator_gaussian_reduced;
//extern eccodes::grib::geo::Iterator* grib_iterator_gen;
extern eccodes::grib::geo::Iterator* grib_iterator_healpix;
extern eccodes::grib::geo::Iterator* grib_iterator_lambert_azimuthal_equal_area;
extern eccodes::grib::geo::Iterator* grib_iterator_lambert_conformal;
extern eccodes::grib::geo::Iterator* grib_iterator_latlon;
extern eccodes::grib::geo::Iterator* grib_iterator_latlon_reduced;
extern eccodes::grib::geo::Iterator* grib_iterator_mercator;
extern eccodes::grib::geo::Iterator* grib_iterator_polar_stereographic;
extern eccodes::grib::geo::Iterator* grib_iterator_regular;
extern eccodes::grib::geo::Iterator* grib_iterator_space_view;
extern eccodes::geo_iterator::Iterator* grib_iterator_gaussian;
extern eccodes::geo_iterator::Iterator* grib_iterator_gaussian_reduced;
//extern eccodes::geo_iterator::Iterator* grib_iterator_gen;
extern eccodes::geo_iterator::Iterator* grib_iterator_healpix;
extern eccodes::geo_iterator::Iterator* grib_iterator_lambert_azimuthal_equal_area;
extern eccodes::geo_iterator::Iterator* grib_iterator_lambert_conformal;
extern eccodes::geo_iterator::Iterator* grib_iterator_latlon;
extern eccodes::geo_iterator::Iterator* grib_iterator_latlon_reduced;
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;