File indexing completed on 2024-06-16 03:46:42

0001 #ifndef OSMTILECLUSTERRENDERER_H
0002 #define OSMTILECLUSTERRENDERER_H
0003 
0004 #include "mapreproject.h"
0005 #include "ReadOnlyMapDefinition.h"
0006 
0007 #include <QDir>
0008 #include <QObject>
0009 #include <QVector>
0010 #include <QImage>
0011 
0012 class ReadOnlyMapImage;
0013 
0014 class OsmTileClusterRenderer: public QObject
0015 {
0016     Q_OBJECT
0017 
0018 public:
0019     explicit OsmTileClusterRenderer( QObject * const parent = nullptr );
0020 
0021     void setClusterEdgeLengthTiles( int const clusterEdgeLengthTiles );
0022     void setMapSources( QVector<ReadOnlyMapDefinition> const & mapSources );
0023     void setOsmBaseDirectory( QDir const & osmBaseDirectory );
0024     void setOsmTileLevel( int const level );
0025 
0026 Q_SIGNALS:
0027     void clusterRendered( OsmTileClusterRenderer * );
0028 
0029 public Q_SLOTS:
0030     void initMapSources();
0031     void renderOsmTileCluster( int const clusterX, int const clusterY );
0032 
0033 private:
0034     QDir checkAndCreateDirectory( int const tileX ) const;
0035     QImage renderOsmTile( int const tileX, int const tileY );
0036     double osmPixelXtoLonRad( int const pixelX ) const;
0037     double osmPixelYtoLatRad( int const pixelY ) const;
0038 
0039     int const m_osmTileEdgeLengthPixel;
0040     QRgb const m_emptyPixel;
0041 
0042     QDir m_osmBaseDirectory;
0043     int m_osmTileLevel;
0044     int m_osmMapEdgeLengthPixel;
0045     int m_clusterEdgeLengthTiles;
0046 
0047     QVector<ReadOnlyMapDefinition> m_mapSourceDefinitions;
0048     QVector<ReadOnlyMapImage*> m_mapSources;
0049     int m_mapSourceCount;
0050 };
0051 
0052 #endif