blob: c461fa1fb35b431bfd40d99f7a89d592a0b89e5c (
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
|
#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
{
pair<int, int> ret(0, scales::GetUpperScale());
int const bound = scales::GetUpperWorldScale();
if (m_scales.front() > bound)
ret.first = bound+1;
if (m_scales.back() <= bound)
ret.second = bound;
return ret;
}
void DataHeader::Save(FileWriter & w) const
{
m_codingParams.Save(w);
//int64_t const base = m_codingParams.GetBasePointInt64();
//WriteVarInt(w, m_bounds.first - base);
//WriteVarInt(w, m_bounds.second - base);
WriteToSink(w, m_bounds.first);
WriteToSink(w, m_bounds.second);
w.Write(m_scales.data(), m_scales.size());
}
void DataHeader::Load(ModelReaderPtr const & r)
{
ReaderSource<ModelReaderPtr> src(r);
m_codingParams.Load(src);
//int64_t const base = m_codingParams.GetBasePointInt64();
//m_bounds.first = ReadVarInt<int64_t>(src) + base;
//m_bounds.second = ReadVarInt<int64_t>(src) + base;
m_bounds.first = ReadPrimitiveFromSource<int64_t>(src);
m_bounds.second = ReadPrimitiveFromSource<int64_t>(src);
src.Read(m_scales.data(), m_scales.size());
}
}
|