-
-
Notifications
You must be signed in to change notification settings - Fork 991
/
data_header.hpp
86 lines (63 loc) · 2.14 KB
/
data_header.hpp
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
#pragma once
#include "coding/geometry_coding.hpp"
#include "geometry/rect2d.hpp"
#include "base/assert.hpp"
#include "base/buffer_vector.hpp"
#include <string>
#include <utility>
class FilesContainerR;
class FileWriter;
class ModelReaderPtr;
namespace feature
{
class DataHeader
{
public:
/// @note An order is important here, @see Load function.
enum class MapType : uint8_t
{
World,
WorldCoasts,
Country
};
/// Max possible geometry scales. @see arrays in feature_impl.hpp
static constexpr size_t kMaxScalesCount = 4;
DataHeader() = default;
explicit DataHeader(std::string const & fileName);
explicit DataHeader(FilesContainerR const & cont);
inline void SetGeometryCodingParams(serial::GeometryCodingParams const & cp)
{
m_codingParams = cp;
}
inline serial::GeometryCodingParams const & GetDefGeometryCodingParams() const
{
return m_codingParams;
}
serial::GeometryCodingParams GetGeometryCodingParams(int scaleIndex) const;
m2::RectD GetBounds() const;
void SetBounds(m2::RectD const & r);
template <size_t N>
void SetScales(int const (&arr)[N])
{
m_scales.assign(arr, arr + N);
}
size_t GetScalesCount() const { return m_scales.size(); }
int GetScale(size_t i) const { return static_cast<int>(m_scales[i]); }
int GetLastScale() const { return m_scales.back(); }
std::pair<int, int> GetScaleRange() const;
void Save(FileWriter & w) const;
void Load(FilesContainerR const & cont);
void SetType(MapType t) { m_type = t; }
MapType GetType() const { return m_type; }
private:
void Load(ModelReaderPtr const & r);
MapType m_type = MapType::World;
serial::GeometryCodingParams m_codingParams;
// Rect around region border. Features which cross region border may cross this rect.
std::pair<int64_t, int64_t> m_bounds;
buffer_vector<uint8_t, kMaxScalesCount> m_scales;
// Is not used now (see data/countries_meta.txt). Can be reused for something else.
buffer_vector<uint8_t, 2> m_langs;
};
std::string DebugPrint(DataHeader::MapType type);
} // namespace feature