blob: 7069bcd66f3ca4f52b0f34241c9256a23de51441 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "drape_frontend/tile_key.hpp"
#include "indexer/mercator.hpp"
namespace df
{
TileKey::TileKey() :
m_x(-1), m_y(-1), m_zoomLevel(-1)
{
}
TileKey::TileKey(int x, int y, int zoomLevel)
: m_x(x), m_y(y), m_zoomLevel(zoomLevel)
{
}
bool TileKey::operator <(TileKey const & other) const
{
if (m_zoomLevel != other.m_zoomLevel)
return m_zoomLevel < other.m_zoomLevel;
if (m_y != other.m_y)
return m_y < other.m_y;
return m_x < other.m_x;
}
bool TileKey::operator ==(TileKey const & other) const
{
return m_x == other.m_x &&
m_y == other.m_y &&
m_zoomLevel == other.m_zoomLevel;
}
m2::RectD TileKey::GetGlobalRect() const
{
double const worldSizeDevisor = 1 << m_zoomLevel;
// Mercator SizeX and SizeY is equal
double const rectSize = (MercatorBounds::maxX - MercatorBounds::minX) / worldSizeDevisor;
double const startX = m_x * rectSize;
double const startY = m_y * rectSize;
return m2::RectD (startX, startY, startX + rectSize, startY + rectSize);
}
} //namespace df
|