From 0dc0baa25593b462517e0a8e603154dcd917cdc5 Mon Sep 17 00:00:00 2001 From: Maxim Pimenov Date: Mon, 9 Apr 2018 20:40:11 +0300 Subject: [coding] [geometry] Refactored geometry serialization. This commit moves all the code related to geometry serialization from indexer/ and coding/ to a single place, namely coding/geometry_coding.{c,h}pp. --- storage/country_info_getter.cpp | 9 ++++----- storage/country_polygon.hpp | 38 +++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 24 deletions(-) (limited to 'storage') diff --git a/storage/country_info_getter.cpp b/storage/country_info_getter.cpp index 665cbe113d..2dadcf3149 100644 --- a/storage/country_info_getter.cpp +++ b/storage/country_info_getter.cpp @@ -1,17 +1,16 @@ -#include "storage/country.hpp" #include "storage/country_info_getter.hpp" + +#include "storage/country.hpp" #include "storage/country_polygon.hpp" #include "platform/local_country_file_utils.hpp" -#include "indexer/geometry_serialization.hpp" +#include "coding/read_write_utils.hpp" #include "geometry/latlon.hpp" #include "geometry/mercator.hpp" #include "geometry/region2d.hpp" -#include "coding/read_write_utils.hpp" - #include "base/logging.hpp" #include "base/string_utils.hpp" @@ -283,7 +282,7 @@ std::result_of_t)> CountryInfoReader::WithRegion(size_t for (size_t i = 0; i < count; ++i) { std::vector points; - serial::LoadOuterPath(src, serial::CodingParams(), points); + serial::LoadOuterPath(src, serial::GeometryCodingParams(), points); rgns.emplace_back(move(points)); } } diff --git a/storage/country_polygon.hpp b/storage/country_polygon.hpp index 9b7cf2b34e..70f1ad0d0c 100644 --- a/storage/country_polygon.hpp +++ b/storage/country_polygon.hpp @@ -2,31 +2,31 @@ #include "storage/country_decl.hpp" -#include "indexer/coding_params.hpp" - +#include "coding/geometry_coding.hpp" #include "coding/point_to_integer.hpp" #include "coding/read_write_utils.hpp" - +#include "coding/varint.hpp" namespace storage { - template void Read(TSource & src, CountryDef & p) - { - rw::Read(src, p.m_countryId); +template void Read(TSource & src, CountryDef & p) +{ + rw::Read(src, p.m_countryId); - pair r; - r.first = ReadVarInt(src); - r.second = ReadVarInt(src); - p.m_rect = Int64ToRectObsolete(r, serial::CodingParams().GetCoordBits()); - } + pair r; + r.first = ReadVarInt(src); + r.second = ReadVarInt(src); + p.m_rect = Int64ToRectObsolete(r, serial::GeometryCodingParams().GetCoordBits()); +} + +template void Write(TSink & sink, CountryDef const & p) +{ + rw::Write(sink, p.m_countryId); - template void Write(TSink & sink, CountryDef const & p) - { - rw::Write(sink, p.m_countryId); + pair const r = + RectToInt64Obsolete(p.m_rect, serial::GeometryCodingParams().GetCoordBits()); - pair const r = - RectToInt64Obsolete(p.m_rect, serial::CodingParams().GetCoordBits()); - WriteVarInt(sink, r.first); - WriteVarInt(sink, r.second); - } + WriteVarInt(sink, r.first); + WriteVarInt(sink, r.second); } +} // namespace storage -- cgit v1.2.3