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(PGM_PIXEL_WIDTH)
31 # define PGM_PIXEL_WIDTH 2
34 namespace GeographicLib {
86 #if PGM_PIXEL_WIDTH != 4
87 typedef unsigned short pixel_t;
88 static const unsigned pixel_size_ = 2;
89 static const unsigned pixel_max_ = 0xffffu;
91 typedef unsigned pixel_t;
92 static const unsigned pixel_size_ = 4;
93 static const unsigned pixel_max_ = 0xffffffffu;
95 static const unsigned stencilsize_ = 12;
96 static const unsigned nterms_ = ((3 + 1) * (3 + 2))/2;
97 static const real c0_;
98 static const real c0n_;
99 static const real c0s_;
100 static const real c3_[stencilsize_ * nterms_];
101 static const real c3n_[stencilsize_ * nterms_];
102 static const real c3s_[stencilsize_ * nterms_];
104 std::string _name, _dir, _filename;
106 const real _a, _e2, _degree, _eps;
107 mutable std::ifstream _file;
108 real _rlonres, _rlatres;
109 std::string _description, _datetime;
110 real _offset, _scale, _maxerror, _rmserror;
112 unsigned long long _datastart, _swidth;
115 mutable std::vector< std::vector<pixel_t> > _data;
118 mutable int _xoffset, _yoffset, _xsize, _ysize;
120 mutable int _ix, _iy;
121 mutable real _v00, _v01, _v10, _v11;
122 mutable real _t[nterms_];
123 void filepos(
int ix,
int iy)
const {
125 #
if !(defined(__GNUC__) && __GNUC__ < 4)
130 pixel_size_ * (
unsigned(iy)*_swidth +
unsigned(ix))));
132 real rawval(
int ix,
int iy)
const {
135 else if (ix >= _width)
137 if (_cache && iy >= _yoffset && iy < _yoffset + _ysize &&
138 ((ix >= _xoffset && ix < _xoffset + _xsize) ||
139 (ix + _width >= _xoffset && ix + _width < _xoffset + _xsize))) {
140 return real(_data[iy - _yoffset]
141 [ix >= _xoffset ? ix - _xoffset : ix + _width - _xoffset]);
143 if (iy < 0 || iy >= _height) {
144 iy = iy < 0 ? -iy : 2 * (_height - 1) - iy;
145 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 ");
173 real height(real lat, real lon,
bool gradp,
174 real& grade, real& gradn)
const;
188 ELLIPSOIDTOGEOID = -1,
197 GEOIDTOELLIPSOID = 1,
224 explicit Geoid(
const std::string& name,
const std::string& path =
"",
225 bool cubic =
true,
bool threadsafe =
false);
269 void CacheClear()
const throw();
288 Math::real operator()(real lat, real lon)
const {
290 return height(lat, lon,
false, gradn, grade);
313 return height(lat, lon,
true, gradn, grade);
334 return h +
real(d) * height(lat, lon,
true, gradn, grade);
346 const std::string&
Description()
const throw() {
return _description; }
351 const std::string&
DateTime()
const throw() {
return _datetime; }
356 const std::string&
GeoidFile()
const throw() {
return _filename; }
362 const std::string&
GeoidName()
const throw() {
return _name; }
373 {
return std::string(_cubic ?
"cubic" :
"bilinear"); }
417 bool Cache()
const throw() {
return _cache; }
423 return _cache ? ((_xoffset + (_xsize == _width ? 0 : _cubic)
424 + _width/2) % _width - _width/2) / _rlonres :
434 (_xsize - (_xsize == _width ? 0 : 1 + 2 * _cubic)) / _rlonres :
442 return _cache ? 90 - (_yoffset + _cubic) / _rlatres : 0;
450 return _cache ? 90 - ( _yoffset + _ysize - 1 - _cubic) / _rlatres : 0;
460 {
return Constants::WGS84_a<real>(); }
477 {
return 1/Constants::WGS84_f<real>(); }
490 static std::string DefaultGeoidPath();
500 static std::string DefaultGeoidName();
506 #if defined(_MSC_VER)
507 # pragma warning (pop)
510 #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
Mathematical functions needed by GeographicLib.
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
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, real &gradn, real &grade) const
Looking up the height of the geoid.