/
githubmirror
/
omim
Обзор
Документация
Войти
/
githubmirror
/
omim
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
drape_frontend/tile_utils.cpp
54 строки
2 KB
Mikhail Gorbushin
[geometry] Get rid of MercatorBounds, refactor to namespace mercator
01 ноя 2019, 11:09
01 ноя 2019, 11:09
6f5d401
Код
Авторство
О чём код?
#include "drape_frontend/tile_utils.hpp" #include "indexer/scales.hpp" #include "geometry/mercator.hpp" #include "base/assert.hpp" #include "base/stl_helpers.hpp" namespace df { CoverageResult CalcTilesCoverage(m2::RectD const & rect, int targetZoom, std::function<void(int, int)> const & processTile) { ASSERT_GREATER(targetZoom, 0, ()); double const rectSize = mercator::Bounds::kRangeX / (1 << (targetZoom - 1)); CoverageResult result; result.m_minTileX = static_cast<int>(floor(rect.minX() / rectSize)); result.m_maxTileX = static_cast<int>(ceil(rect.maxX() / rectSize)); result.m_minTileY = static_cast<int>(floor(rect.minY() / rectSize)); result.m_maxTileY = static_cast<int>(ceil(rect.maxY() / rectSize)); if (processTile != nullptr) { for (int tileY = result.m_minTileY; tileY < result.m_maxTileY; ++tileY) for (int tileX = result.m_minTileX; tileX < result.m_maxTileX; ++tileX) processTile(tileX, tileY); } return result; } bool IsNeighbours(TileKey const & tileKey1, TileKey const & tileKey2) { return !((tileKey1.m_x == tileKey2.m_x) && (tileKey1.m_y == tileKey2.m_y)) && (abs(tileKey1.m_x - tileKey2.m_x) < 2) && (abs(tileKey1.m_y - tileKey2.m_y) < 2); } int ClipTileZoomByMaxDataZoom(int zoom) { int const upperScale = scales::GetUpperScale(); return zoom <= upperScale ? zoom : upperScale; } TileKey GetTileKeyByPoint(m2::PointD const & pt, int zoom) { ASSERT_GREATER(zoom, 0, ()); double const rectSize = mercator::Bounds::kRangeX / (1 << (zoom - 1)); return TileKey(static_cast<int>(floor(pt.x / rectSize)), static_cast<int>(floor(pt.y / rectSize)), zoom); } } // namespace df