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{
22public:
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
37private:
38 uint m_mapThemeIdHash;
39 int m_zoomLevel;
40 int m_tileX;
41 int m_tileY;
42};
43
44uint qHash(TileId const &);
45
46// inline definitions
47
48inline int TileId::zoomLevel() const
49{
50 return m_zoomLevel;
51}
52
53inline int TileId::x() const
54{
55 return m_tileX;
56}
57
58inline int TileId::y() const
59{
60 return m_tileY;
61}
62
63inline uint TileId::mapThemeIdHash() const
64{
65 return m_mapThemeIdHash;
66}
67
68inline bool TileId::operator==(TileId const &rhs) const
69{
70 return m_zoomLevel == rhs.m_zoomLevel && m_tileX == rhs.m_tileX && m_tileY == rhs.m_tileY && m_mapThemeIdHash == rhs.m_mapThemeIdHash;
71}
72
73inline bool TileId::operator<(TileId const &rhs) const
74{
75 if (m_zoomLevel < rhs.m_zoomLevel)
76 return true;
77 else if (m_zoomLevel == rhs.m_zoomLevel && m_tileX < rhs.m_tileX)
78 return true;
79 else if (m_zoomLevel == rhs.m_zoomLevel && m_tileX == rhs.m_tileX && m_tileY < rhs.m_tileY)
80 return true;
81 else if (m_zoomLevel == rhs.m_zoomLevel && m_tileX == rhs.m_tileX && m_tileY == rhs.m_tileY && m_mapThemeIdHash < rhs.m_mapThemeIdHash)
82 return true;
83 return false;
84}
85
86inline uint qHash(TileId const &tid)
87{
88 const quint64 tmp = ((quint64)(tid.zoomLevel()) << 36) + ((quint64)(tid.x()) << 18) + (quint64)(tid.y());
89 return ::qHash(tmp) ^ tid.mapThemeIdHash();
90}
91
92}
93
94#ifndef QT_NO_DEBUG_STREAM
95QDebug operator<<(QDebug, const Marble::TileId &);
96#endif
97
98#endif
KTEXTEDITOR_EXPORT size_t qHash(KTextEditor::Cursor cursor, size_t seed=0) noexcept
bool operator<(const PosRange< Trait > &l, const PosRange< Trait > &r)
bool operator==(const StyleDelim &l, const StyleDelim &r)
Binds a QML item to a specific geodetic location in screen coordinates.
QDebug operator<<(QDebug dbg, const PerceptualColor::MultiSpinBoxSection &value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.