Marble

TileId.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2008, 2010 Jens-Michael Hoffmann <jensmh@gmx.de>
4// SPDX-FileCopyrightText: 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
5//
6
7#ifndef MARBLE_TILEID_H
8#define MARBLE_TILEID_H
9
10#include "marble_export.h"
11
12#include <QHash>
13
14class QString;
15
16namespace Marble
17{
18class GeoDataCoordinates;
19
20class 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
44uint qHash( TileId const& );
45
46
47// inline definitions
48
49inline int TileId::zoomLevel() const
50{
51 return m_zoomLevel;
52}
53
54inline int TileId::x() const
55{
56 return m_tileX;
57}
58
59inline int TileId::y() const
60{
61 return m_tileY;
62}
63
64inline uint TileId::mapThemeIdHash() const
65{
66 return m_mapThemeIdHash;
67}
68
69inline 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
77inline 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
96inline 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
107QDebug operator<<( QDebug, const Marble::TileId & );
108#endif
109
110#endif
KTEXTEDITOR_EXPORT size_t qHash(KTextEditor::Cursor cursor, size_t seed=0) noexcept
Binds a QML item to a specific geodetic location in screen coordinates.
QDebug operator<<(QDebug dbg, const PerceptualColor::LchaDouble &value)
bool operator==(const QGraphicsApiFilter &reference, const QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.