Skip to content

Commit 335df85

Browse files
committed
Code cleanup
1 parent f1b52c7 commit 335df85

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/map/IMG/demtree.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,13 @@ double DEMTree::elevation(const Coordinates &c) const
111111

112112
return ele;
113113
}
114+
115+
MatrixD DEMTree::elevation(const MatrixC &m) const
116+
{
117+
MatrixD ret(m.h(), m.w());
118+
119+
for (int i = 0; i < m.size(); i++)
120+
ret.at(i) = elevation(m.at(i));
121+
122+
return ret;
123+
}

src/map/IMG/demtree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define IMG_DEMTREE_H
33

44
#include "common/rtree.h"
5+
#include "map/matrix.h"
56
#include "mapdata.h"
67

78
namespace IMG {
@@ -11,6 +12,7 @@ class DEMTree {
1112
DEMTree(const QList<MapData::Elevation> &tiles);
1213

1314
double elevation(const Coordinates &c) const;
15+
MatrixD elevation(const MatrixC &m) const;
1416

1517
private:
1618
typedef RTree<const MapData::Elevation*, double, 2> Tree;

src/map/IMG/rastertile.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -483,22 +483,18 @@ MatrixD RasterTile::elevation(int extend) const
483483

484484
if (_data->hasDEM()) {
485485
RectC rect;
486-
QList<MapData::Elevation> tiles;
487-
488486
for (int i = 0; i < ll.size(); i++)
489487
rect = rect.united(ll.at(i));
490-
// Extra margin for always including the next DEM tile on the map tile
491-
// edges (the DEM tile resolution is usally 0.5-15% of the map tile)
488+
/* Extra margin for always including the next DEM tile on the map tile
489+
edges (the DEM tile resolution is usally 0.5-15% of the map tile) */
492490
double factor = 6 - (_zoom - 24) * 1.7;
493-
_data->elevations(_file, rect.adjusted(0, 0, rect.width() / factor,
494-
-rect.height() / factor), _zoom, &tiles);
491+
RectC br(rect.adjusted(0, 0, rect.width() / factor, -rect.height()
492+
/ factor));
495493

496-
DEMTree tree(tiles);
497-
MatrixD m(ll.h(), ll.w());
498-
for (int i = 0; i < ll.size(); i++)
499-
m.at(i) = tree.elevation(ll.at(i));
494+
QList<MapData::Elevation> tiles;
495+
_data->elevations(_file, br, _zoom, &tiles);
500496

501-
return m;
497+
return DEMTree(tiles).elevation(ll);
502498
} else
503499
return DEM::elevation(ll);
504500
}

0 commit comments

Comments
 (0)