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: e9fbc7b01c42a0d3440aecb82e490a0808d7e6dc (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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#pragma once

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

#include "coding/string_utf8_multilang.hpp"

#include "geometry/point2d.hpp"
#include "geometry/rect2d.hpp"

#include <cstdint>
#include <map>
#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 & feature) const;
  void SetPostcode(std::string const & postcode) { m_postcode = postcode; }
  uint64_t GetId() const { return m_id; }
  StringUtf8Multilang const & GetNames() const { return m_names; }
  std::string GetName(std::string const & lang) const
  {
    std::string res;
    if (m_names.GetString(lang, res))
      return res;
    return {};
  }

  feature::Metadata & GetMetadata() { return m_metadata; }

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

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

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

  uint64_t const m_id;
  m2::PointD const m_center;
  std::vector<m2::PointD> const m_boundary;
  Type const m_type;
  StringUtf8Multilang m_names;
  std::string m_postcode;
  feature::Metadata m_metadata;

private:
  void Init();
};

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 ToDebugString() 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 ToDebugString() 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 ToDebugString() 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);
  TestStreet(std::vector<m2::PointD> const & points, StringUtf8Multilang const & name);

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

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

class TestSquare : public TestFeature
{
public:
  TestSquare(m2::RectD const & rect, std::string const & name, std::string const & lang);

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

private:
  m2::RectD m_rect;
};

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 ToDebugString() const override;

  feature::TypesHolder GetTypes() const;
  void SetHouseNumber(std::string const & houseNumber) { m_houseNumber = houseNumber; }
  void SetStreetName(std::string const & name) { m_streetName = name; }
  void SetTypes(std::vector<std::vector<std::string>> const & types) { m_types = types; }

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

class TestMultilingualPOI : public TestPOI
{
public:
  TestMultilingualPOI(m2::PointD const & center, std::string const & defaultName,
                      std::map<std::string, std::string> const & multilingualNames);
  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToDebugString() const override;

private:
  std::map<std::string, std::string> m_multilingualNames;
};

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,
               std::string const & street, std::string const & lang);
  TestBuilding(std::vector<m2::PointD> const & boundary, std::string const & name,
               std::string const & houseNumber, std::string const & street,
               std::string const & lang);

  // TestFeature overrides:
  void Serialize(FeatureBuilder1 & fb) const override;
  std::string ToDebugString() 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 ToDebugString() 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 ToDebugString() const override;

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

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