File indexing completed on 2024-09-15 03:35:05
0001 #ifndef NWWMAPIMAGE_H 0002 #define NWWMAPIMAGE_H 0003 0004 #include "mapreproject.h" 0005 #include "ReadOnlyMapImage.h" 0006 0007 #include <QCache> 0008 #include <QDir> 0009 #include <QPair> 0010 #include <QSet> 0011 #include <QColor> 0012 #include <QImage> 0013 0014 class InterpolationMethod; 0015 0016 class NwwMapImage: public ReadOnlyMapImage 0017 { 0018 public: 0019 NwwMapImage( QDir const & baseDirectory, int const tileLevel ); 0020 0021 QRgb pixel( double const lonRad, double const latRad ) override; 0022 QRgb pixel( int const x, int const y ) override; 0023 0024 void setBaseDirectory( QDir const & baseDirectory ); 0025 void setCacheSizeBytes( int const cacheSizeBytes ); 0026 void setInterpolationMethod( InterpolationMethod * const method ) override; 0027 void setTileLevel( int const level ); 0028 0029 private: 0030 enum { DefaultCacheSizeBytes = 32 * 1024 * 1024 }; 0031 0032 static int tileId( int const tileX, int const tileY ); 0033 QPair<QImage, bool> tile( int const tileX, int const tileY ); 0034 double lonRadToPixelX( double const lonRad ) const; 0035 double latRadToPixelY( double const latRad ) const; 0036 0037 // Interpolation methods 0038 QRgb nearestNeighbor( double const x, double const y ); 0039 QRgb bilinearInterpolation( double const x, double const y ); 0040 0041 int const m_tileEdgeLengthPixel; 0042 QRgb const m_emptyPixel; 0043 0044 QDir m_baseDirectory; 0045 int m_tileLevel; 0046 int m_mapWidthTiles; 0047 int m_mapHeightTiles; 0048 int m_mapWidthPixel; 0049 int m_mapHeightPixel; 0050 0051 0052 InterpolationMethod * m_interpolationMethod; 0053 0054 QSet<int> m_tileMissing; 0055 QCache<int, QImage> m_tileCache; 0056 }; 0057 0058 #endif