diff options
author | vng <viktor.govako@gmail.com> | 2011-03-14 11:10:19 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:13:34 +0300 |
commit | 221d3d99da351bddd4c82f9fc553737eb458025f (patch) | |
tree | c45c9981941fec357f910fd7dae65d0ec484f1fd /indexer/data_header.cpp | |
parent | 25ea1267b48898b89681b93a5f371232fc79b711 (diff) |
Refactoring of feature::DataHeader.
Added base point and scales array to header.
World and country generation now have different scale ranges.
Diffstat (limited to 'indexer/data_header.cpp')
-rw-r--r-- | indexer/data_header.cpp | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/indexer/data_header.cpp b/indexer/data_header.cpp index 4b3805b2c7..184e7ce5d3 100644 --- a/indexer/data_header.cpp +++ b/indexer/data_header.cpp @@ -1,47 +1,61 @@ #include "data_header.hpp" -#include "../base/string_utils.hpp" - -#include "../platform/platform.hpp" +#include "../indexer/point_to_int64.hpp" +#include "../coding/file_reader.hpp" #include "../coding/file_writer.hpp" - -#include "../indexer/cell_id.hpp" +#include "../coding/write_to_sink.hpp" +#include "../coding/varint.hpp" #include "../base/start_mem_debug.hpp" + namespace feature { - DataHeader::DataHeader() { Reset(); } - namespace + void DataHeader::Reset() { - struct do_reset - { - void operator() (string & t, int) { t.clear(); } - void operator() (uint64_t & t, int) { t = 0; } - void operator() (pair<int64_t, int64_t> &, int) {} - }; } - void DataHeader::Reset() + void DataHeader::SetBase(m2::PointD const & p) { - do_reset doReset; - for_each_tuple(m_params, doReset); + m_base = PointToInt64(p.x, p.y); } - m2::RectD const DataHeader::Bounds() const + m2::RectD const DataHeader::GetBounds() const { - return Int64ToRect(Get<EBoundary>()); + return Int64ToRect(m_bounds); } void DataHeader::SetBounds(m2::RectD const & r) { - Set<EBoundary>(RectToInt64(r)); + m_bounds = RectToInt64(r); + } + + void DataHeader::SetScales(int * arr) + { + for (int i = 0; i < m_scales.size(); ++i) + m_scales[i] = static_cast<uint8_t>(arr[i]); } + void DataHeader::Save(FileWriter & w) const + { + WriteToSink(w, m_base); + WriteVarInt(w, m_bounds.first - m_base); + WriteVarInt(w, m_bounds.second - m_base); + w.Write(m_scales.data(), m_scales.size()); + } + + void DataHeader::Load(FileReader const & r) + { + ReaderSource<FileReader> src(r); + m_base = ReadPrimitiveFromSource<int64_t>(src); + m_bounds.first = ReadVarInt<int64_t>(src) + m_base; + m_bounds.second = ReadVarInt<int64_t>(src) + m_base; + src.Read(m_scales.data(), m_scales.size()); + } } |