Code cleanup
[GPXSee.git] / src / data / dem.h
blobbb715fd9434a53bd4bef78ebcbbc08f8303a50e8
1 #ifndef DEM_H
2 #define DEM_H
4 #include <QString>
5 #include <QCache>
6 #include <QByteArray>
7 #include <QMutex>
8 #include "common/hash.h"
9 #include "area.h"
11 class Coordinates;
13 class DEM
15 public:
16 class Tile {
17 public:
18 Tile(int lon, int lat) : _lon(lon), _lat(lat) {}
20 int lon() const {return _lon;}
21 int lat() const {return _lat;}
23 QString lonStr() const;
24 QString latStr() const;
25 QString baseName() const;
27 bool operator==(const Tile &other) const
29 return (_lon == other._lon && _lat == other._lat);
32 private:
33 int _lon, _lat;
36 static void setCacheSize(int size);
37 static void setDir(const QString &path);
38 static void clearCache();
40 static double elevation(const Coordinates &c);
41 static void lock() {_lock.lock();}
42 static void unlock() {_lock.unlock();}
44 static QList<Area> tiles();
46 private:
47 typedef QCache<DEM::Tile, QByteArray> TileCache;
49 static QString fileName(const QString &baseName);
51 static QString _dir;
52 static TileCache _data;
53 static QMutex _lock;
56 inline HASH_T qHash(const DEM::Tile &tile)
58 return (qHash(tile.lon()) ^ qHash(tile.lat()));
61 #ifndef QT_NO_DEBUG
62 QDebug operator<<(QDebug dbg, const DEM::Tile &tile);
63 #endif // QT_NO_DEBUG
65 #endif // DEM_H