From 458f2610305d9134ecf631e72b72d5ea3d223872 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Tue, 27 Aug 2019 14:21:52 +0300 Subject: [PATCH] Revert "[core] fix for matching bookmarks on areas" This reverts commit 928e522c3ddbff464f5d8fabb31c99743a40d8f7. --- indexer/feature_data.cpp | 15 ----------- indexer/feature_data.hpp | 2 -- map/framework.cpp | 58 +++++++++------------------------------- map/framework.hpp | 9 ++----- 4 files changed, 15 insertions(+), 69 deletions(-) diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp index 5b149140a4..e1c28c28c1 100644 --- a/indexer/feature_data.cpp +++ b/indexer/feature_data.cpp @@ -44,18 +44,6 @@ TypesHolder::TypesHolder(FeatureType & f) : m_size(0), m_geomType(f.GetGeomType( }); } -// static -TypesHolder TypesHolder::FromTypesIndexes(std::vector const & indexes) -{ - TypesHolder result; - for (auto index : indexes) - { - result.Add(classif().GetTypeForIndex(index)); - } - - return result; -} - void TypesHolder::Remove(uint32_t type) { UNUSED_VALUE(RemoveIf(base::EqualFunctor(type))); @@ -63,9 +51,6 @@ void TypesHolder::Remove(uint32_t type) bool TypesHolder::Equals(TypesHolder const & other) const { - if (m_size != other.m_size) - return false; - vector my(this->begin(), this->end()); vector his(other.begin(), other.end()); diff --git a/indexer/feature_data.hpp b/indexer/feature_data.hpp index 73f36dabb2..e71c7f3407 100644 --- a/indexer/feature_data.hpp +++ b/indexer/feature_data.hpp @@ -61,8 +61,6 @@ namespace feature explicit TypesHolder(GeomType geomType) : m_geomType(geomType) {} explicit TypesHolder(FeatureType & f); - static TypesHolder FromTypesIndexes(std::vector const & src); - void Assign(uint32_t type) { m_types[0] = type; diff --git a/map/framework.cpp b/map/framework.cpp index 80ccb1d3b2..5461daa3a6 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -827,18 +827,6 @@ kml::MarkGroupId Framework::AddCategory(string const & categoryName) return GetBookmarkManager().CreateBookmarkCategory(categoryName); } -void Framework::FillPointInfoForBookmark(Bookmark const & bmk, place_page::Info & info) const -{ - feature::TypesHolder types; - if (!bmk.GetData().m_featureTypes.empty()) - types = feature::TypesHolder::FromTypesIndexes(bmk.GetData().m_featureTypes); - - FillPointInfo(info, bmk.GetPivot(), {}, [&types](feature::GeomType geomType, FeatureType & ft) - { - return !types.Empty() && feature::TypesHolder(ft).Equals(types); - }); -} - void Framework::FillBookmarkInfo(Bookmark const & bmk, place_page::Info & info) const { info.SetBookmarkCategoryName(GetBookmarkManager().GetCategoryName(bmk.GetGroupId())); @@ -847,7 +835,7 @@ void Framework::FillBookmarkInfo(Bookmark const & bmk, place_page::Info & info) info.SetBookmarkCategoryId(bmk.GetGroupId()); info.SetOpeningMode(bmk.GetDescription().empty() ? place_page::OpeningMode::Preview : place_page::OpeningMode::PreviewPlus); - FillPointInfoForBookmark(bmk, info); + FillPointInfo(bmk.GetPivot(), {} /* customTitle */, info); } void Framework::ResetBookmarkInfo(Bookmark const & bmk, place_page::Info & info) const @@ -857,7 +845,7 @@ void Framework::ResetBookmarkInfo(Bookmark const & bmk, place_page::Info & info) info.SetBookmarkId(kml::kInvalidMarkId); info.SetBookmarkCategoryId(kml::kInvalidMarkGroupId); info.SetOpeningMode(place_page::OpeningMode::Preview); - FillPointInfoForBookmark(bmk, info); + FillPointInfo(bmk.GetPivot(), {} /* customTitle */, info); } search::ReverseGeocoder::Address Framework::GetAddressAtPoint(m2::PointD const & pt) const @@ -884,11 +872,9 @@ void Framework::FillFeatureInfo(FeatureID const & fid, place_page::Info & info) FillInfoFromFeatureType(*ft, info); } -void Framework::FillPointInfo(place_page::Info & info, m2::PointD const & mercator, - string const & customTitle /* = {} */, - FeatureMatcher && matcher /* = nullptr */) const +void Framework::FillPointInfo(m2::PointD const & mercator, string const & customTitle, place_page::Info & info) const { - auto const fid = GetFeatureAtPoint(mercator, move(matcher)); + auto const fid = GetFeatureAtPoint(mercator); if (fid.IsValid()) { @@ -1051,7 +1037,7 @@ void Framework::FillInfoFromFeatureType(FeatureType & ft, place_page::Info & inf void Framework::FillApiMarkInfo(ApiMarkPoint const & api, place_page::Info & info) const { - FillPointInfo(info, api.GetPivot()); + FillPointInfo(api.GetPivot(), {} /* customTitle */, info); string const & name = api.GetName(); if (!name.empty()) info.SetCustomName(name); @@ -1064,7 +1050,7 @@ void Framework::FillSearchResultInfo(SearchMarkPoint const & smp, place_page::In if (smp.GetFeatureID().IsValid()) FillFeatureInfo(smp.GetFeatureID(), info); else - FillPointInfo(info, smp.GetPivot(), smp.GetMatchedName()); + FillPointInfo(smp.GetPivot(), smp.GetMatchedName(), info); } void Framework::FillMyPositionInfo(place_page::Info & info, df::TapInfo const & tapInfo) const @@ -1087,7 +1073,7 @@ void Framework::FillMyPositionInfo(place_page::Info & info, df::TapInfo const & void Framework::FillRouteMarkInfo(RouteMarkPoint const & rmp, place_page::Info & info) const { - FillPointInfo(info, rmp.GetPivot()); + FillPointInfo(rmp.GetPivot(), {} /* customTitle */, info); info.SetIsRoutePoint(); info.SetRouteMarkType(rmp.GetRoutePointType()); info.SetIntermediateIndex(rmp.GetIntermediateIndex()); @@ -1188,7 +1174,7 @@ void Framework::ShowFeatureByMercator(m2::PointD const & pt) place_page::Info info; std::string name; GetBookmarkManager().SelectionMark().SetPtOrg(pt); - FillPointInfo(info, pt, name); + FillPointInfo(pt, name, info); ActivateMapSelection(false, df::SelectionShape::OBJECT_POI, info); m_lastTapEvent = MakeTapEvent(info.GetMercator(), info.GetID(), TapEvent::Source::Other); } @@ -1701,7 +1687,7 @@ void Framework::SelectSearchResult(search::Result const & result, bool animation break; case Result::Type::LatLon: - FillPointInfo(info, result.GetFeatureCenter(), result.GetString()); + FillPointInfo(result.GetFeatureCenter(), result.GetString(), info); scale = scales::GetUpperComfortScale(); break; @@ -2276,7 +2262,7 @@ bool Framework::ShowMapForURL(string const & url) else { GetBookmarkManager().SelectionMark().SetPtOrg(point); - FillPointInfo(info, point, name); + FillPointInfo(point, name, info); ActivateMapSelection(false, df::SelectionShape::OBJECT_POI, info); } m_lastTapEvent = MakeTapEvent(info.GetMercator(), info.GetID(), TapEvent::Source::Other); @@ -2313,25 +2299,12 @@ url_scheme::SearchRequest Framework::GetParsedSearchRequest() const return m_ParsedMapApi.GetSearchRequest(); } -FeatureID Framework::GetFeatureAtPoint(m2::PointD const & mercator, - FeatureMatcher && matcher /* = nullptr */) const +FeatureID Framework::GetFeatureAtPoint(m2::PointD const & mercator) const { FeatureID poi, line, area; - auto haveBuilding = false; - auto fullMatch = false; - auto closestDistnceToCenter = numeric_limits::max(); - auto currentDistance = numeric_limits::max(); + bool haveBuilding = false; indexer::ForEachFeatureAtPoint(m_model.GetDataSource(), [&](FeatureType & ft) { - if (fullMatch) - return; - if (matcher && matcher(ft.GetGeomType(), ft)) - { - fullMatch = true; - poi = ft.GetID(); - return; - } - switch (ft.GetGeomType()) { case feature::GeomType::Point: @@ -2347,13 +2320,8 @@ FeatureID Framework::GetFeatureAtPoint(m2::PointD const & mercator, // Skip/ignore coastlines. if (feature::TypesHolder(ft).Has(classif().GetCoastType())) return; - currentDistance = MercatorBounds::DistanceOnEarth(mercator, feature::GetCenter(ft)); - // Choose first closest object. - if (currentDistance >= closestDistnceToCenter) - return; area = ft.GetID(); haveBuilding = ftypes::IsBuildingChecker::Instance()(ft); - closestDistnceToCenter = currentDistance; break; case feature::GeomType::Undefined: ASSERT(false, ("case feature::Undefined")); @@ -2611,7 +2579,7 @@ df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(TapEvent const & t bool showMapSelection = false; if (tapInfo.m_isLong || tapEvent.m_source == TapEvent::Source::Search) { - FillPointInfo(outInfo, tapInfo.m_mercator); + FillPointInfo(tapInfo.m_mercator, {} /* customTitle */, outInfo); if (!outInfo.IsFeature() && featureTapped.IsValid()) FillFeatureInfo(featureTapped, outInfo); showMapSelection = true; diff --git a/map/framework.hpp b/map/framework.hpp index 041e95f65c..ac59e91260 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -719,8 +719,6 @@ public: ParsedRoutingData GetParsedRoutingData() const; url_scheme::SearchRequest GetParsedSearchRequest() const; - using FeatureMatcher = std::function; - private: /// @returns true if command was handled by editor. bool ParseEditorDebugCommand(search::SearchParams const & params); @@ -733,15 +731,13 @@ private: void FillFeatureInfo(FeatureID const & fid, place_page::Info & info) const; /// @param customTitle, if not empty, overrides any other calculated name. - void FillPointInfo(place_page::Info & info, m2::PointD const & mercator, - string const & customTitle = {}, FeatureMatcher && matcher = nullptr) const; + void FillPointInfo(m2::PointD const & mercator, string const & customTitle, place_page::Info & info) const; void FillInfoFromFeatureType(FeatureType & ft, place_page::Info & info) const; void FillApiMarkInfo(ApiMarkPoint const & api, place_page::Info & info) const; void FillSearchResultInfo(SearchMarkPoint const & smp, place_page::Info & info) const; void FillMyPositionInfo(place_page::Info & info, df::TapInfo const & tapInfo) const; void FillRouteMarkInfo(RouteMarkPoint const & rmp, place_page::Info & info) const; void FillRoadTypeMarkInfo(RoadWarningMark const & roadTypeMark, place_page::Info & info) const; - void FillPointInfoForBookmark(Bookmark const & bmk, place_page::Info & info) const; public: void FillBookmarkInfo(Bookmark const & bmk, place_page::Info & info) const; @@ -752,8 +748,7 @@ public: /// Get "best for the user" feature at given point even if it's invisible on the screen. /// Ignores coastlines and prefers buildings over other area features. /// @returns invalid FeatureID if no feature was found at the given mercator point. - FeatureID GetFeatureAtPoint(m2::PointD const & mercator, - FeatureMatcher && matcher = nullptr) const; + FeatureID GetFeatureAtPoint(m2::PointD const & mercator) const; template void ForEachFeatureAtPoint(TFn && fn, m2::PointD const & mercator) const {