Welcome to mirror list, hosted at ThFree Co, Russian Federation.

online_absent_fetcher.cpp « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1bc624b7f18cb78a9e2352dafeee0ebc7d51575f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "online_absent_fetcher.hpp"
#include "online_cross_fetcher.hpp"

#include "platform/platform.hpp"
#include "platform/country_file.hpp"
#include "platform/local_country_file.hpp"

#include "std/vector.hpp"

#include "private.h"

using platform::CountryFile;
using platform::LocalCountryFile;

namespace routing
{
void OnlineAbsentCountriesFetcher::GenerateRequest(const m2::PointD & startPoint,
                                                   const m2::PointD & finalPoint)
{
  // Single mwm case.
  if (m_countryFileFn(startPoint) == m_countryFileFn(finalPoint) ||
      GetPlatform().ConnectionStatus() == Platform::EConnectionType::CONNECTION_NONE)
    return;
  unique_ptr<OnlineCrossFetcher> fetcher =
      make_unique<OnlineCrossFetcher>(OSRM_ONLINE_SERVER_URL, MercatorBounds::ToLatLon(startPoint),
                                      MercatorBounds::ToLatLon(finalPoint));
  // iOS can't reuse threads. So we need to recreate the thread.
  m_fetcherThread.reset(new threads::Thread());
  m_fetcherThread->Create(move(fetcher));
}

void OnlineAbsentCountriesFetcher::GetAbsentCountries(vector<string> & countries)
{
  // Check whether a request was scheduled to be run on the thread.
  if (!m_fetcherThread)
    return;
  m_fetcherThread->Join();
  for (auto const & point : m_fetcherThread->GetRoutineAs<OnlineCrossFetcher>()->GetMwmPoints())
  {
    string const name = m_countryFileFn(point);
    ASSERT(!name.empty(), ());
    if (name.empty() || m_countryLocalFileFn(name))
      continue;

    LOG(LINFO, ("Needs: ", name));
    countries.emplace_back(move(name));
  }
  m_fetcherThread.reset();
}
}  // namespace routing