| 38 | } |
| 39 | |
| 40 | void ForEachOfTypesInRect(DataSource const & dataSource, std::vector<uint32_t> const & types, m2::RectD const & pivot, |
| 41 | FeatureIndexCallback const & fn) |
| 42 | { |
| 43 | std::vector<std::shared_ptr<MwmInfo>> infos; |
| 44 | dataSource.GetMwmsInfo(infos); |
| 45 | |
| 46 | base::Cancellable const cancellable; |
| 47 | CategoriesCache cache(types, cancellable); |
| 48 | auto pivotRectsCache = |
| 49 | PivotRectsCache(1 /* maxNumEntries */, cancellable, std::max(pivot.SizeX(), pivot.SizeY()) /* maxRadiusMeters */); |
| 50 | |
| 51 | for (auto const & info : infos) |
| 52 | { |
| 53 | if (!pivot.IsIntersect(info->m_bordersRect)) |
| 54 | continue; |
| 55 | |
| 56 | auto handle = dataSource.GetMwmHandleById(MwmSet::MwmId(info)); |
| 57 | auto & value = *handle.GetValue(); |
| 58 | if (!value.HasSearchIndex()) |
| 59 | continue; |
| 60 | |
| 61 | MwmContext const mwmContext(std::move(handle)); |
| 62 | auto features = cache.Get(mwmContext); |
| 63 | |
| 64 | auto const pivotFeatures = pivotRectsCache.Get(mwmContext, pivot, scales::GetUpperScale()); |
| 65 | ViewportFilter const filter(pivotFeatures, 0 /* threshold */); |
| 66 | features = filter.Filter(features); |
| 67 | MwmSet::MwmId mwmId(info); |
| 68 | features.ForEach([&fn, &mwmId](uint64_t bit) { fn(FeatureID(mwmId, base::asserted_cast<uint32_t>(bit))); }); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | bool IsCategorialRequestFuzzy(std::string const & query, std::string const & categoryName) |
| 73 | { |