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

test_feature.hpp « generator_tests_support « generator - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 23df5befed588b63820ff9e04e0219a25c13388a (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#pragma once

#include "indexer/feature_decl.hpp"
#include "indexer/mwm_set.hpp"

#include "geometry/point2d.hpp"

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

class FeatureBuilder1;
class FeatureType;

namespace osm
{
class Editor;
}

namespace generator
{
namespace tests_support
{
class TestFeature
{
public:
  virtual ~TestFeature() = default;

  bool Matches(FeatureType const & feature) const;
  inline void SetPostcode(std::string const & postcode) { m_postcode = postcode; }
  inline uint64_t GetId() const { return m_id; }
  inline std::string const & GetName() const { return m_name; }

  virtual void Serialize(FeatureBuilder1 & fb) const;
  virtual std::string ToString() const = 0;

protected:
  enum class Type
  {
    Point,
    Area,
    Unknown
  };

  TestFeature(std::string const & name, std::string const & lang);
  TestFeature(m2::PointD const & center, std::string const & name, std::string const & lang);
  TestFeature(vector<m2::PointD> const & boundary, std::string const & name,
              std::string const & lang);

  uint64_t const m_id;
  m2::PointD const m_center;
  vector<m2::PointD> const m_boundary;
  Type const m_type;
  std::string const m_name;
  std::string const m_lang;
  std::string m_postcode;
};

class TestCountry : public TestFeature
{
public:
  TestCountry(m2::PointD const & center, std::string const & name, std::string const & lang);

  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToString() const override;
};

class TestCity : public TestFeature
{
public:
  TestCity(m2::PointD const & center, std::string const & name, std::string const & lang,
           uint8_t rank);
  TestCity(std::vector<m2::PointD> const & boundary, std::string const & name,
           std::string const & lang, uint8_t rank);

  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToString() const override;

private:
  uint8_t const m_rank;
};

class TestVillage : public TestFeature
{
public:
  TestVillage(m2::PointD const & center, std::string const & name, std::string const & lang, uint8_t rank);

  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToString() const override;

private:
  uint8_t const m_rank;
};

class TestStreet : public TestFeature
{
public:
  TestStreet(std::vector<m2::PointD> const & points, std::string const & name, std::string const & lang);

  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToString() const override;

private:
  std::vector<m2::PointD> m_points;
};

class TestPOI : public TestFeature
{
public:
  TestPOI(m2::PointD const & center, std::string const & name, std::string const & lang);

  static std::pair<TestPOI, FeatureID> AddWithEditor(osm::Editor & editor, MwmSet::MwmId const & mwmId,
                                                std::string const & enName, m2::PointD const & pt);

  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToString() const override;

  inline void SetHouseNumber(std::string const & houseNumber) { m_houseNumber = houseNumber; }
  inline void SetStreet(TestStreet const & street) { m_streetName = street.GetName(); }
  inline void SetTypes(std::vector<std::vector<std::string>> const & types) { m_types = types; }

private:
  std::string m_houseNumber;
  std::string m_streetName;
  std::vector<std::vector<std::string>> m_types;
};

class TestBuilding : public TestFeature
{
public:
  TestBuilding(m2::PointD const & center, std::string const & name, std::string const & houseNumber,
               std::string const & lang);
  TestBuilding(m2::PointD const & center, std::string const & name, std::string const & houseNumber,
               TestStreet const & street, std::string const & lang);
  TestBuilding(std::vector<m2::PointD> const & boundary, std::string const & name, std::string const & houseNumber,
               TestStreet const & street, std::string const & lang);

  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToString() const override;

  void AddType(std::vector<std::string> const & path) { m_types.push_back(path); }

private:
  std::vector<m2::PointD> const m_boundary;
  std::string const m_houseNumber;
  std::string const m_streetName;

  std::vector<std::vector<std::string>> m_types;
};

class TestPark : public TestFeature
{
public:
  TestPark(std::vector<m2::PointD> const & boundary, std::string const & name, std::string const & lang);

  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToString() const override;

private:
  std::vector<m2::PointD> m_boundary;
};

class TestRoad : public TestFeature
{
public:
  TestRoad(std::vector<m2::PointD> const & points, std::string const & name, std::string const & lang);

  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToString() const override;

private:
  std::vector<m2::PointD> m_points;
};

std::string DebugPrint(TestFeature const & feature);
}  // namespace tests_support
}  // namespace generator