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 95 #if GEOGRAPHICLIB_GEOID_PGM_PIXEL_WIDTH != 4 96 typedef unsigned short pixel_t;
97 static const unsigned pixel_size_ = 2;
98 static const unsigned pixel_max_ = 0xffffu;
100 typedef unsigned pixel_t;
101 static const unsigned pixel_size_ = 4;
102 static const unsigned pixel_max_ = 0xffffffffu;
104 static const unsigned stencilsize_ = 12;
105 static const unsigned nterms_ = ((3 + 1) * (3 + 2))/2;
106 static const int c0_;
107 static const int c0n_;
108 static const int c0s_;
109 static const int c3_[stencilsize_ * nterms_];
110 static const int c3n_[stencilsize_ * nterms_];
111 static const int c3s_[stencilsize_ * nterms_];
113 std::string _name, _dir, _filename;
115 const real _a, _e2, _degree, _eps;
116 mutable std::ifstream _file;
117 real _rlonres, _rlatres;
118 std::string _description, _datetime;
119 real _offset, _scale, _maxerror, _rmserror;
121 unsigned long long _datastart, _swidth;
124 mutable std::vector< std::vector<pixel_t> > _data;
127 mutable int _xoffset, _yoffset, _xsize, _ysize;
129 mutable int _ix, _iy;
130 mutable real _v00, _v01, _v10, _v11;
131 mutable real _t[nterms_];
132 void filepos(
int ix,
int iy)
const {
134 #
if !(defined(__GNUC__) && __GNUC__ < 4)
139 pixel_size_ * (
unsigned(iy)*_swidth +
unsigned(ix))));
141 real rawval(
int ix,
int iy)
const {
144 else if (ix >= _width)
146 if (_cache && iy >= _yoffset && iy < _yoffset + _ysize &&
147 ((ix >= _xoffset && ix < _xoffset + _xsize) ||
148 (ix + _width >= _xoffset && ix + _width < _xoffset + _xsize))) {
149 return real(_data[iy - _yoffset]
150 [ix >= _xoffset ? ix - _xoffset : ix + _width - _xoffset]);
152 if (iy < 0 || iy >= _height) {
153 iy = iy < 0 ? -iy : 2 * (_height - 1) - iy;
154 ix += (ix < _width/2 ? 1 : -1) * _width/2;
162 unsigned r = ((
unsigned char)(a) << 8) | (
unsigned char)(b);
163 if (pixel_size_ == 4) {
166 r = (r << 16) | ((
unsigned char)(a) << 8) | (
unsigned char)(b);
170 catch (
const std::exception& e) {
175 std::string err(
"Error reading ");
183 real height(real lat, real lon,
bool gradp,
184 real& grade, real& gradn)
const;
198 ELLIPSOIDTOGEOID = -1,
207 GEOIDTOELLIPSOID = 1,
234 explicit Geoid(
const std::string& name,
const std::string& path =
"",
235 bool cubic =
true,
bool threadsafe =
false);
257 void CacheArea(real south, real west, real north, real east)
const;
279 void CacheClear()
const;
300 return height(lat, lon,
false, gradn, grade);
324 return height(lat, lon,
true, gradn, grade);
345 return h +
real(d) * height(lat, lon,
true, gradn, grade);
362 const std::string&
DateTime()
const {
return _datetime; }
367 const std::string&
GeoidFile()
const {
return _filename; }
384 {
return std::string(_cubic ?
"cubic" :
"bilinear"); }
428 bool Cache()
const {
return _cache; }
434 return _cache ? ((_xoffset + (_xsize == _width ? 0 : _cubic)
435 + _width/2) % _width - _width/2) / _rlonres :
445 (_xsize - (_xsize == _width ? 0 : 1 + 2 * _cubic)) / _rlonres :
453 return _cache ? 90 - (_yoffset + _cubic) / _rlatres : 0;
461 return _cache ? 90 - ( _yoffset + _ysize - 1 - _cubic) / _rlatres : 0;
500 static std::string DefaultGeoidPath();
510 static std::string DefaultGeoidName();
516 #if defined(_MSC_VER) 517 # pragma warning (pop) 520 #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 above the ellipsoid.