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 {
124 #
if !(defined(__GNUC__) && __GNUC__ < 4)
129 pixel_size_ * (
unsigned(iy)*_swidth +
unsigned(ix))));
131 real rawval(
int ix,
int iy)
const {
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 ");
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);
246 void CacheArea(real south, real west, real north, real east)
const;
268 void CacheClear()
const;
288 return height(lat, lon,
false, gradn, grade);
311 Math::real operator()(real lat, real lon, real& gradn, real& grade)
const {
312 return height(lat, lon,
true, gradn, grade);
334 return h +
real(d) * height(lat, lon,
false, gradn, grade);
351 const std::string&
DateTime()
const {
return _datetime; }
356 const std::string&
GeoidFile()
const {
return _filename; }
373 {
return std::string(_cubic ?
"cubic" :
"bilinear"); }
417 bool Cache()
const {
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;
489 static std::string DefaultGeoidPath();
499 static std::string DefaultGeoidName();
505 #if defined(_MSC_VER)
506 # pragma warning (pop)
509 #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
Looking up the height of the geoid above the ellipsoid.