Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tumic0 committed Oct 22, 2024
1 parent b348ad6 commit 5b5e000
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/map/IMG/rastertile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,7 @@ MatrixD RasterTile::elevation(int extend) const
int top = _rect.top() - extend;
int bottom = _rect.bottom() + extend;

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

DEMTree tree(tiles);
MatrixD m(ll.h(), ll.w());

for (int i = 0; i < ll.size(); i++)
m.at(i) = tree.elevation(ll.at(i));

Expand Down
5 changes: 3 additions & 2 deletions src/map/dem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static double value(int col, int row, int samples, const QByteArray &data)
return (val == -32768) ? NAN : val;
}

QMutex DEM::_lock;

DEM::Entry::Entry(const QByteArray &data) : _data(data)
{
Expand All @@ -70,6 +69,8 @@ QString DEM::Tile::fileName() const
return QString("%1%2.hgt").arg(latStr(), lonStr());
}


QMutex DEM::_lock;
QString DEM::_dir;
DEM::TileCache DEM::_data;

Expand Down Expand Up @@ -170,7 +171,7 @@ double DEM::elevationLockFree(const Coordinates &c)
return ele;
}

MatrixD DEM::elevation(const Matrix<Coordinates> &m)
MatrixD DEM::elevation(const MatrixC &m)
{
if (_dir.isEmpty())
return MatrixD(m.h(), m.w(), NAN);
Expand Down
4 changes: 1 addition & 3 deletions src/map/dem.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include "data/area.h"
#include "matrix.h"

class Coordinates;

class DEM
{
public:
Expand Down Expand Up @@ -39,7 +37,7 @@ class DEM
static void clearCache();

static double elevation(const Coordinates &c);
static MatrixD elevation(const Matrix<Coordinates> &m);
static MatrixD elevation(const MatrixC &m);

static QList<Area> tiles();

Expand Down
3 changes: 1 addition & 2 deletions src/map/mapsforge/rastertile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ MatrixD RasterTile::elevation(int extend) const
int top = _rect.top() - extend;
int bottom = _rect.bottom() + extend;

Matrix<Coordinates> ll(_rect.height() + 2 * extend,
_rect.width() + 2 * extend);
MatrixC ll(_rect.height() + 2 * extend, _rect.width() + 2 * extend);
for (int y = top, i = 0; y <= bottom; y++)
for (int x = left; x <= right; x++, i++)
ll.at(i) = xy2ll(QPointF(x, y));
Expand Down
4 changes: 4 additions & 0 deletions src/map/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <QVector>
#include <QDebug>

class Coordinates;

template <class T>
class Matrix
{
Expand Down Expand Up @@ -39,6 +41,8 @@ class MatrixD : public Matrix<double>
MatrixD augemented(const MatrixD &M) const;
};

typedef Matrix<Coordinates> MatrixC;

#ifndef QT_NO_DEBUG
template <class T>
inline QDebug operator<<(QDebug dbg, const Matrix<T> &matrix)
Expand Down

0 comments on commit 5b5e000

Please sign in to comment.