10 #if !defined(GEOGRAPHICLIB_GEOID_HPP)
11 #define GEOGRAPHICLIB_GEOID_HPP 1
19 # pragma warning (push)
20 # pragma warning (disable: 4251 4127)
23 #if !defined(GEOGRAPHICLIB_GEOID_PGM_PIXEL_WIDTH)
31 # define GEOGRAPHICLIB_GEOID_PGM_PIXEL_WIDTH 2
85 #if GEOGRAPHICLIB_GEOID_PGM_PIXEL_WIDTH != 4
87 static const unsigned pixel_size_ = 2;
88 static const unsigned pixel_max_ = 0xffffu;
91 static const unsigned pixel_size_ = 4;
92 static const unsigned pixel_max_ = 0xffffffffu;
94 static const unsigned stencilsize_ = 12;
95 static const unsigned nterms_ = ((3 + 1) * (3 + 2))/2;
99 static const int c3_[stencilsize_ * nterms_];
100 static const int c3n_[stencilsize_ * nterms_];
101 static const int c3s_[stencilsize_ * nterms_];
114 mutable std::vector< std::vector<pixel_t> >
_data;
117 mutable int _xoffset, _yoffset, _xsize,
_ysize;
124 #
if !(defined(__GNUC__) && __GNUC__ < 4)
129 pixel_size_ * (
unsigned(iy)*_swidth +
unsigned(ix))));
134 else if (ix >= _width)
136 if (_cache && iy >= _yoffset && iy < _yoffset + _ysize &&
137 ((ix >= _xoffset && ix < _xoffset + _xsize) ||
138 (ix + _width >= _xoffset && ix + _width < _xoffset + _xsize))) {
139 return real(_data[iy - _yoffset]
140 [ix >= _xoffset ? ix - _xoffset : ix + _width - _xoffset]);
142 if (iy < 0 || iy >= _height) {
143 iy = iy < 0 ? -iy : 2 * (_height - 1) - iy;
144 ix += (ix < _width/2 ? 1 : -1) * _width/2;
152 unsigned r = ((
unsigned char)(
a) << 8) | (
unsigned char)(
b);
153 if (pixel_size_ == 4) {
156 r = (r << 16) | ((
unsigned char)(
a) << 8) | (
unsigned char)(
b);
160 catch (
const std::exception&
e) {
165 std::string err(
"Error reading ");
187 ELLIPSOIDTOGEOID = -1,
196 GEOIDTOELLIPSOID = 1,
223 explicit Geoid(
const std::string&
name,
const std::string&
path =
"",
224 bool cubic =
true,
bool threadsafe =
false);
269 void CacheClear()
const;
327 const std::string&
DateTime()
const {
return _datetime; }
332 const std::string&
GeoidFile()
const {
return _filename; }
349 {
return std::string(_cubic ?
"cubic" :
"bilinear"); }
393 bool Cache()
const {
return _cache; }
399 return _cache ? ((_xoffset + (_xsize == _width ? 0 : _cubic)
400 + _width/2) % _width - _width/2) / _rlonres :
410 (_xsize - (_xsize == _width ? 0 : 1 + 2 * _cubic)) / _rlonres :
418 return _cache ? 90 - (_yoffset + _cubic) / _rlatres : 0;
426 return _cache ? 90 - ( _yoffset + _ysize - 1 - _cubic) / _rlatres : 0;
456 static std::string DefaultGeoidPath();
466 static std::string DefaultGeoidName();
472 #if defined(_MSC_VER)
473 # pragma warning (pop)
476 #endif // GEOGRAPHICLIB_GEOID_HPP