Modernisation: Introduce namespaces and change class names

This commit is contained in:
Eugen Betke 2024-09-24 11:04:11 +02:00
parent 1afda19f17
commit 2122cd6ef9
25 changed files with 332 additions and 129 deletions

View File

@ -16,7 +16,11 @@
\ingroup grib_iterator
*/
class grib_iterator
namespace eccodes {
namespace grib {
namespace geo {
class Iterator
{
public:
virtual int init(grib_handle*, grib_arguments*) = 0;
@ -38,3 +42,7 @@ public:
size_t size_;
int inited_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -9,16 +9,19 @@
*/
#include "grib_iterator_class_gaussian.h"
#include <cmath>
grib_iterator_gaussian_t _grib_iterator_gaussian{};
grib_iterator* grib_iterator_gaussian = &_grib_iterator_gaussian;
namespace eccodes {
namespace grib {
namespace geo {
Gaussian _grib_iterator_gaussian{};
Iterator* grib_iterator_gaussian = &_grib_iterator_gaussian;
static void binary_search_gaussian_latitudes(const double xx[], const unsigned long n, double x, long* j);
int grib_iterator_gaussian_t::init(grib_handle* h, grib_arguments* args)
int Gaussian::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_regular_t::init(h, args);
Regular::init(h, args);
double* lats;
double laf; /* latitude of first point in degrees */
@ -144,3 +147,7 @@ static void binary_search_gaussian_latitudes(const double array[], const unsigne
// }
// *j = jl;
// }
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -8,14 +8,24 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
#pragma once
#include "grib_iterator_class_regular.h"
class grib_iterator_gaussian_t : public grib_iterator_regular_t
namespace eccodes {
namespace grib {
namespace geo {
class Gaussian : public Regular
{
public:
grib_iterator_gaussian_t() : grib_iterator_regular_t()
Gaussian() : Regular()
{
class_name_ = "gaussian";
}
int init(grib_handle*, grib_arguments*);
int init(grib_handle*, grib_arguments*) override;
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -11,13 +11,16 @@
#include "grib_iterator_class_gaussian_reduced.h"
#include <cmath>
namespace eccodes {
namespace grib {
namespace geo {
grib_iterator_gaussian_reduced_t _grib_iterator_gaussian_reduced{};
grib_iterator* grib_iterator_gaussian_reduced = &_grib_iterator_gaussian_reduced;
GaussianReduced _grib_iterator_gaussian_reduced{};
Iterator* grib_iterator_gaussian_reduced = &_grib_iterator_gaussian_reduced;
#define ITER "Reduced Gaussian grid Geoiterator"
int grib_iterator_gaussian_reduced_t::next(double* lat, double* lon, double* val)
int GaussianReduced::next(double* lat, double* lon, double* val)
{
double ret_lat=0, ret_lon=0;
@ -94,7 +97,7 @@ static void binary_search(const double xx[], const unsigned long n, double x, lo
}
/* Use legacy way to compute the iterator latitude/longitude values */
int grib_iterator_gaussian_reduced_t::iterate_reduced_gaussian_subarea_legacy(grib_handle* h,
int GaussianReduced::iterate_reduced_gaussian_subarea_legacy(grib_handle* h,
double lat_first, double lon_first,
double lat_last, double lon_last,
double* lats, long* pl, size_t plsize)
@ -156,7 +159,7 @@ int grib_iterator_gaussian_reduced_t::iterate_reduced_gaussian_subarea_legacy(gr
// err = iterate_reduced_gaussian_subarea_algorithm2(iter, h, lat_first, lon_first, lat_last, lon_last, lats, pl, plsize);
// }
// return err;
int grib_iterator_gaussian_reduced_t::iterate_reduced_gaussian_subarea(grib_handle* h,
int GaussianReduced::iterate_reduced_gaussian_subarea(grib_handle* h,
double lat_first, double lon_first,
double lat_last, double lon_last,
double* lats, long* pl, size_t plsize, size_t numlats)
@ -220,9 +223,9 @@ int grib_iterator_gaussian_reduced_t::iterate_reduced_gaussian_subarea(grib_hand
return err;
}
int grib_iterator_gaussian_reduced_t::init(grib_handle* h, grib_arguments* args)
int GaussianReduced::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_gen_t::init(h, args);
Gen::init(h, args);
int ret = GRIB_SUCCESS, j, is_global = 0;
double lat_first = 0, lon_first = 0, lat_last = 0, lon_last = 0;
@ -361,13 +364,17 @@ finalise:
return ret;
}
int grib_iterator_gaussian_reduced_t::destroy()
int GaussianReduced::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, las_);
grib_context_free(c, los_);
grib_iterator_gen_t::destroy();
Gen::destroy();
return GRIB_SUCCESS;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_gen.h"
class grib_iterator_gaussian_reduced_t : public grib_iterator_gen_t
namespace eccodes {
namespace grib {
namespace geo {
class GaussianReduced : public Gen
{
public:
grib_iterator_gaussian_reduced_t() : grib_iterator_gen_t()
GaussianReduced() : Gen()
{
class_name_ = "gaussian_reduced";
}
@ -44,3 +48,7 @@ int iterate_reduced_gaussian_subarea(grib_handle*,
double, double,
double*, long*, size_t, size_t);
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -10,8 +10,12 @@
#include "grib_iterator_class_gen.h"
//grib_iterator_gen_t _grib_iterator_class_gen{};
//grib_iterator* grib_iterator_class_gen = &_grib_iterator_class_gen;
namespace eccodes {
namespace grib {
namespace geo {
//Gen _grib_iterator_class_gen{};
//Iterator* grib_iterator_class_gen = &_grib_iterator_class_gen;
/*
@ -110,9 +114,9 @@ int transform_iterator_data(grib_context* context, double* data,
return GRIB_SUCCESS;
}
int grib_iterator_gen_t::init(grib_handle* h, grib_arguments* args)
int Gen::init(grib_handle* h, grib_arguments* args)
{
grib_iterator::init(h, args);
Iterator::init(h, args);
size_t dli = 0;
int err = GRIB_SUCCESS;
@ -169,22 +173,22 @@ int grib_iterator_gen_t::init(grib_handle* h, grib_arguments* args)
return err;
}
int grib_iterator_gen_t::reset()
int Gen::reset()
{
e_ = -1;
return 0;
}
int grib_iterator_gen_t::destroy()
int Gen::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, data_);
grib_iterator::destroy();
Iterator::destroy();
return GRIB_SUCCESS;
}
long grib_iterator_gen_t::has_next()
long Gen::has_next()
{
if (flags_ == 0 && data_ == NULL)
return 0;
@ -194,11 +198,28 @@ long grib_iterator_gen_t::has_next()
}
int grib_iterator_gen_t::previous(double*, double*, double*) {
int Gen::previous(double*, double*, double*) {
return GRIB_NOT_IMPLEMENTED;
}
int grib_iterator_gen_t::next(double*, double*, double*) {
int Gen::next(double*, double*, double*) {
return GRIB_NOT_IMPLEMENTED;
}
int Gen::get(double* lat, double* lon, double* val)
{
if (e_ >= (long)(nv_ - 1))
return GRIB_END_OF_ITERATION;
e_++;
if (lat) *lat = 0;
if (lon) *lon = 0;
if (val) *val = 0;
return 1;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator.h"
class grib_iterator_gen_t : public grib_iterator
namespace eccodes {
namespace grib {
namespace geo { // TODO(maee): geo
class Gen : public Iterator
{
public:
grib_iterator_gen_t() : grib_iterator()
Gen() : Iterator()
{
class_name_ = "abstract_long_vector";
}
@ -25,9 +29,13 @@ public:
int previous(double*, double*, double*) override;
int reset() override;
int destroy() override;
long has_next() override;
long has_next() override; // TODO(maee/masn): return bool please!
public:
int carg_;
const char* missingValue_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -10,6 +10,10 @@
#include "grib_iterator_class_healpix.h"
namespace eccodes {
namespace grib {
namespace geo {
#include <algorithm>
#include <bitset>
#include <cmath>
@ -17,15 +21,16 @@
#include <tuple>
#include <vector>
grib_iterator_healpix_t _grib_iterator_healpix;
grib_iterator* grib_iterator_healpix = &_grib_iterator_healpix;
namespace eccodes {
namespace grib {
namespace geo {
Healpix _grib_iterator_healpix;
Iterator* grib_iterator_healpix = &_grib_iterator_healpix;
#define ITER "HEALPix Geoiterator"
constexpr double RAD2DEG = 57.29577951308232087684; // 180 over pi
namespace
{
struct CodecFijNest
{
static constexpr uint64_t __masks[] = { 0x00000000ffffffff, 0x0000ffff0000ffff, 0x00ff00ff00ff00ff,
@ -144,7 +149,7 @@ static std::vector<double> HEALPix_longitudes(size_t N, size_t i)
} // anonymous namespace
int grib_iterator_healpix_t::iterate_healpix(long N)
int Healpix::iterate_healpix(long N)
{
size_t Ny = 4 * static_cast<size_t>(N) - 1;
auto Nd = static_cast<double>(N);
@ -265,9 +270,9 @@ int grib_iterator_healpix_t::iterate_healpix(long N)
return GRIB_SUCCESS;
}
int grib_iterator_healpix_t::init(grib_handle* h, grib_arguments* args)
int Healpix::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_gen_t::init(h, args);
Gen::init(h, args);
int err = 0;
@ -332,7 +337,7 @@ int grib_iterator_healpix_t::init(grib_handle* h, grib_arguments* args)
return err;
}
int grib_iterator_healpix_t::next(double* lat, double* lon, double* val)
int Healpix::next(double* lat, double* lon, double* val)
{
if (e_ >= static_cast<long>(nv_ - 1)) {
return 0;
@ -348,11 +353,15 @@ int grib_iterator_healpix_t::next(double* lat, double* lon, double* val)
return 1;
}
int grib_iterator_healpix_t::destroy()
int Healpix::destroy()
{
grib_context_free(context_, lats_);
grib_context_free(context_, lons_);
grib_iterator_gen_t::destroy();
Gen::destroy();
return GRIB_SUCCESS;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_gen.h"
class grib_iterator_healpix_t : public grib_iterator_gen_t
namespace eccodes {
namespace grib {
namespace geo {
class Healpix : public Gen
{
public:
grib_iterator_healpix_t() : grib_iterator_gen_t()
Healpix() : Gen()
{
class_name_ = "healpix";
}
@ -33,3 +37,7 @@ public:
private:
int iterate_healpix(long N);
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -9,16 +9,17 @@
*/
#include "grib_iterator_class_lambert_azimuthal_equal_area.h"
#include <cmath>
namespace eccodes {
namespace grib {
namespace geo {
grib_iterator_lambert_azimuthal_equal_area_t _grib_iterator_lambert_azimuthal_equal_area{};
grib_iterator* grib_iterator_lambert_azimuthal_equal_area = &_grib_iterator_lambert_azimuthal_equal_area;
LambertAzimuthalEqualArea _grib_iterator_lambert_azimuthal_equal_area{};
Iterator* grib_iterator_lambert_azimuthal_equal_area = &_grib_iterator_lambert_azimuthal_equal_area;
#define ITER "Lambert azimuthal equal area Geoiterator"
int grib_iterator_lambert_azimuthal_equal_area_t::next(double* lat, double* lon, double* val)
int LambertAzimuthalEqualArea::next(double* lat, double* lon, double* val)
{
if ((long)e_ >= (long)(nv_ - 1))
return 0;
@ -94,7 +95,7 @@ static double pj_qsfn(double sinphi, double e, double one_es)
#define EPS10 1.e-10
static int init_oblate(grib_handle* h,
grib_iterator_lambert_azimuthal_equal_area_t* self,
LambertAzimuthalEqualArea* self,
size_t nv, long nx, long ny,
double Dx, double Dy, double earthMinorAxisInMetres, double earthMajorAxisInMetres,
double latFirstInRadians, double lonFirstInRadians,
@ -225,7 +226,7 @@ static int init_oblate(grib_handle* h,
}
static int init_sphere(grib_handle* h,
grib_iterator_lambert_azimuthal_equal_area_t* self,
LambertAzimuthalEqualArea* self,
size_t nv, long nx, long ny,
double Dx, double Dy, double radius,
double latFirstInRadians, double lonFirstInRadians,
@ -331,9 +332,9 @@ static int init_sphere(grib_handle* h,
return GRIB_SUCCESS;
}
int grib_iterator_lambert_azimuthal_equal_area_t::init(grib_handle* h, grib_arguments* args)
int LambertAzimuthalEqualArea::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_gen_t::init(h, args);
Gen::init(h, args);
int err = 0;
int is_oblate = 0;
@ -426,13 +427,17 @@ int grib_iterator_lambert_azimuthal_equal_area_t::init(grib_handle* h, grib_argu
return GRIB_SUCCESS;
}
int grib_iterator_lambert_azimuthal_equal_area_t::destroy()
int LambertAzimuthalEqualArea::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, lats_);
grib_context_free(c, lons_);
grib_iterator_gen_t::destroy();
Gen::destroy();
return GRIB_SUCCESS;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_gen.h"
class grib_iterator_lambert_azimuthal_equal_area_t : public grib_iterator_gen_t
namespace eccodes {
namespace grib {
namespace geo {
class LambertAzimuthalEqualArea : public Gen
{
public:
grib_iterator_lambert_azimuthal_equal_area_t() : grib_iterator_gen_t()
LambertAzimuthalEqualArea() : Gen()
{
class_name_ = "lambert_azimuthal_equal_area";
}
@ -30,3 +34,7 @@ public:
double *lons_;
long Nj_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -11,8 +11,12 @@
#include "grib_iterator_class_lambert_conformal.h"
#include <cmath>
grib_iterator_lambert_conformal_t _grib_iterator_lambert_conformal{};
grib_iterator* grib_iterator_lambert_conformal = &_grib_iterator_lambert_conformal;
namespace eccodes {
namespace grib {
namespace geo {
LambertConformal _grib_iterator_lambert_conformal{};
Iterator* grib_iterator_lambert_conformal = &_grib_iterator_lambert_conformal;
#define ITER "Lambert conformal Geoiterator"
#define EPSILON 1.0e-10
@ -121,7 +125,7 @@ static void xy2lonlat(double radius, double n, double f, double rho0_bare, doubl
}
}
int grib_iterator_lambert_conformal_t::init_sphere(const grib_handle* h,
int LambertConformal::init_sphere(const grib_handle* h,
size_t nv, long nx, long ny,
double LoVInDegrees,
double Dx, double Dy, double radius,
@ -210,7 +214,7 @@ int grib_iterator_lambert_conformal_t::init_sphere(const grib_handle* h,
}
// Oblate spheroid
int grib_iterator_lambert_conformal_t::init_oblate(const grib_handle* h,
int LambertConformal::init_oblate(const grib_handle* h,
size_t nv, long nx, long ny,
double LoVInDegrees,
double Dx, double Dy,
@ -339,9 +343,9 @@ int grib_iterator_lambert_conformal_t::init_oblate(const grib_handle* h,
return GRIB_SUCCESS;
}
int grib_iterator_lambert_conformal_t::init(grib_handle* h, grib_arguments* args)
int LambertConformal::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_gen_t::init(h, args);
Gen::init(h, args);
int err = 0, is_oblate = 0;
long nx, ny, iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning;
@ -452,7 +456,7 @@ int grib_iterator_lambert_conformal_t::init(grib_handle* h, grib_arguments* args
return err;
}
int grib_iterator_lambert_conformal_t::next(double* lat, double* lon, double* val)
int LambertConformal::next(double* lat, double* lon, double* val)
{
if ((long)e_ >= (long)(nv_ - 1))
return 0;
@ -466,13 +470,17 @@ int grib_iterator_lambert_conformal_t::next(double* lat, double* lon, double* va
return 1;
}
int grib_iterator_lambert_conformal_t::destroy()
int LambertConformal::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, lats_);
grib_context_free(c, lons_);
grib_iterator_gen_t::destroy();
Gen::destroy();
return GRIB_SUCCESS;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_gen.h"
class grib_iterator_lambert_conformal_t : public grib_iterator_gen_t
namespace eccodes {
namespace grib {
namespace geo {
class LambertConformal : public Gen
{
public:
grib_iterator_lambert_conformal_t() : grib_iterator_gen_t()
LambertConformal() : Gen()
{
class_name_ = "lambert_conformal";
}
@ -46,3 +50,7 @@ private:
double, double, double,
double);
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -10,11 +10,15 @@
#include "grib_iterator_class_latlon.h"
grib_iterator_latlon_t _grib_iterator_latlon{};
grib_iterator* grib_iterator_latlon = &_grib_iterator_latlon;
namespace eccodes {
namespace grib {
namespace geo {
Latlon _grib_iterator_latlon{};
Iterator* grib_iterator_latlon = &_grib_iterator_latlon;
int grib_iterator_latlon_t::next(double* lat, double* lon, double* val)
int Latlon::next(double* lat, double* lon, double* val)
{
/* GRIB-238: Support rotated lat/lon grids */
double ret_lat, ret_lon, ret_val=0;
@ -59,9 +63,9 @@ int grib_iterator_latlon_t::next(double* lat, double* lon, double* val)
return 1;
}
int grib_iterator_latlon_t::init(grib_handle* h, grib_arguments* args)
int Latlon::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_regular_t::init(h, args);
Regular::init(h, args);
int err = 0;
double jdir;
@ -150,3 +154,7 @@ int grib_iterator_latlon_t::init(grib_handle* h, grib_arguments* args)
e_ = -1;
return err;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_regular.h"
class grib_iterator_latlon_t : public grib_iterator_regular_t
namespace eccodes {
namespace grib {
namespace geo {
class Latlon : public Regular
{
public:
grib_iterator_latlon_t() : grib_iterator_regular_t()
Latlon() : Regular()
{
class_name_ = "latlon";
}
@ -23,3 +27,7 @@ public:
int init(grib_handle*, grib_arguments*) override;
int next(double*, double*, double*) override;
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -9,13 +9,16 @@
*/
#include "grib_iterator_class_latlon_reduced.h"
#include <cmath>
grib_iterator_latlon_reduced_t _grib_iterator_latlon_reduced{};
grib_iterator* grib_iterator_latlon_reduced = &_grib_iterator_latlon_reduced;
namespace eccodes {
namespace grib {
namespace geo {
LatlonReduced _grib_iterator_latlon_reduced{};
Iterator* grib_iterator_latlon_reduced = &_grib_iterator_latlon_reduced;
int grib_iterator_latlon_reduced_t::next(double* lat, double* lon, double* val)
int LatlonReduced::next(double* lat, double* lon, double* val)
{
if ((long)e_ >= (long)(nv_ - 1))
return 0;
@ -29,9 +32,9 @@ int grib_iterator_latlon_reduced_t::next(double* lat, double* lon, double* val)
return 1;
}
int grib_iterator_latlon_reduced_t::init(grib_handle* h, grib_arguments* args)
int LatlonReduced::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_gen_t::init(h, args);
Gen::init(h, args);
int ret = GRIB_SUCCESS;
double laf;
@ -127,13 +130,17 @@ int grib_iterator_latlon_reduced_t::init(grib_handle* h, grib_arguments* args)
return ret;
}
int grib_iterator_latlon_reduced_t::destroy()
int LatlonReduced::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, las_);
grib_context_free(c, los_);
grib_iterator_gen_t::destroy();
Gen::destroy();
return GRIB_SUCCESS;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_gen.h"
class grib_iterator_latlon_reduced_t : public grib_iterator_gen_t
namespace eccodes {
namespace grib {
namespace geo {
class LatlonReduced : public Gen
{
public:
grib_iterator_latlon_reduced_t() : grib_iterator_gen_t()
LatlonReduced() : Gen()
{
class_name_ = "latlon_reduced";
}
@ -28,3 +32,7 @@ private:
double* las_;
double* los_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -9,10 +9,13 @@
*/
#include "grib_iterator_class_mercator.h"
#include <cmath>
grib_iterator_mercator_t _grib_iterator_mercator{};
grib_iterator* grib_iterator_mercator = &_grib_iterator_mercator;
namespace eccodes {
namespace grib {
namespace geo {
Mercator _grib_iterator_mercator{};
Iterator* grib_iterator_mercator = &_grib_iterator_mercator;
#define ITER "Mercator Geoiterator"
#define EPSILON 1.0e-10
@ -81,7 +84,7 @@ static double compute_t(
return (tan(0.5 * (M_PI_2 - phi)) / con);
}
int grib_iterator_mercator_t::init_mercator(grib_handle* h,
int Mercator::init_mercator(grib_handle* h,
size_t nv, long nx, long ny,
double DiInMetres, double DjInMetres,
double earthMinorAxisInMetres, double earthMajorAxisInMetres,
@ -160,9 +163,9 @@ int grib_iterator_mercator_t::init_mercator(grib_handle* h,
return GRIB_SUCCESS;
}
int grib_iterator_mercator_t::init(grib_handle* h, grib_arguments* args)
int Mercator::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_gen_t::init(h, args);
Gen::init(h, args);
int err = 0;
long ni, nj, iScansNegatively, jScansPositively, jPointsAreConsecutive, alternativeRowScanning;
@ -255,7 +258,7 @@ int grib_iterator_mercator_t::init(grib_handle* h, grib_arguments* args)
return err;
}
int grib_iterator_mercator_t::next(double* lat, double* lon, double* val)
int Mercator::next(double* lat, double* lon, double* val)
{
if ((long)e_ >= (long)(nv_ - 1))
return 0;
@ -269,13 +272,17 @@ int grib_iterator_mercator_t::next(double* lat, double* lon, double* val)
return 1;
}
int grib_iterator_mercator_t::destroy()
int Mercator::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, lats_);
grib_context_free(c, lons_);
grib_iterator_gen_t::destroy();
Gen::destroy();
return GRIB_SUCCESS;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_gen.h"
class grib_iterator_mercator_t : public grib_iterator_gen_t
namespace eccodes {
namespace grib {
namespace geo {
class Mercator : public Gen
{
public:
grib_iterator_mercator_t() {
Mercator() {
class_name_ = "mercator";
}
int init(grib_handle*,grib_arguments*) override;
@ -36,3 +40,6 @@ private:
double, double);
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -9,14 +9,17 @@
*/
#include "grib_iterator_class_polar_stereographic.h"
#include <cmath>
grib_iterator_polar_stereographic_t _grib_iterator_polar_stereographic{};
grib_iterator* grib_iterator_polar_stereographic = &_grib_iterator_polar_stereographic;
namespace eccodes {
namespace grib {
namespace geo {
PolarStereographic _grib_iterator_polar_stereographic{};
Iterator* grib_iterator_polar_stereographic = &_grib_iterator_polar_stereographic;
#define ITER "Polar stereographic Geoiterator"
int grib_iterator_polar_stereographic_t::next(double* lat, double* lon, double* val)
int PolarStereographic::next(double* lat, double* lon, double* val)
{
if ((long)e_ >= (long)(nv_ - 1))
return 0;
@ -48,9 +51,9 @@ typedef struct proj_data_t
#define PI_OVER_2 1.5707963267948966 /* half pi */
#define EPSILON 1.0e-10
int grib_iterator_polar_stereographic_t::init(grib_handle* h, grib_arguments* args)
int PolarStereographic::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_gen_t::init(h, args);
Gen::init(h, args);
int ret = 0;
double *lats, *lons; /* arrays for latitudes and longitudes */
@ -294,13 +297,17 @@ int grib_iterator_polar_stereographic_t::init(grib_handle* h, grib_arguments* ar
return ret;
}
int grib_iterator_polar_stereographic_t::destroy()
int PolarStereographic::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, lats_);
grib_context_free(c, lons_);
grib_iterator_gen_t::destroy();
Gen::destroy();
return GRIB_SUCCESS;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_gen.h"
class grib_iterator_polar_stereographic_t : public grib_iterator_gen_t
namespace eccodes {
namespace grib {
namespace geo {
class PolarStereographic : public Gen
{
public:
grib_iterator_polar_stereographic_t() : grib_iterator_gen_t()
PolarStereographic() : Gen()
{
class_name_ = "polar_stereographic";
}
@ -30,3 +34,6 @@ private:
long Nj_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -9,14 +9,17 @@
*/
#include "grib_iterator_class_regular.h"
#include <cmath>
grib_iterator_regular_t _grib_iterator_regular{};
grib_iterator_regular_t* grib_iterator_regular = &_grib_iterator_regular;
namespace eccodes {
namespace grib {
namespace geo {
Regular _grib_iterator_regular{};
Iterator* grib_iterator_regular = &_grib_iterator_regular;
#define ITER "Regular grid Geoiterator"
int grib_iterator_regular_t::next(double* lat, double* lon, double* val)
int Regular::next(double* lat, double* lon, double* val)
{
if ((long)e_ >= (long)(nv_ - 1))
return 0;
@ -31,7 +34,7 @@ int grib_iterator_regular_t::next(double* lat, double* lon, double* val)
return 1;
}
int grib_iterator_regular_t::previous(double* lat, double* lon, double* val)
int Regular::previous(double* lat, double* lon, double* val)
{
if (e_ < 0)
return 0;
@ -45,19 +48,19 @@ int grib_iterator_regular_t::previous(double* lat, double* lon, double* val)
return 1;
}
int grib_iterator_regular_t::destroy()
int Regular::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, las_);
grib_context_free(c, los_);
grib_iterator_gen_t::destroy();
Gen::destroy();
return GRIB_SUCCESS;
}
int grib_iterator_regular_t::init(grib_handle* h, grib_arguments* args)
int Regular::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_gen_t::init(h, args);
Gen::init(h, args);
int ret = GRIB_SUCCESS;
@ -158,3 +161,7 @@ int grib_iterator_regular_t::init(grib_handle* h, grib_arguments* args)
return ret;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_gen.h"
class grib_iterator_regular_t : public grib_iterator_gen_t
namespace eccodes {
namespace grib {
namespace geo {
class Regular : public Gen
{
public:
grib_iterator_regular_t()
Regular()
{
class_name_ = "regular";
}
@ -38,3 +42,7 @@ protected:
long jPointsAreConsecutive_;
long disableUnrotate_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -9,14 +9,17 @@
*/
#include "grib_iterator_class_space_view.h"
#include <cmath>
grib_iterator_space_view_t _grib_iterator_space_view{};
grib_iterator* grib_iterator_space_view = &_grib_iterator_space_view;
namespace eccodes {
namespace grib {
namespace geo {
SpaceView _grib_iterator_space_view{};
Iterator* grib_iterator_space_view = &_grib_iterator_space_view;
#define ITER "Space view Geoiterator"
int grib_iterator_space_view_t::next(double* lat, double* lon, double* val)
int SpaceView::next(double* lat, double* lon, double* val)
{
if ((long)e_ >= (long)(nv_ - 1))
return 0;
@ -73,9 +76,9 @@ int grib_iterator_space_view_t::next(double* lat, double* lon, double* val)
#define RAD2DEG 57.29577951308232087684 /* 180 over pi */
#define DEG2RAD 0.01745329251994329576 /* pi over 180 */
int grib_iterator_space_view_t::init(grib_handle* h, grib_arguments* args)
int SpaceView::init(grib_handle* h, grib_arguments* args)
{
grib_iterator_gen_t::init(h, args);
Gen::init(h, args);
/* REFERENCE:
* LRIT/HRIT Global Specification (CGMS 03, Issue 2.6, 12.08.1999)
@ -309,13 +312,17 @@ int grib_iterator_space_view_t::init(grib_handle* h, grib_arguments* args)
return ret;
}
int grib_iterator_space_view_t::destroy()
int SpaceView::destroy()
{
const grib_context* c = h_->context;
grib_context_free(c, lats_);
grib_context_free(c, lons_);
grib_iterator_gen_t::destroy();
Gen::destroy();
return GRIB_SUCCESS;
}
} // namespace geo
} // namespace grib
} // namespace eccodes

View File

@ -12,10 +12,14 @@
#include "grib_iterator_class_gen.h"
class grib_iterator_space_view_t : public grib_iterator_gen_t
namespace eccodes {
namespace grib {
namespace geo {
class SpaceView : public Gen
{
public:
grib_iterator_space_view_t()
SpaceView()
{
class_name_ = "space_view";
}
@ -30,3 +34,6 @@ private:
long Nj_;
};
} // namespace geo
} // namespace grib
} // namespace eccodes