diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2018-07-11 14:25:06 +0300 |
---|---|---|
committer | Tatiana Yan <tatiana.kondakova@gmail.com> | 2018-07-12 10:22:45 +0300 |
commit | f79ed2af2c7399a72165295fa46688e1390f98b7 (patch) | |
tree | 984bdbddb26174ddca9140739105e264756c14bc /search | |
parent | b5e49972d6beb662fb6f04756e1c1945e2e57863 (diff) |
City boundaries visualization.
Diffstat (limited to 'search')
-rw-r--r-- | search/cities_boundaries_table.cpp | 17 | ||||
-rw-r--r-- | search/cities_boundaries_table.hpp | 15 |
2 files changed, 32 insertions, 0 deletions
diff --git a/search/cities_boundaries_table.cpp b/search/cities_boundaries_table.cpp index 55d9c39c2c..07a2e3d8bf 100644 --- a/search/cities_boundaries_table.cpp +++ b/search/cities_boundaries_table.cpp @@ -105,4 +105,21 @@ bool CitiesBoundariesTable::Get(uint32_t fid, Boundaries & bs) const bs = Boundaries(it->second, m_eps); return true; } + +void GetCityBoundariesInRectForTesting(CitiesBoundariesTable const & table, m2::RectD const & rect, + vector<uint32_t> & featureIds) +{ + featureIds.clear(); + for (auto const & kv : table.m_table) + { + for (auto const & cb : kv.second) + { + if (rect.IsIntersect(m2::RectD(cb.m_bbox.Min(), cb.m_bbox.Max()))) + { + featureIds.push_back(kv.first); + break; + } + } + } +} } // namespace search diff --git a/search/cities_boundaries_table.hpp b/search/cities_boundaries_table.hpp index e9ac3841fa..fbe60ffe01 100644 --- a/search/cities_boundaries_table.hpp +++ b/search/cities_boundaries_table.hpp @@ -4,6 +4,7 @@ #include "indexer/feature_decl.hpp" #include "geometry/point2d.hpp" +#include "geometry/rect2d.hpp" #include <cstdint> #include <sstream> @@ -23,6 +24,10 @@ namespace search { class CitiesBoundariesTable { + friend void GetCityBoundariesInRectForTesting(CitiesBoundariesTable const &, + m2::RectD const & rect, + std::vector<uint32_t> & featureIds); + public: class Boundaries { @@ -43,6 +48,8 @@ public: // |*this|. bool HasPoint(m2::PointD const & p) const; + std::vector<indexer::CityBoundary> const & GetBoundariesForTesting() const { return m_boundaries; } + friend std::string DebugPrint(Boundaries const & boundaries) { std::ostringstream os; @@ -68,10 +75,18 @@ public: bool Get(FeatureID const & fid, Boundaries & bs) const; bool Get(uint32_t fid, Boundaries & bs) const; + size_t GetSize() const { return m_table.size(); } + private: DataSource const & m_dataSource; MwmSet::MwmId m_mwmId; std::unordered_map<uint32_t, std::vector<indexer::CityBoundary>> m_table; double m_eps = 0.0; }; + +/// \brief Fills |featureIds| with feature ids of city boundaries if bounding rect of +/// the city boundary crosses |rect|. +/// \note This method is inefficient and is written for debug and test purposes only. +void GetCityBoundariesInRectForTesting(CitiesBoundariesTable const &, m2::RectD const & rect, + std::vector<uint32_t> & featureIds); } // namespace search |