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
86 typedef unsigned short pixel_t;
87 static const unsigned pixel_size_ = 2;
88 static const unsigned pixel_max_ = 0xffffu;
90 typedef unsigned pixel_t;
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;
97 static const int c0n_;
98 static const int c0s_;
99 static const int c3_[stencilsize_ * nterms_];
100 static const int c3n_[stencilsize_ * nterms_];
101 static const int c3s_[stencilsize_ * nterms_];
103 std::string _name, _dir, _filename;
105 const real _a, _e2, _degree, _eps;
106 mutable std::ifstream _file;
107 real _rlonres, _rlatres;
108 std::string _description, _datetime;
109 real _offset, _scale, _maxerror, _rmserror;
111 unsigned long long _datastart, _swidth;
114 mutable std::vector< std::vector<pixel_t> > _data;
117 mutable int _xoffset, _yoffset, _xsize, _ysize;
119 mutable int _ix, _iy;
120 mutable real _v00, _v01, _v10, _v11;
121 mutable real _t[nterms_];
122 void filepos(
int ix,
int iy)
const {
123 _file.seekg(std::streamoff
125 pixel_size_ * (
unsigned(iy)*_swidth +
unsigned(ix))));
127 real rawval(
int ix,
int iy)
const {
130 else if (ix >= _width)
132 if (_cache && iy >= _yoffset && iy < _yoffset + _ysize &&
133 ((ix >= _xoffset && ix < _xoffset + _xsize) ||
134 (ix + _width >= _xoffset && ix + _width < _xoffset + _xsize))) {
135 return real(_data[iy - _yoffset]
136 [ix >= _xoffset ? ix - _xoffset : ix + _width - _xoffset]);
138 if (iy < 0 || iy >= _height) {
139 iy = iy < 0 ? -iy : 2 * (_height - 1) - iy;
140 ix += (ix < _width/2 ? 1 : -1) * _width/2;
148 unsigned r = ((
unsigned char)(a) << 8) | (
unsigned char)(b);
149 if (pixel_size_ == 4) {
152 r = (r << 16) | ((
unsigned char)(a) << 8) | (
unsigned char)(b);
156 catch (
const std::exception& e) {
161 std::string err(
"Error reading ");
169 real height(real lat, real lon)
const;
183 ELLIPSOIDTOGEOID = -1,
192 GEOIDTOELLIPSOID = 1,
219 explicit Geoid(
const std::string& name,
const std::string& path =
"",
220 bool cubic =
true,
bool threadsafe =
false);
265 void CacheClear()
const;
285 return height(lat, lon);
306 return h +
real(d) * height(lat, lon);
323 const std::string&
DateTime()
const {
return _datetime; }
328 const std::string&
GeoidFile()
const {
return _filename; }
345 {
return std::string(_cubic ?
"cubic" :
"bilinear"); }
389 bool Cache()
const {
return _cache; }
395 return _cache ? ((_xoffset + (_xsize == _width ? 0 : _cubic)
396 + _width/2) % _width - _width/2) / _rlonres :
406 (_xsize - (_xsize == _width ? 0 : 1 + 2 * _cubic)) / _rlonres :
414 return _cache ?
real(
Math::qd) - (_yoffset + _cubic) / _rlatres : 0;
423 real(
Math::qd) - ( _yoffset + _ysize - 1 - _cubic) / _rlatres :
454 static std::string DefaultGeoidPath();
464 static std::string DefaultGeoidName();
471# pragma warning (pop)
Header for GeographicLib::Constants class.
#define GEOGRAPHICLIB_EXPORT
GeographicLib::Math::real real
Exception handling for GeographicLib.
Looking up the height of the geoid above the ellipsoid.
Math::real MaxError() const
const std::string & Description() const
Math::real CacheEast() const
const std::string & GeoidDirectory() const
Math::real Flattening() const
Math::real RMSError() const
const std::string & GeoidFile() const
Math::real CacheSouth() const
Math::real EquatorialRadius() const
const std::string Interpolation() const
Math::real CacheNorth() const
Math::real ConvertHeight(real lat, real lon, real h, convertflag d) const
Math::real Offset() const
const std::string & DateTime() const
Math::real operator()(real lat, real lon) const
const std::string & GeoidName() const
Math::real CacheWest() const
@ qd
degrees per quarter turn
Namespace for GeographicLib.