Skip to content

Commit 9cadd2f

Browse files
committed
Remove metkit/codes/GribAccessor
1 parent 85684a2 commit 9cadd2f

File tree

8 files changed

+27
-266
lines changed

8 files changed

+27
-266
lines changed

src/metkit/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ if ( HAVE_GRIB )
137137
codes/BufrContent.h
138138
codes/CodesSplitter.cc
139139
codes/CodesSplitter.h
140-
codes/GribAccessor.cc
141-
codes/GribAccessor.h
142140
codes/GribHandle.cc
143141
codes/GribHandle.h
144142
codes/GribIterator.cc

src/metkit/codes/GribAccessor.cc

Lines changed: 0 additions & 93 deletions
This file was deleted.

src/metkit/codes/GribAccessor.h

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/metkit/codes/GribHandle.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "eckit/io/DataHandle.h"
1717
#include "eckit/io/StdFile.h"
1818

19-
#include "metkit/codes/GribAccessor.h"
2019

2120
using namespace std;
2221

@@ -103,7 +102,12 @@ GribHandle::~GribHandle() noexcept(false) {
103102

104103
std::string GribHandle::geographyHash() const {
105104
// The following key is edition independent
106-
return GribAccessor<std::string>("md5GridSection")(*this);
105+
std::string ret;
106+
std::size_t keylen = 1024;
107+
ret.resize(keylen);
108+
CODES_CALL(codes_get_string(raw(), "md5GridSection", ret.data(), &keylen));
109+
ret.resize(strlen(ret.c_str()));
110+
return ret;
107111
}
108112

109113
size_t GribHandle::getDataValuesSize() const {

src/metkit/codes/GribHandle.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ namespace metkit {
2525
namespace grib {
2626

2727
class GribMetaData;
28-
class GribAccessorBase;
2928
class GribMutatorBase;
3029

3130
//----------------------------------------------------------------------------------------------------------------------
@@ -95,7 +94,6 @@ class GribHandle : private eckit::NonCopyable {
9594

9695
protected: // methods
9796

98-
friend class GribAccessorBase;
9997
friend class GribMutatorBase;
10098
friend class GribIterator;
10199

src/metkit/pointdb/GribFieldInfo.cc

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
*/
1010

1111
#include "metkit/pointdb/GribFieldInfo.h"
12-
#include <bitset>
13-
#include "metkit/codes/GribAccessor.h"
1412
#include "metkit/pointdb/GribDataSource.h"
13+
#include "metkit/codes/api/CodesAPI.h"
14+
15+
#include <bitset>
1516

1617
using namespace eckit;
1718
using namespace metkit::grib;
@@ -25,17 +26,6 @@ double grib_power(long s, long n);
2526
namespace metkit {
2627
namespace pointdb {
2728

28-
static GribAccessor<long> bitmapPresent("bitmapPresent");
29-
static GribAccessor<long> binaryScaleFactor("binaryScaleFactor");
30-
static GribAccessor<long> decimalScaleFactor("decimalScaleFactor");
31-
static GribAccessor<unsigned long> bitsPerValue("bitsPerValue");
32-
static GribAccessor<double> referenceValue("referenceValue");
33-
static GribAccessor<unsigned long> offsetBeforeData("offsetBeforeData");
34-
static GribAccessor<unsigned long> offsetBeforeBitmap("offsetBeforeBitmap");
35-
static GribAccessor<unsigned long> numberOfValues("numberOfValues");
36-
static GribAccessor<unsigned long> numberOfDataPoints("numberOfDataPoints");
37-
static GribAccessor<long> sphericalHarmonics("sphericalHarmonics");
38-
3929
static Mutex mutex;
4030

4131
#define MISSING 9999
@@ -63,23 +53,23 @@ GribFieldInfo::GribFieldInfo() :
6353
numberOfDataPoints_(0),
6454
sphericalHarmonics_(0) {}
6555

66-
void GribFieldInfo::update(const GribHandle& h) {
67-
binaryScaleFactor_ = binaryScaleFactor(h);
68-
decimalScaleFactor_ = decimalScaleFactor(h);
69-
bitsPerValue_ = bitsPerValue(h);
70-
referenceValue_ = referenceValue(h);
71-
offsetBeforeData_ = offsetBeforeData(h);
72-
numberOfDataPoints_ = numberOfDataPoints(h);
73-
numberOfValues_ = numberOfValues(h);
74-
sphericalHarmonics_ = sphericalHarmonics(h);
75-
76-
if (bitmapPresent(h))
77-
offsetBeforeBitmap_ = offsetBeforeBitmap(h);
56+
void GribFieldInfo::update(const codes::CodesHandle& h) {
57+
binaryScaleFactor_ = h.getLong("binaryScaleFactor");
58+
decimalScaleFactor_ = h.getLong("decimalScaleFactor");
59+
bitsPerValue_ = h.getLong("bitsPerValue");
60+
referenceValue_ = h.getDouble("referenceValue");
61+
offsetBeforeData_ = h.getLong("offsetBeforeData");
62+
numberOfDataPoints_ = h.getLong("numberOfDataPoints");
63+
numberOfValues_ = h.getLong("numberOfValues");
64+
sphericalHarmonics_ = h.getLong("sphericalHarmonics");
65+
66+
if (h.getLong("bitmapPresent"))
67+
offsetBeforeBitmap_ = h.getLong("offsetBeforeBitmap");
7868
else
7969
offsetBeforeBitmap_ = 0;
8070

8171
if (!sphericalHarmonics_)
82-
geographyHash_ = h.geographyHash();
72+
geographyHash_ = h.getString("md5GridSection");
8373
}
8474

8575
void GribFieldInfo::print(std::ostream& s) const {

src/metkit/pointdb/GribFieldInfo.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
#ifndef FieldInfoData_H
1212
#define FieldInfoData_H
1313

14+
15+
#include "metkit/codes/api/CodesAPI.h"
16+
1417
#include "eckit/io/Length.h"
1518
#include "eckit/io/Offset.h"
1619
#include "eckit/types/FixedString.h"
1720

1821

22+
1923
namespace eckit {
2024
class PathName;
2125
}
@@ -40,7 +44,7 @@ class GribFieldInfo {
4044

4145
bool ready() const { return numberOfValues_ > 0; }
4246

43-
void update(const grib::GribHandle& h);
47+
void update(const codes::CodesHandle& h);
4448

4549
double value(const GribDataSource&, size_t index) const;
4650

tests/test_gribhandle.cc

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)