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
|
#pragma once
#include "search/doc_vec.hpp"
#include "search/model.hpp"
#include "search/token_range.hpp"
#include "indexer/mwm_set.hpp"
#include "storage/country_info_getter.hpp"
#include "geometry/point2d.hpp"
#include "geometry/rect2d.hpp"
#include <cstdint>
#include <string>
namespace search
{
class IdfMap;
struct Locality
{
Locality(MwmSet::MwmId const & countryId, uint32_t featureId, TokenRange const & tokenRange,
QueryVec const & queryVec, bool exactMatch)
: m_countryId(countryId)
, m_featureId(featureId)
, m_tokenRange(tokenRange)
, m_queryVec(queryVec)
, m_exactMatch(exactMatch)
{
}
double QueryNorm() { return m_queryVec.Norm(); }
MwmSet::MwmId m_countryId;
uint32_t m_featureId = 0;
TokenRange m_tokenRange;
QueryVec m_queryVec;
bool m_exactMatch;
};
// This struct represents a country or US- or Canadian- state. It
// is used to filter maps before search.
struct Region : public Locality
{
enum Type
{
TYPE_STATE,
TYPE_COUNTRY,
TYPE_COUNT
};
Region(Locality const & locality, Type type) : Locality(locality), m_center(0, 0), m_type(type) {}
static Model::Type ToModelType(Type type);
storage::CountryInfoGetter::RegionIdVec m_ids;
std::string m_defaultName;
m2::PointD m_center;
Type m_type;
};
// This struct represents a city or a village. It is used to filter features
// during search.
// todo(@m) It works well as is, but consider a new naming scheme
// when counties etc. are added. E.g., Region for countries and
// states and Locality for smaller settlements.
struct City : public Locality
{
City(Locality const & locality, Model::Type type) : Locality(locality), m_type(type)
{
}
m2::RectD m_rect;
Model::Type m_type;
#if defined(DEBUG)
std::string m_defaultName;
#endif
};
std::string DebugPrint(Locality const & locality);
} // namespace search
|