From 59a0d804f4c32ec4e5790a4ea579f7eaa52ced6c Mon Sep 17 00:00:00 2001 From: Yuri Gorshenin Date: Wed, 27 Jan 2016 13:18:08 +0300 Subject: [PATCH] [search] Fixed buildings matching. * Fixed building-to-street check. High precision geometry is used now to get building center and to get nearby streets. * Fixed search results merge for buildings. --- search/search_query.cpp | 11 ++++++++++- search/v2/features_layer_matcher.hpp | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/search/search_query.cpp b/search/search_query.cpp index 0a28528d37..ff6201a02c 100644 --- a/search/search_query.cpp +++ b/search/search_query.cpp @@ -647,6 +647,14 @@ class PreResult2Maker m_query.GetBestMatchName(f, name); + // It's invalid for a building to have an empty name if it has a + // house number - it will be merged with other buildings in a + // MakePreResult2(). To prevent this, house number is used as a + // building name here, if the latter is empty. + auto const & checker = ftypes::IsBuildingChecker::Instance(); + if (checker(f) && name.empty()) + name = f.GetHouseNumber(); + // country (region) name is a file name if feature isn't from World.mwm if (m_pFV->IsWorld()) country.clear(); @@ -973,7 +981,8 @@ public: void Query::GetBestMatchName(FeatureType const & f, string & name) const { - UNUSED_VALUE(f.ForEachName(impl::BestNameFinder(name, m_keywordsScorer))); + impl::BestNameFinder finder(name, m_keywordsScorer); + UNUSED_VALUE(f.ForEachName(finder)); } /// Makes continuous range for tokens and prefix. diff --git a/search/v2/features_layer_matcher.hpp b/search/v2/features_layer_matcher.hpp index 62536c2526..9fee53fe76 100644 --- a/search/v2/features_layer_matcher.hpp +++ b/search/v2/features_layer_matcher.hpp @@ -308,7 +308,14 @@ private: if (!loaded) GetByIndex(houseId, feature); - m2::PointD const center = feature::GetCenter(feature, FeatureType::WORST_GEOMETRY); + // Best geometry is used here as feature::GetCenter(feature) + // actually modifies internal state of a |feature| by caching + // it's geometry. So, when GetMatchingStreet(houseId, feature) + // is called, high precision geometry is used again to compute + // |feature|'s center, and this is a right behavior as + // house-to-street table was generated by using high-precision + // centers of features. + m2::PointD const center = feature::GetCenter(feature); if (!calculator.GetProjection(center, proj)) continue;