diff options
author | vng <viktor.govako@gmail.com> | 2011-01-30 19:48:10 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:11:19 +0300 |
commit | 0c8521ffc3fa545ad815b2419c8c972ed744a33f (patch) | |
tree | 6750bf7cecf3a01f36d9301a867f0207a3482ed8 /indexer/cell_id.hpp | |
parent | ede8645c54bb07206b0cf8927395d71eef9bbeeb (diff) |
Factor Int64ToPoint, PointToInt64 and their helper functions into a separate header,
Diffstat (limited to 'indexer/cell_id.hpp')
-rw-r--r-- | indexer/cell_id.hpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/indexer/cell_id.hpp b/indexer/cell_id.hpp index b43e744d46..d0ee6641b6 100644 --- a/indexer/cell_id.hpp +++ b/indexer/cell_id.hpp @@ -1,26 +1,9 @@ #pragma once #include "mercator.hpp" +#include "point_to_int64.hpp" -#include "../geometry/cellid.hpp" -#include "../geometry/rect2d.hpp" - -#include "../base/base.hpp" #include "../base/assert.hpp" -#include "../std/utility.hpp" -#include "../std/string.hpp" - -typedef double CoordT; -typedef pair<CoordT, CoordT> CoordPointT; - -typedef m2::CellId<19> RectId; - -int64_t PointToInt64(CoordT x, CoordT y); -inline int64_t PointToInt64(CoordPointT const & pt) { return PointToInt64(pt.first, pt.second); } -CoordPointT Int64ToPoint(int64_t v); - -pair<int64_t, int64_t> RectToInt64(m2::RectD const & r); -m2::RectD Int64ToRect(pair<int64_t, int64_t> const & p); template <int MinX, int MinY, int MaxX, int MaxY> struct Bounds @@ -40,7 +23,6 @@ template <typename BoundsT, typename CellIdT> class CellIdConverter { public: - static CoordT XToCellIdX(CoordT x) { return (x - BoundsT::minX) / StepX(); @@ -50,6 +32,15 @@ public: return (y - BoundsT::minY) / StepY(); } + static CoordT CellIdXToX(CoordT x) + { + return (x*StepX() + BoundsT::minX); + } + static CoordT CellIdYToY(CoordT y) + { + return (y*StepY() + BoundsT::minY); + } + static CellIdT ToCellId(CoordT x, CoordT y) { uint32_t const ix = static_cast<uint32_t>(XToCellIdX(x)); @@ -90,7 +81,7 @@ public: static CoordPointT FromCellId(CellIdT id) { pair<uint32_t, uint32_t> const xy = id.XY(); - return CoordPointT(xy.first * StepX() + BoundsT::minX, xy.second * StepY() + BoundsT::minY); + return CoordPointT(CellIdXToX(xy.first), CellIdYToY(xy.second)); } static void GetCellBounds(CellIdT id, CoordT & minX, CoordT & minY, CoordT & maxX, CoordT & maxY) |