File indexing completed on 2025-01-05 03:59:37
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2008, 2010 Jens-Michael Hoffmann <jensmh@gmx.de> 0004 // SPDX-FileCopyrightText: 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de> 0005 // 0006 0007 #ifndef MARBLE_TILEID_H 0008 #define MARBLE_TILEID_H 0009 0010 #include "digikam_export.h" 0011 0012 #include <QHash> 0013 0014 class QString; 0015 0016 namespace Marble 0017 { 0018 class GeoDataCoordinates; 0019 0020 class DIGIKAM_EXPORT TileId 0021 { 0022 public: 0023 TileId( QString const & mapThemeId, int zoomLevel, int tileX, int tileY ); 0024 TileId( uint mapThemeIdHash, int zoomLevel, int tileX, int tileY ); 0025 TileId(); 0026 0027 int zoomLevel() const; 0028 int x() const; 0029 int y() const; 0030 uint mapThemeIdHash() const; 0031 0032 bool operator==( TileId const& rhs ) const; 0033 bool operator<( TileId const& rhs ) const; 0034 0035 static TileId fromCoordinates( const GeoDataCoordinates& coords, int zoomLevel ); 0036 0037 private: 0038 uint m_mapThemeIdHash; 0039 int m_zoomLevel; 0040 int m_tileX; 0041 int m_tileY; 0042 }; 0043 0044 uint qHash( TileId const& ); 0045 0046 0047 // inline definitions 0048 0049 inline int TileId::zoomLevel() const 0050 { 0051 return m_zoomLevel; 0052 } 0053 0054 inline int TileId::x() const 0055 { 0056 return m_tileX; 0057 } 0058 0059 inline int TileId::y() const 0060 { 0061 return m_tileY; 0062 } 0063 0064 inline uint TileId::mapThemeIdHash() const 0065 { 0066 return m_mapThemeIdHash; 0067 } 0068 0069 inline bool TileId::operator==( TileId const& rhs ) const 0070 { 0071 return m_zoomLevel == rhs.m_zoomLevel 0072 && m_tileX == rhs.m_tileX 0073 && m_tileY == rhs.m_tileY 0074 && m_mapThemeIdHash == rhs.m_mapThemeIdHash; 0075 } 0076 0077 inline bool TileId::operator<( TileId const& rhs ) const 0078 { 0079 if (m_zoomLevel < rhs.m_zoomLevel) 0080 return true; 0081 else if (m_zoomLevel == rhs.m_zoomLevel 0082 && m_tileX < rhs.m_tileX) 0083 return true; 0084 else if (m_zoomLevel == rhs.m_zoomLevel 0085 && m_tileX == rhs.m_tileX 0086 && m_tileY < rhs.m_tileY) 0087 return true; 0088 else if (m_zoomLevel == rhs.m_zoomLevel 0089 && m_tileX == rhs.m_tileX 0090 && m_tileY == rhs.m_tileY 0091 && m_mapThemeIdHash < rhs.m_mapThemeIdHash) 0092 return true; 0093 return false; 0094 } 0095 0096 inline uint qHash( TileId const& tid ) 0097 { 0098 const quint64 tmp = (( quint64 )( tid.zoomLevel() ) << 36 ) 0099 + (( quint64 )( tid.x() ) << 18 ) 0100 + ( quint64 )( tid.y() ); 0101 return ::qHash( tmp ) ^ tid.mapThemeIdHash(); 0102 } 0103 0104 } 0105 0106 #ifndef QT_NO_DEBUG_STREAM 0107 QDebug operator<<( QDebug, const Marble::TileId & ); 0108 #endif 0109 0110 #endif