blob: 5b1c822e32ca98b3156adcc6f36052940ba34c20 (
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
|
#include "data_header.hpp"
#include "point_to_int64.hpp"
#include "scales.hpp"
#include "../defines.hpp"
#include "../coding/file_reader.hpp"
#include "../coding/file_writer.hpp"
#include "../coding/file_container.hpp"
#include "../coding/write_to_sink.hpp"
#include "../coding/varint.hpp"
#include "../base/start_mem_debug.hpp"
namespace feature
{
m2::RectD const DataHeader::GetBounds() const
{
return Int64ToRect(m_bounds, m_codingParams.GetCoordBits());
}
void DataHeader::SetBounds(m2::RectD const & r)
{
m_bounds = RectToInt64(r, m_codingParams.GetCoordBits());
}
void DataHeader::SetScales(int * arr)
{
for (size_t i = 0; i < m_scales.size(); ++i)
m_scales[i] = static_cast<uint8_t>(arr[i]);
}
pair<int, int> DataHeader::GetScaleRange() const
{
int const worldB = scales::GetUpperWorldScale();
int const countryB = scales::GetUpperScale();
if (m_scales.back() == countryB)
return make_pair(worldB + 1, countryB);
else
return make_pair(0, worldB);
}
void DataHeader::Save(FileWriter & w) const
{
m_codingParams.Save(w);
WriteVarInt(w, m_bounds.first);
WriteVarInt(w, m_bounds.second);
w.Write(m_scales.data(), m_scales.size());
WriteVarInt(w, static_cast<int32_t>(m_type));
}
void DataHeader::Load(ModelReaderPtr const & r)
{
ReaderSource<ModelReaderPtr> src(r);
m_codingParams.Load(src);
m_bounds.first = ReadVarInt<int64_t>(src);
m_bounds.second = ReadVarInt<int64_t>(src);
src.Read(m_scales.data(), m_scales.size());
m_type = static_cast<MapType>(ReadVarInt<int32_t>(src));
m_ver = v2;
}
void DataHeader::LoadVer1(ModelReaderPtr const & r)
{
ReaderSource<ModelReaderPtr> src(r);
int64_t const base = ReadPrimitiveFromSource<int64_t>(src);
m_codingParams = serial::CodingParams(POINT_COORD_BITS, base);
m_bounds.first = ReadVarInt<int64_t>(src) + base;
m_bounds.second = ReadVarInt<int64_t>(src) + base;
src.Read(m_scales.data(), m_scales.size());
m_ver = v1;
}
}
|