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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYury Melnichek <melnichek@gmail.com>2011-04-25 05:49:24 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:16:22 +0300
commit81e732a71d79d31cd41b0c54020ae23b8f2961ea (patch)
tree83f6198330951b7d0335a2416e05f3021c041951 /indexer/cell_coverer.hpp
parent830281b9eeb7b939676d338c505a79fc6cf6582b (diff)
Rewrite feature covering. Use a simpler approach and remove stream optimizer.
Diffstat (limited to 'indexer/cell_coverer.hpp')
-rw-r--r--indexer/cell_coverer.hpp121
1 files changed, 1 insertions, 120 deletions
diff --git a/indexer/cell_coverer.hpp b/indexer/cell_coverer.hpp
index 2f575493c2..0d8aec8ef1 100644
--- a/indexer/cell_coverer.hpp
+++ b/indexer/cell_coverer.hpp
@@ -5,126 +5,7 @@
#include "../std/queue.hpp"
#include "../std/vector.hpp"
-inline bool IntersectsHoriz(CoordT x1, CoordT y1, CoordT x2, CoordT y2,
- CoordT y, CoordT l, CoordT r)
-{
- CoordT d = (y1 - y) * (y2 - y);
- if (d > 0) return false;
-
- CoordT x = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
-
- if ((l - x) * (r - x) <= 0) return true; else return false;
-}
-
-inline bool IntersectsVert(CoordT x1, CoordT y1, CoordT x2, CoordT y2,
- CoordT x, CoordT b, CoordT t)
-{
- CoordT d = (x1 - x) * (x2 - x);
- if (d > 0) return false;
-
- CoordT y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
-
- if ((b - y) * (t - y) <= 0) return true; else return false;
-}
-
-template <typename BoundsT, typename CellIdT>
-inline bool CellIntersects(vector<CoordPointT> const & polyLine, CellIdT id)
-{
- CoordT minX, minY, maxX, maxY;
- CellIdConverter<BoundsT, CellIdT>::GetCellBounds(id, minX, minY, maxX, maxY);
- CoordPointT minPoint = make_pair(minX, minY);
- CoordPointT maxPoint = make_pair(maxX, maxY);
-
- for (size_t i = 0; i < polyLine.size() - 1; ++i)
- {
- if (IntersectsHoriz(polyLine[i].first, polyLine[i].second,
- polyLine[i + 1].first, polyLine[i + 1].second,
- minPoint.second, minPoint.first, maxPoint.first)) return true;
-
- if (IntersectsHoriz(polyLine[i].first, polyLine[i].second,
- polyLine[i + 1].first, polyLine[i + 1].second,
- maxPoint.second, minPoint.first, maxPoint.first)) return true;
-
- if (IntersectsVert(polyLine[i].first, polyLine[i].second,
- polyLine[i + 1].first, polyLine[i + 1].second,
- minPoint.first, minPoint.second, maxPoint.second)) return true;
-
- if (IntersectsVert(polyLine[i].first, polyLine[i].second,
- polyLine[i + 1].first, polyLine[i + 1].second,
- maxPoint.first, minPoint.second, maxPoint.second)) return true;
- }
-
- return false;
-}
-
-template <typename BoundsT, typename CellIdT>
-inline void SplitCell(vector<CoordPointT> const & polyLine, queue<CellIdT> & cellQueue)
-{
- CellIdT id = cellQueue.front();
- cellQueue.pop();
-
- for (size_t i = 0; i < 4; ++i)
- {
- CellIdT child = id.Child(i);
-
- if (CellIntersects<BoundsT>(polyLine, child))
- {
- cellQueue.push(child);
- }
- }
-}
-
-template <typename ItT>
-inline bool FindBounds(ItT begin, ItT end,
- CoordT & minX, CoordT & minY, CoordT & maxX, CoordT & maxY)
-{
- if (begin == end) return false;
-
- minX = begin->first;
- maxX = begin->first;
- minY = begin->second;
- maxY = begin->second;
-
- for (ItT it = begin; it != end; ++it)
- {
- if (it->first < minX) minX = it->first;
- if (it->first > maxX) maxX = it->first;
- if (it->second < minY) minY = it->second;
- if (it->second > maxY) maxY = it->second;
- }
-
- return true;
-}
-
-template <typename BoundsT, typename CellIdT>
-inline CellIdT CoverPoint(CoordPointT const & point)
-{
- return CellIdConverter<BoundsT, CellIdT>::ToCellId(point.first, point.second);
-}
-
-template <typename BoundsT, typename CellIdT>
-inline void CoverPolyLine(vector< CoordPointT > const & polyLine, size_t cellDepth,
- vector<CellIdT> & cells)
-{
- CoordT minX = 0, minY = 0, maxX = 0, maxY = 0;
- FindBounds(polyLine.begin(), polyLine.end(), minX, minY, maxX, maxY);
-
- CellIdT commonCell =
- CellIdConverter<BoundsT, CellIdT>::Cover2PointsWithCell(minX, minY, maxX, maxY);
-
- queue<CellIdT> cellQueue;
- cellQueue.push(commonCell);
- while (cellQueue.front().Level() < static_cast<int>(cellDepth)) // cellQueue.size() < cells_count
- {
- SplitCell<BoundsT>(polyLine, cellQueue);
- }
-
- while (!cellQueue.empty())
- {
- cells.push_back(cellQueue.front());
- cellQueue.pop();
- }
-}
+// TODO: Move neccessary functions to geometry/covering.hpp and delete this file.
template <typename BoundsT, typename CellIdT>
inline void SplitRectCell(CellIdT id,