Marble

TileId.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2008, 2010 Jens-Michael Hoffmann <[email protected]>
4 // SPDX-FileCopyrightText: 2012 Bernhard Beschow <[email protected]>
5 //
6 
7 #ifndef MARBLE_TILEID_H
8 #define MARBLE_TILEID_H
9 
10 #include "marble_export.h"
11 
12 #include <QHash>
13 
14 class QString;
15 
16 namespace Marble
17 {
18 class GeoDataCoordinates;
19 
20 class MARBLE_EXPORT TileId
21 {
22  public:
23  TileId( QString const & mapThemeId, int zoomLevel, int tileX, int tileY );
24  TileId( uint mapThemeIdHash, int zoomLevel, int tileX, int tileY );
25  TileId();
26 
27  int zoomLevel() const;
28  int x() const;
29  int y() const;
30  uint mapThemeIdHash() const;
31 
32  bool operator==( TileId const& rhs ) const;
33  bool operator<( TileId const& rhs ) const;
34 
35  static TileId fromCoordinates( const GeoDataCoordinates& coords, int zoomLevel );
36 
37  private:
38  uint m_mapThemeIdHash;
39  int m_zoomLevel;
40  int m_tileX;
41  int m_tileY;
42 };
43 
44 uint qHash( TileId const& );
45 
46 
47 // inline definitions
48 
49 inline int TileId::zoomLevel() const
50 {
51  return m_zoomLevel;
52 }
53 
54 inline int TileId::x() const
55 {
56  return m_tileX;
57 }
58 
59 inline int TileId::y() const
60 {
61  return m_tileY;
62 }
63 
64 inline uint TileId::mapThemeIdHash() const
65 {
66  return m_mapThemeIdHash;
67 }
68 
69 inline bool TileId::operator==( TileId const& rhs ) const
70 {
71  return m_zoomLevel == rhs.m_zoomLevel
72  && m_tileX == rhs.m_tileX
73  && m_tileY == rhs.m_tileY
74  && m_mapThemeIdHash == rhs.m_mapThemeIdHash;
75 }
76 
77 inline bool TileId::operator<( TileId const& rhs ) const
78 {
79  if (m_zoomLevel < rhs.m_zoomLevel)
80  return true;
81  else if (m_zoomLevel == rhs.m_zoomLevel
82  && m_tileX < rhs.m_tileX)
83  return true;
84  else if (m_zoomLevel == rhs.m_zoomLevel
85  && m_tileX == rhs.m_tileX
86  && m_tileY < rhs.m_tileY)
87  return true;
88  else if (m_zoomLevel == rhs.m_zoomLevel
89  && m_tileX == rhs.m_tileX
90  && m_tileY == rhs.m_tileY
91  && m_mapThemeIdHash < rhs.m_mapThemeIdHash)
92  return true;
93  return false;
94 }
95 
96 inline uint qHash( TileId const& tid )
97 {
98  const quint64 tmp = (( quint64 )( tid.zoomLevel() ) << 36 )
99  + (( quint64 )( tid.x() ) << 18 )
100  + ( quint64 )( tid.y() );
101  return ::qHash( tmp ) ^ tid.mapThemeIdHash();
102 }
103 
104 }
105 
106 #ifndef QT_NO_DEBUG_STREAM
107 QDebug operator<<( QDebug, const Marble::TileId & );
108 #endif
109 
110 #endif
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 04:09:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.