1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Compare commits

..

No commits in common. "5a71deda15f15f3658bc22db9cc71767a851d17e" and "b348ad628885b1a88665f0cd9dc3b479dda251cd" have entirely different histories.

5 changed files with 14 additions and 22 deletions

View File

@ -466,7 +466,8 @@ MatrixD RasterTile::elevation(int extend) const
int top = _rect.top() - extend; int top = _rect.top() - extend;
int bottom = _rect.bottom() + extend; int bottom = _rect.bottom() + extend;
MatrixC ll(_rect.height() + 2 * extend, _rect.width() + 2 * extend); Matrix<Coordinates> ll(_rect.height() + 2 * extend,
_rect.width() + 2 * extend);
for (int y = top, i = 0; y <= bottom; y++) for (int y = top, i = 0; y <= bottom; y++)
for (int x = left; x <= right; x++, i++) for (int x = left; x <= right; x++, i++)
ll.at(i) = xy2ll(QPointF(x, y)); ll.at(i) = xy2ll(QPointF(x, y));
@ -485,6 +486,7 @@ MatrixD RasterTile::elevation(int extend) const
DEMTree tree(tiles); DEMTree tree(tiles);
MatrixD m(ll.h(), ll.w()); MatrixD m(ll.h(), ll.w());
for (int i = 0; i < ll.size(); i++) for (int i = 0; i < ll.size(); i++)
m.at(i) = tree.elevation(ll.at(i)); m.at(i) = tree.elevation(ll.at(i));

View File

@ -23,20 +23,12 @@
static unsigned int isqrt(unsigned int x) static unsigned int isqrt(unsigned int x)
{ {
unsigned int l = 0; unsigned int r = 0;
unsigned int m;
unsigned int r = x + 1;
while (l != r - 1) { while ((r + 1) * (r + 1) <= x)
m = (l + r) / 2; r++;
if (m * m <= x) return r;
l = m;
else
r = m;
}
return l;
} }
static double interpolate(double dx, double dy, double p0, double p1, double p2, static double interpolate(double dx, double dy, double p0, double p1, double p2,
@ -54,6 +46,7 @@ static double value(int col, int row, int samples, const QByteArray &data)
return (val == -32768) ? NAN : val; return (val == -32768) ? NAN : val;
} }
QMutex DEM::_lock;
DEM::Entry::Entry(const QByteArray &data) : _data(data) DEM::Entry::Entry(const QByteArray &data) : _data(data)
{ {
@ -77,8 +70,6 @@ QString DEM::Tile::fileName() const
return QString("%1%2.hgt").arg(latStr(), lonStr()); return QString("%1%2.hgt").arg(latStr(), lonStr());
} }
QMutex DEM::_lock;
QString DEM::_dir; QString DEM::_dir;
DEM::TileCache DEM::_data; DEM::TileCache DEM::_data;
@ -179,7 +170,7 @@ double DEM::elevationLockFree(const Coordinates &c)
return ele; return ele;
} }
MatrixD DEM::elevation(const MatrixC &m) MatrixD DEM::elevation(const Matrix<Coordinates> &m)
{ {
if (_dir.isEmpty()) if (_dir.isEmpty())
return MatrixD(m.h(), m.w(), NAN); return MatrixD(m.h(), m.w(), NAN);

View File

@ -9,6 +9,8 @@
#include "data/area.h" #include "data/area.h"
#include "matrix.h" #include "matrix.h"
class Coordinates;
class DEM class DEM
{ {
public: public:
@ -37,7 +39,7 @@ public:
static void clearCache(); static void clearCache();
static double elevation(const Coordinates &c); static double elevation(const Coordinates &c);
static MatrixD elevation(const MatrixC &m); static MatrixD elevation(const Matrix<Coordinates> &m);
static QList<Area> tiles(); static QList<Area> tiles();

View File

@ -475,7 +475,8 @@ MatrixD RasterTile::elevation(int extend) const
int top = _rect.top() - extend; int top = _rect.top() - extend;
int bottom = _rect.bottom() + extend; int bottom = _rect.bottom() + extend;
MatrixC ll(_rect.height() + 2 * extend, _rect.width() + 2 * extend); Matrix<Coordinates> ll(_rect.height() + 2 * extend,
_rect.width() + 2 * extend);
for (int y = top, i = 0; y <= bottom; y++) for (int y = top, i = 0; y <= bottom; y++)
for (int x = left; x <= right; x++, i++) for (int x = left; x <= right; x++, i++)
ll.at(i) = xy2ll(QPointF(x, y)); ll.at(i) = xy2ll(QPointF(x, y));

View File

@ -5,8 +5,6 @@
#include <QVector> #include <QVector>
#include <QDebug> #include <QDebug>
class Coordinates;
template <class T> template <class T>
class Matrix class Matrix
{ {
@ -41,8 +39,6 @@ public:
MatrixD augemented(const MatrixD &M) const; MatrixD augemented(const MatrixD &M) const;
}; };
typedef Matrix<Coordinates> MatrixC;
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
template <class T> template <class T>
inline QDebug operator<<(QDebug dbg, const Matrix<T> &matrix) inline QDebug operator<<(QDebug dbg, const Matrix<T> &matrix)