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 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;
99 static const int c3_[stencilsize_ * nterms_];
100 static const int c3n_[stencilsize_ * nterms_];
101 static const int c3s_[stencilsize_ * nterms_];
105 const real _a, _e2, _degree,
_eps;
109 real _offset,
_scale, _maxerror, _rmserror;
114 mutable std::vector< std::vector<pixel_t> >
_data;
117 mutable int _xoffset, _yoffset, _xsize,
_ysize;
120 mutable real _v00, _v01, _v10,
_v11;
121 mutable real _t[nterms_];
124 #
if !(defined(__GNUC__) && __GNUC__ < 4)
129 pixel_size_ * (
unsigned(iy)*_swidth +
unsigned(ix))));
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)
const;
187 ELLIPSOIDTOGEOID = -1,
196 GEOIDTOELLIPSOID = 1,
223 explicit Geoid(
const std::string&
name,
const std::string&
path =
"",
224 bool cubic =
true,
bool threadsafe =
false);
247 void CacheArea(real south, real west, real north, real east)
const;
269 void CacheClear()
const;
289 return height(lat, lon);
310 return h +
real(d) * height(lat, lon);
327 const std::string&
DateTime()
const {
return _datetime; }
332 const std::string&
GeoidFile()
const {
return _filename; }
349 {
return std::string(_cubic ?
"cubic" :
"bilinear"); }
393 bool Cache()
const {
return _cache; }
399 return _cache ? ((_xoffset + (_xsize == _width ? 0 : _cubic)
400 + _width/2) % _width - _width/2) / _rlonres :
410 (_xsize - (_xsize == _width ? 0 : 1 + 2 * _cubic)) / _rlonres :
418 return _cache ? 90 - (_yoffset + _cubic) / _rlatres : 0;
426 return _cache ? 90 - ( _yoffset + _ysize - 1 - _cubic) / _rlatres : 0;
456 static std::string DefaultGeoidPath();
466 static std::string DefaultGeoidName();
472 #if defined(_MSC_VER) 473 # pragma warning (pop) 476 #endif // GEOGRAPHICLIB_GEOID_HPP
const std::string & GeoidFile() const
#define GEOGRAPHICLIB_EXPORT
Math::real RMSError() const
const std::string Interpolation() const
Math::real Offset() const
const std::string & GeoidName() const
Math::real ConvertHeight(real lat, real lon, real h, convertflag d) const
Math::real CacheNorth() const
Math::real MaxError() const
void filepos(int ix, int iy) const
real rawval(int ix, int iy) const
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
const std::string & Description() const
std::vector< std::vector< pixel_t > > _data
unsigned long long _swidth
Exception handling for GeographicLib.
Math::real CacheSouth() const
Header for GeographicLib::Constants class.
Math::real CacheWest() const
Math::real Flattening() const
Annotation for function names.
const std::string & DateTime() const
const std::string & GeoidDirectory() const
Math::real MajorRadius() const
Math::real CacheEast() const
Math::real operator()(real lat, real lon) const
Looking up the height of the geoid above the ellipsoid.