diff --git a/src/map/IMG/demtree.cpp b/src/map/IMG/demtree.cpp index b8863181..d94df078 100644 --- a/src/map/IMG/demtree.cpp +++ b/src/map/IMG/demtree.cpp @@ -111,3 +111,13 @@ double DEMTree::elevation(const Coordinates &c) const return ele; } + +MatrixD DEMTree::elevation(const MatrixC &m) const +{ + MatrixD ret(m.h(), m.w()); + + for (int i = 0; i < m.size(); i++) + ret.at(i) = elevation(m.at(i)); + + return ret; +} diff --git a/src/map/IMG/demtree.h b/src/map/IMG/demtree.h index 9e78b302..86ff7139 100644 --- a/src/map/IMG/demtree.h +++ b/src/map/IMG/demtree.h @@ -2,6 +2,7 @@ #define IMG_DEMTREE_H #include "common/rtree.h" +#include "map/matrix.h" #include "mapdata.h" namespace IMG { @@ -11,6 +12,7 @@ public: DEMTree(const QList &tiles); double elevation(const Coordinates &c) const; + MatrixD elevation(const MatrixC &m) const; private: typedef RTree Tree; diff --git a/src/map/IMG/rastertile.cpp b/src/map/IMG/rastertile.cpp index af8d51a3..be67893b 100644 --- a/src/map/IMG/rastertile.cpp +++ b/src/map/IMG/rastertile.cpp @@ -483,22 +483,18 @@ MatrixD RasterTile::elevation(int extend) const if (_data->hasDEM()) { RectC rect; - QList tiles; - for (int i = 0; i < ll.size(); i++) rect = rect.united(ll.at(i)); - // Extra margin for always including the next DEM tile on the map tile - // edges (the DEM tile resolution is usally 0.5-15% of the map tile) + /* Extra margin for always including the next DEM tile on the map tile + edges (the DEM tile resolution is usally 0.5-15% of the map tile) */ double factor = 6 - (_zoom - 24) * 1.7; - _data->elevations(_file, rect.adjusted(0, 0, rect.width() / factor, - -rect.height() / factor), _zoom, &tiles); + RectC br(rect.adjusted(0, 0, rect.width() / factor, -rect.height() + / factor)); - 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)); + QList tiles; + _data->elevations(_file, br, _zoom, &tiles); - return m; + return DEMTree(tiles).elevation(ll); } else return DEM::elevation(ll); }