3#include "TileCoordsPyramid.h"
5#include <MarbleDebug.h>
14class Q_DECL_HIDDEN TileCoordsPyramid::Private
17 Private(
int const topLevel,
int const bottomLevel);
21 QRect m_bottomLevelCoords;
25TileCoordsPyramid::Private::Private(
int const topLevel,
int const bottomLevel)
26 : m_topLevel(topLevel)
27 , m_bottomLevel(bottomLevel)
29 Q_ASSERT(m_topLevel <= m_bottomLevel);
32TileCoordsPyramid::TileCoordsPyramid(
int const topLevel,
int const bottomLevel)
33 : d(new Private(topLevel, bottomLevel))
37TileCoordsPyramid::TileCoordsPyramid(TileCoordsPyramid
const &other)
38 : d(new Private(*other.d))
42TileCoordsPyramid::TileCoordsPyramid()
43 : d(new Private(0, 0))
47TileCoordsPyramid &TileCoordsPyramid::operator=(TileCoordsPyramid
const &rhs)
49 TileCoordsPyramid temp(rhs);
54TileCoordsPyramid::~TileCoordsPyramid()
59int TileCoordsPyramid::topLevel()
const
64int TileCoordsPyramid::bottomLevel()
const
66 return d->m_bottomLevel;
69void TileCoordsPyramid::setBottomLevelCoords(
QRect const &coords)
71 d->m_bottomLevelCoords = coords;
74QRect TileCoordsPyramid::coords(
int const level)
const
76 Q_ASSERT(d->m_topLevel <= level && level <= d->m_bottomLevel);
77 int bottomX1, bottomY1, bottomX2, bottomY2;
78 d->m_bottomLevelCoords.getCoords(&bottomX1, &bottomY1, &bottomX2, &bottomY2);
79 int const deltaLevel = d->m_bottomLevel -
level;
80 int const x1 = bottomX1 >> deltaLevel;
81 int const y1 = bottomY1 >> deltaLevel;
82 int const x2 = bottomX2 >> deltaLevel;
83 int const y2 = bottomY2 >> deltaLevel;
89void TileCoordsPyramid::setValidTileLevels(
const QList<int> validLevels)
91 d->m_validLevels = validLevels;
96 return d->m_validLevels;
99qint64 TileCoordsPyramid::tilesCount()
const
102 for (
int level = d->m_topLevel; level <= d->m_bottomLevel; ++level) {
103 if (!d->m_validLevels.isEmpty() && !d->m_validLevels.contains(level))
106 QRect const levelCoords = coords(level);
108 result += qint64(levelCoords.
width()) * levelCoords.
height();
113void TileCoordsPyramid::swap(TileCoordsPyramid &other)
115 std::swap(d, other.d);
QStringView level(QStringView ifopt)
Binds a QML item to a specific geodetic location in screen coordinates.
void setCoords(int x1, int y1, int x2, int y2)