Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tile_key.cpp « drape_frontend - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3995178fd14747403f8e9259ee0df9b22b928368 (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 "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