| 528 | } |
| 529 | |
| 530 | void Geocoder::GoImpl(vector<MwmInfoPtr> const & infos, bool inViewport) |
| 531 | { |
| 532 | // base::PProf pprof("/tmp/geocoder.prof"); |
| 533 | |
| 534 | // Tries to find world and fill localities table. |
| 535 | { |
| 536 | m_cities.clear(); |
| 537 | for (auto & regions : m_regions) |
| 538 | regions.clear(); |
| 539 | MwmSet::MwmHandle handle = indexer::FindWorld(m_dataSource, infos); |
| 540 | if (handle.IsAlive()) |
| 541 | { |
| 542 | auto & value = *handle.GetValue(); |
| 543 | |
| 544 | // All MwmIds are unique during the application lifetime, so |
| 545 | // it's ok to save MwmId. |
| 546 | m_worldId = handle.GetId(); |
| 547 | m_context = make_unique<MwmContext>(std::move(handle)); |
| 548 | |
| 549 | if (value.HasSearchIndex()) |
| 550 | { |
| 551 | BaseContext ctx; |
| 552 | InitBaseContext(ctx); |
| 553 | FillLocalitiesTable(ctx); |
| 554 | } |
| 555 | |
| 556 | m_context.reset(); |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | // Orders countries by distance from viewport center and position. |
| 561 | // This order is used during MatchAroundPivot() stage - we try to |
| 562 | // match as many features as possible without trying to match |
| 563 | // locality (COUNTRY or CITY), and only when there are too many |
| 564 | // features, viewport and position vicinity filter is used. To |
| 565 | // prevent full search in all mwms, we need to limit somehow a set |
| 566 | // of mwms for MatchAroundPivot(), so, we always call |
| 567 | // MatchAroundPivot() on maps intersecting with pivot rect, other |
| 568 | // maps are ordered by distance from pivot, and we stop to call |
| 569 | // MatchAroundPivot() on them as soon as at least one feature is |
| 570 | // found. |
| 571 | auto const infosWithType = OrderCountries(inViewport, infos); |
| 572 | |
| 573 | // MatchAroundPivot() should always be matched in mwms |
| 574 | // intersecting with position and viewport. |
| 575 | auto processCountry = [&](unique_ptr<MwmContext> context, bool updatePreranker) |
| 576 | { |
| 577 | ASSERT(context, ()); |
| 578 | m_context = std::move(context); |
| 579 | |
| 580 | SCOPE_GUARD(cleanup, [&]() |
| 581 | { |
| 582 | LOG(LDEBUG, (m_context->GetName(), "geocoding complete.")); |
| 583 | m_matcher->OnQueryFinished(); |
| 584 | m_matcher = nullptr; |
| 585 | m_context.reset(); |
| 586 | }); |
| 587 |
nothing calls this directly
no test coverage detected