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

openlr_decoder.hpp « openlr - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3175e726e4b24058bd44fa9cba6c927d5aabc945 (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
61
#pragma once

#include "openlr/stats.hpp"

#include "base/exception.hpp"

#include <cstdint>
#include <functional>
#include <string>
#include <unordered_set>
#include <vector>

class Index;

namespace openlr
{
struct LinearSegment;
struct DecodedPath;

DECLARE_EXCEPTION(DecoderError, RootException);

class Graph;
class RoadInfoGetter;

class OpenLRDecoder
{
public:
  using CountryParentNameGetter = std::function<std::string(std::string const &)>;

  class SegmentsFilter
  {
  public:
    SegmentsFilter(std::string const & idsPath, bool const multipointsOnly);

    bool Matches(LinearSegment const & segment) const;

  private:
    std::unordered_set<uint32_t> m_ids;
    bool m_idsSet;
    bool const m_multipointsOnly;
  };

  OpenLRDecoder(std::vector<Index> const & indexes,
                CountryParentNameGetter const & countryParentNameGetter);

  // Maps partner segments to mwm paths. |segments| should be sorted by partner id.
  void DecodeV1(std::vector<LinearSegment> const & segments, uint32_t const numThreads,
                std::vector<DecodedPath> & paths);

  void DecodeV2(std::vector<LinearSegment> const & segments, uint32_t const numThreads,
                std::vector<DecodedPath> & paths);

private:
  template <typename Decoder, typename Stats>
  void Decode(std::vector<LinearSegment> const & segments, uint32_t const numThreads,
              std::vector<DecodedPath> & paths);

  std::vector<Index> const & m_indexes;
  CountryParentNameGetter m_countryParentNameGetter;
};
}  // namespace openlr