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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
#pragma once
#include "base/base.hpp"
#include "std/algorithm.hpp"
#include "std/array.hpp"
#include "std/initializer_list.hpp"
#include "std/limits.hpp"
#include "std/string.hpp"
#include "std/utility.hpp"
#include "std/vector.hpp"
namespace feature { class TypesHolder; }
class FeatureType;
namespace ftypes
{
class BaseChecker
{
size_t const m_level;
protected:
vector<uint32_t> m_types;
BaseChecker(size_t level = 2) : m_level(level) {}
virtual ~BaseChecker() = default;
public:
virtual bool IsMatched(uint32_t type) const;
bool operator() (feature::TypesHolder const & types) const;
bool operator() (FeatureType const & ft) const;
bool operator() (vector<uint32_t> const & types) const;
static uint32_t PrepareToMatch(uint32_t type, uint8_t level);
template <typename TFn>
void ForEachType(TFn && fn) const
{
for_each(m_types.cbegin(), m_types.cend(), forward<TFn>(fn));
}
};
class IsPeakChecker : public BaseChecker
{
IsPeakChecker();
public:
static IsPeakChecker const & Instance();
};
class IsATMChecker : public BaseChecker
{
IsATMChecker();
public:
static IsATMChecker const & Instance();
};
class IsSpeedCamChecker : public BaseChecker
{
IsSpeedCamChecker();
public:
static IsSpeedCamChecker const & Instance();
};
class IsFuelStationChecker : public BaseChecker
{
IsFuelStationChecker();
public:
static IsFuelStationChecker const & Instance();
};
class IsRailwayStationChecker : public BaseChecker
{
IsRailwayStationChecker();
public:
static IsRailwayStationChecker const & Instance();
};
class IsStreetChecker : public BaseChecker
{
IsStreetChecker();
public:
static IsStreetChecker const & Instance();
};
class IsAddressObjectChecker : public BaseChecker
{
IsAddressObjectChecker();
public:
static IsAddressObjectChecker const & Instance();
};
class IsVillageChecker : public BaseChecker
{
IsVillageChecker();
public:
static IsVillageChecker const & Instance();
};
class IsOneWayChecker : public BaseChecker
{
IsOneWayChecker();
public:
static IsOneWayChecker const & Instance();
};
class IsRoundAboutChecker : public BaseChecker
{
IsRoundAboutChecker();
public:
static IsRoundAboutChecker const & Instance();
};
class IsLinkChecker : public BaseChecker
{
IsLinkChecker();
public:
static IsLinkChecker const & Instance();
};
class IsBuildingChecker : public BaseChecker
{
IsBuildingChecker();
public:
static IsBuildingChecker const & Instance();
uint32_t GetMainType() const { return m_types[0]; }
};
class IsBridgeChecker : public BaseChecker
{
virtual bool IsMatched(uint32_t type) const override;
IsBridgeChecker();
public:
static IsBridgeChecker const & Instance();
};
class IsTunnelChecker : public BaseChecker
{
virtual bool IsMatched(uint32_t type) const override;
IsTunnelChecker();
public:
static IsTunnelChecker const & Instance();
};
class IsBookingChecker : public BaseChecker
{
IsBookingChecker();
public:
static IsBookingChecker const & Instance();
};
class IsHotelChecker : public BaseChecker
{
public:
enum class Type
{
Hotel,
Apartment,
CampSite,
Chalet,
GuestHouse,
Hostel,
Motel,
Resort,
Count
};
static_assert(static_cast<size_t>(Type::Count) <= CHAR_BIT * sizeof(unsigned),
"Too many types of hotels");
static IsHotelChecker const & Instance();
static char const * GetHotelTypeTag(Type type);
unsigned GetHotelTypesMask(FeatureType const & ft) const;
private:
IsHotelChecker();
array<pair<uint32_t, Type>, static_cast<size_t>(Type::Count)> m_sortedTypes;
};
// WiFi is a type in classificator.txt,
// it should be checked for filling metadata in MapObject.
class IsWifiChecker : public BaseChecker
{
IsWifiChecker();
public:
static IsWifiChecker const & Instance();
};
class IsFoodChecker : public BaseChecker
{
IsFoodChecker();
public:
static IsFoodChecker const & Instance();
};
class IsOpentableChecker : public BaseChecker
{
IsOpentableChecker();
public:
static IsOpentableChecker const & Instance();
};
// Checks for types that are not drawable, but searchable.
class IsInvisibleIndexedChecker : public BaseChecker
{
IsInvisibleIndexedChecker();
public:
static IsInvisibleIndexedChecker const & Instance();
};
/// Type of locality (do not change values and order - they have detalization order)
/// COUNTRY < STATE < CITY < ...
enum Type { NONE = -1, COUNTRY = 0, STATE, CITY, TOWN, VILLAGE, LOCALITY_COUNT };
class IsLocalityChecker : public BaseChecker
{
IsLocalityChecker();
public:
Type GetType(uint32_t t) const;
Type GetType(feature::TypesHolder const & types) const;
Type GetType(FeatureType const & f) const;
static IsLocalityChecker const & Instance();
};
/// @name Get city radius and population.
/// @param r Radius in meters.
//@{
uint64_t GetPopulation(FeatureType const & ft);
double GetRadiusByPopulation(uint64_t p);
uint64_t GetPopulationByRadius(double r);
//@}
/// Check if type conforms the path. Strings in the path can be
/// feature types like "highway", "living_street", "bridge" and so on
/// or *. * means any class.
/// The root name ("world") is ignored
bool IsTypeConformed(uint32_t type, StringIL const & path);
// Highway class. The order is important.
// The enum values follow from the biggest roads (Trunk) to the smallest ones (Service).
enum class HighwayClass
{
Undefined = 0, // There has not been any attempt of calculating HighwayClass.
Error, // There was an attempt of calculating HighwayClass but it was not successful.
Trunk,
Primary,
Secondary,
Tertiary,
LivingStreet,
Service,
Pedestrian,
Count // This value is used for internals only.
};
string DebugPrint(HighwayClass const cls);
HighwayClass GetHighwayClass(feature::TypesHolder const & types);
} // namespace ftypes
|