mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 21:13:35 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
#include "platform/mwm_version.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
|
||||
#include "coding/files_container.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/files_container.hpp"
|
||||
#include "coding/point_coding.hpp"
|
||||
#include "coding/varint.hpp"
|
||||
|
||||
@@ -41,98 +41,96 @@ void LoadBytes(Source & src, Cont & cont)
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DataHeader::DataHeader(std::string const & fileName)
|
||||
: DataHeader((FilesContainerR(GetPlatform().GetReader(fileName))))
|
||||
DataHeader::DataHeader(std::string const & fileName) : DataHeader((FilesContainerR(GetPlatform().GetReader(fileName))))
|
||||
{}
|
||||
|
||||
DataHeader::DataHeader(FilesContainerR const & cont)
|
||||
{
|
||||
Load(cont);
|
||||
}
|
||||
|
||||
serial::GeometryCodingParams DataHeader::GetGeometryCodingParams(int scaleIndex) const
|
||||
{
|
||||
return {static_cast<uint8_t>(m_codingParams.GetCoordBits() - (m_scales.back() - m_scales[scaleIndex]) / 2),
|
||||
m_codingParams.GetBasePointUint64()};
|
||||
}
|
||||
|
||||
m2::RectD DataHeader::GetBounds() const
|
||||
{
|
||||
return Int64ToRectObsolete(m_bounds, m_codingParams.GetCoordBits());
|
||||
}
|
||||
|
||||
void DataHeader::SetBounds(m2::RectD const & r)
|
||||
{
|
||||
m_bounds = RectToInt64Obsolete(r, m_codingParams.GetCoordBits());
|
||||
}
|
||||
|
||||
std::pair<int, int> DataHeader::GetScaleRange() const
|
||||
{
|
||||
using namespace scales;
|
||||
|
||||
int const low = 0;
|
||||
int const high = GetUpperScale();
|
||||
int const worldH = GetUpperWorldScale();
|
||||
MapType const type = GetType();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case MapType::World: return {low, worldH};
|
||||
case MapType::WorldCoasts: return {low, high};
|
||||
default:
|
||||
ASSERT_EQUAL(type, MapType::Country, ());
|
||||
return {worldH + 1, high};
|
||||
|
||||
// Uncomment this to test countries drawing in all scales.
|
||||
// return {1, high};
|
||||
}
|
||||
}
|
||||
|
||||
void DataHeader::Save(FileWriter & w) const
|
||||
{
|
||||
m_codingParams.Save(w);
|
||||
|
||||
WriteVarInt(w, m_bounds.first);
|
||||
WriteVarInt(w, m_bounds.second);
|
||||
|
||||
SaveBytes(w, m_scales);
|
||||
SaveBytes(w, m_langs);
|
||||
|
||||
WriteVarInt(w, static_cast<int32_t>(m_type));
|
||||
}
|
||||
|
||||
void DataHeader::Load(FilesContainerR const & cont)
|
||||
{
|
||||
Load(cont.GetReader(HEADER_FILE_TAG));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
LoadBytes(src, m_scales);
|
||||
LoadBytes(src, m_langs);
|
||||
|
||||
m_type = static_cast<MapType>(ReadVarInt<int32_t>(src));
|
||||
|
||||
if (m_type < MapType::World || m_type > MapType::Country || m_scales.size() != kMaxScalesCount)
|
||||
MYTHROW(CorruptedMwmFile, (r.GetName()));
|
||||
}
|
||||
|
||||
std::string DebugPrint(DataHeader::MapType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DataHeader::MapType::World: return "World";
|
||||
case DataHeader::MapType::WorldCoasts: return "WorldCoasts";
|
||||
case DataHeader::MapType::Country: return "Country";
|
||||
}
|
||||
|
||||
DataHeader::DataHeader(FilesContainerR const & cont)
|
||||
{
|
||||
Load(cont);
|
||||
}
|
||||
|
||||
serial::GeometryCodingParams DataHeader::GetGeometryCodingParams(int scaleIndex) const
|
||||
{
|
||||
return { static_cast<uint8_t>(m_codingParams.GetCoordBits() - (m_scales.back() - m_scales[scaleIndex]) / 2),
|
||||
m_codingParams.GetBasePointUint64()};
|
||||
}
|
||||
|
||||
m2::RectD DataHeader::GetBounds() const
|
||||
{
|
||||
return Int64ToRectObsolete(m_bounds, m_codingParams.GetCoordBits());
|
||||
}
|
||||
|
||||
void DataHeader::SetBounds(m2::RectD const & r)
|
||||
{
|
||||
m_bounds = RectToInt64Obsolete(r, m_codingParams.GetCoordBits());
|
||||
}
|
||||
|
||||
std::pair<int, int> DataHeader::GetScaleRange() const
|
||||
{
|
||||
using namespace scales;
|
||||
|
||||
int const low = 0;
|
||||
int const high = GetUpperScale();
|
||||
int const worldH = GetUpperWorldScale();
|
||||
MapType const type = GetType();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case MapType::World: return {low, worldH};
|
||||
case MapType::WorldCoasts: return {low, high};
|
||||
default:
|
||||
ASSERT_EQUAL(type, MapType::Country, ());
|
||||
return {worldH + 1, high};
|
||||
|
||||
// Uncomment this to test countries drawing in all scales.
|
||||
//return {1, high};
|
||||
}
|
||||
}
|
||||
|
||||
void DataHeader::Save(FileWriter & w) const
|
||||
{
|
||||
m_codingParams.Save(w);
|
||||
|
||||
WriteVarInt(w, m_bounds.first);
|
||||
WriteVarInt(w, m_bounds.second);
|
||||
|
||||
SaveBytes(w, m_scales);
|
||||
SaveBytes(w, m_langs);
|
||||
|
||||
WriteVarInt(w, static_cast<int32_t>(m_type));
|
||||
}
|
||||
|
||||
void DataHeader::Load(FilesContainerR const & cont)
|
||||
{
|
||||
Load(cont.GetReader(HEADER_FILE_TAG));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
LoadBytes(src, m_scales);
|
||||
LoadBytes(src, m_langs);
|
||||
|
||||
m_type = static_cast<MapType>(ReadVarInt<int32_t>(src));
|
||||
|
||||
if (m_type < MapType::World || m_type > MapType::Country || m_scales.size() != kMaxScalesCount)
|
||||
MYTHROW(CorruptedMwmFile, (r.GetName()));
|
||||
}
|
||||
|
||||
std::string DebugPrint(DataHeader::MapType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DataHeader::MapType::World: return "World";
|
||||
case DataHeader::MapType::WorldCoasts: return "WorldCoasts";
|
||||
case DataHeader::MapType::Country: return "Country";
|
||||
}
|
||||
|
||||
UNREACHABLE();
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
} // namespace feature
|
||||
|
||||
Reference in New Issue
Block a user