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

relation_tags.hpp « generator - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fd4d4bd61a44e8762cbf9a0f134291a497cda52e (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
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once

#include "generator/intermediate_elements.hpp"
#include "generator/routing_helpers.hpp"

#include "base/assert.hpp"
#include "base/cache.hpp"
#include "base/control_flow.hpp"

#include <cstdint>
#include <string>
#include <utility>

struct OsmElement;

namespace generator
{
/// Generated features should include parent relation tags to make
/// full types matching and storing any additional info.
class RelationTagsBase
{
public:
  RelationTagsBase();
  virtual ~RelationTagsBase() = default;

  void Reset(uint64_t fID, OsmElement * p);

  template <class Reader>
  base::ControlFlow operator() (uint64_t id, Reader & reader)
  {
    bool exists = false;
    RelationElement & e = m_cache.Find(id, exists);
    if (!exists)
      CHECK(reader.Read(id, e), (id));

    Process(e);
    return base::ControlFlow::Continue;
  }

protected:
  static bool IsSkipRelation(std::string const & type);
  bool IsKeyTagExists(std::string const & key) const;
  void AddCustomTag(std::pair<std::string, std::string> const & p);
  virtual void Process(RelationElement const & e) = 0;

  uint64_t m_featureID;
  OsmElement * m_current;

private:
  base::Cache<uint64_t, RelationElement> m_cache;
};

class RelationTagsNode : public RelationTagsBase
{
protected:
  void Process(RelationElement const & e) override;

private:
    using Base = RelationTagsBase;
};

class RelationTagsWay : public RelationTagsBase
{
private:
  using Base = RelationTagsBase;
  using NameKeys = std::unordered_set<std::string>;

  bool IsAcceptBoundary(RelationElement const & e) const;

protected:
  void Process(RelationElement const & e) override;
};
}  // namespace generator