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
94 #if GEOGRAPHICLIB_GEOID_PGM_PIXEL_WIDTH != 4
95 typedef unsigned short pixel_t;
96 static const unsigned pixel_size_ = 2;
97 static const unsigned pixel_max_ = 0xffffu;
99 typedef unsigned pixel_t;
100 static const unsigned pixel_size_ = 4;
101 static const unsigned pixel_max_ = 0xffffffffu;
103 static const unsigned stencilsize_ = 12;
104 static const unsigned nterms_ = ((3 + 1) * (3 + 2))/2;
105 static const int c0_;
106 static const int c0n_;
107 static const int c0s_;
108 static const int c3_[stencilsize_ * nterms_];
109 static const int c3n_[stencilsize_ * nterms_];
110 static const int c3s_[stencilsize_ * nterms_];
112 std::string _name, _dir, _filename;
114 const real _a, _e2, _degree, _eps;
115 mutable std::ifstream _file;
116 real _rlonres, _rlatres;
117 std::string _description, _datetime;
118 real _offset, _scale, _maxerror, _rmserror;
120 unsigned long long _datastart, _swidth;
123 mutable std::vector< std::vector<pixel_t> > _data;
126 mutable int _xoffset, _yoffset, _xsize, _ysize;
128 mutable int _ix, _iy;
129 mutable real _v00, _v01, _v10, _v11;
130 mutable real _t[nterms_];
131 void filepos(
int ix,
int iy)
const {
133 #
if !(defined(__GNUC__) && __GNUC__ < 4)
138 pixel_size_ * (
unsigned(iy)*_swidth +
unsigned(ix))));
140 real rawval(
int ix,
int iy)
const {
143 else if (ix >= _width)
145 if (_cache && iy >= _yoffset && iy < _yoffset + _ysize &&
146 ((ix >= _xoffset && ix < _xoffset + _xsize) ||
147 (ix + _width >= _xoffset && ix + _width < _xoffset + _xsize))) {
148 return real(_data[iy - _yoffset]
149 [ix >= _xoffset ? ix - _xoffset : ix + _width - _xoffset]);
151 if (iy < 0 || iy >= _height) {
152 iy = iy < 0 ? -iy : 2 * (_height - 1) - iy;
153 ix += (ix < _width/2 ? 1 : -1) * _width/2;
161 unsigned r = ((
unsigned char)(a) << 8) | (
unsigned char)(b);
162 if (pixel_size_ == 4) {
165 r = (r << 16) | ((
unsigned char)(a) << 8) | (
unsigned char)(b);
169 catch (
const std::exception& e) {
174 std::string err(
"Error reading ");
182 real height(real lat, real lon,
bool gradp,
183 real& grade, real& gradn)
const;
197 ELLIPSOIDTOGEOID = -1,
206 GEOIDTOELLIPSOID = 1,
233 explicit Geoid(
const std::string& name,
const std::string& path =
"",
234 bool cubic =
true,
bool threadsafe =
false);
256 void CacheArea(real south, real west, real north, real east)
const;
278 void CacheClear()
const;
299 return height(lat, lon,
false, gradn, grade);
323 return height(lat, lon,
true, gradn, grade);
344 return h +
real(d) * height(lat, lon,
true, gradn, grade);
361 const std::string&
DateTime()
const {
return _datetime; }
366 const std::string&
GeoidFile()
const {
return _filename; }
383 {
return std::string(_cubic ?
"cubic" :
"bilinear"); }
427 bool Cache()
const {
return _cache; }
433 return _cache ? ((_xoffset + (_xsize == _width ? 0 : _cubic)
434 + _width/2) % _width - _width/2) / _rlonres :
444 (_xsize - (_xsize == _width ? 0 : 1 + 2 * _cubic)) / _rlonres :
452 return _cache ? 90 - (_yoffset + _cubic) / _rlatres : 0;
460 return _cache ? 90 - ( _yoffset + _ysize - 1 - _cubic) / _rlatres : 0;
499 static std::string DefaultGeoidPath();
509 static std::string DefaultGeoidName();
515 #if defined(_MSC_VER)
516 # pragma warning (pop)
519 #endif // GEOGRAPHICLIB_GEOID_HPP
const std::string & GeoidDirectory() const
#define GEOGRAPHICLIB_EXPORT
Math::real MaxError() const
GeographicLib::Math::real real
Math::real CacheWest() const
Math::real CacheNorth() const
const std::string & DateTime() const
Math::real MajorRadius() const
const std::string & GeoidFile() const
Math::real ConvertHeight(real lat, real lon, real h, convertflag d) const
const std::string Interpolation() const
Math::real Offset() const
Namespace for GeographicLib.
Math::real RMSError() const
Math::real Flattening() const
Exception handling for GeographicLib.
Header for GeographicLib::Constants class.
Math::real CacheSouth() const
Math::real CacheEast() const
const std::string & Description() const
const std::string & GeoidName() const
Math::real operator()(real lat, real lon) const
Math::real operator()(real lat, real lon, real &gradn, real &grade) const
Looking up the height of the geoid.