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

utils.hpp « track_analyzing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 91b650cd9337f0382ae455f4561b315c2822f281 (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
51
52
53
54
55
56
57
58
59
60
#pragma once

#include "track_analyzing/exceptions.hpp"
#include "track_analyzing/track.hpp"

#include "routing/geometry.hpp"

#include "routing_common/num_mwm_id.hpp"

#include "storage/storage.hpp"

#include "platform/platform.hpp"

#include <algorithm>
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <vector>

namespace track_analyzing
{
using StringFilter = std::function<bool(std::string const &)>;

double CalcSubtrackLength(MatchedTrack::const_iterator begin, MatchedTrack::const_iterator end,
                          routing::Geometry & geometry);
double CalcTrackLength(MatchedTrack const & track, routing::Geometry & geometry);
double CalcSpeedKMpH(double meters, uint64_t secondsElapsed);
void ReadTracks(std::shared_ptr<routing::NumMwmIds> numMwmIds, std::string const & filename,
                MwmToMatchedTracks & mwmToMatchedTracks);
MatchedTrack const & GetMatchedTrack(MwmToMatchedTracks const & mwmToMatchedTracks,
                                     routing::NumMwmIds const & numMwmIds,
                                     std::string const & mwmName, std::string const & user,
                                     size_t trackIdx);
std::string GetCurrentVersionMwmFile(storage::Storage const & storage, std::string const & mwmName);

template <typename MwmToTracks, typename ToDo>
void ForTracksSortedByMwmName(MwmToTracks const & mwmToTracks, routing::NumMwmIds const & numMwmIds,
                              ToDo && toDo)
{
  std::vector<std::string> mwmNames;
  mwmNames.reserve(mwmToTracks.size());
  for (auto const & it : mwmToTracks)
    mwmNames.push_back(numMwmIds.GetFile(it.first).GetName());
  std::sort(mwmNames.begin(), mwmNames.end());

  for (auto const & mwmName : mwmNames)
  {
    auto const mwmId = numMwmIds.GetId(platform::CountryFile(mwmName));
    auto mwmIt = mwmToTracks.find(mwmId);
    CHECK(mwmIt != mwmToTracks.cend(), ());
    toDo(mwmName, mwmIt->second);
  }
}

void ForEachTrackFile(
    std::string const & filepath, std::string const & extension,
    std::shared_ptr<routing::NumMwmIds> numMwmIds,
    std::function<void(std::string const & filename, MwmToMatchedTracks const &)> && toDo);
}  // namespace track_analyzing