| 898 | } |
| 899 | |
| 900 | void Geocoder::MatchCategories(BaseContext & ctx, bool aroundPivot) |
| 901 | { |
| 902 | TRACE(MatchCategories); |
| 903 | |
| 904 | auto features = ctx.m_features[0]; |
| 905 | |
| 906 | if (aroundPivot) |
| 907 | { |
| 908 | auto const pivotFeatures = RetrieveGeometryFeatures(*m_context, m_params.m_pivot, RectId::Pivot); |
| 909 | ViewportFilter filter(pivotFeatures, m_preRanker.Limit() /* threshold */); |
| 910 | features.m_features = filter.Filter(features.m_features); |
| 911 | features.m_exactMatchingFeatures = features.m_exactMatchingFeatures.Intersect(features.m_features); |
| 912 | } |
| 913 | |
| 914 | // Features have been retrieved from the search index |
| 915 | // using the exact (non-fuzzy) matching and intersected |
| 916 | // with viewport, if needed. Every such feature is relevant. |
| 917 | features.ForEach([&](uint32_t featureId, bool exactMatch) |
| 918 | { |
| 919 | Model::Type type; |
| 920 | if (!GetTypeInGeocoding(ctx, featureId, type)) |
| 921 | return; |
| 922 | |
| 923 | EmitResult(ctx, {m_context->GetId(), featureId}, type, TokenRange(0, ctx.NumTokens()), nullptr /* geoParts */, |
| 924 | true /* allTokensUsed */, exactMatch); |
| 925 | }); |
| 926 | } |
| 927 | |
| 928 | void Geocoder::MatchRegions(BaseContext & ctx, Region::Type type) |
| 929 | { |