forked from organicmaps/organicmaps-tmp
GraphData modifications to implement whole serdes transit section test.
This commit is contained in:
parent
be9ea801a0
commit
f6a05f4676
2 changed files with 51 additions and 7 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "coding/file_container.hpp"
|
||||
#include "coding/file_name_utils.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
|
||||
#include "platform/country_file.hpp"
|
||||
#include "platform/local_country_file.hpp"
|
||||
|
@ -208,7 +209,7 @@ namespace routing
|
|||
namespace transit
|
||||
{
|
||||
// DeserializerFromJson ---------------------------------------------------------------------------
|
||||
DeserializerFromJson::DeserializerFromJson(json_struct_t* node,
|
||||
DeserializerFromJson::DeserializerFromJson(json_struct_t * node,
|
||||
OsmIdToFeatureIdsMap const & osmIdToFeatureIds)
|
||||
: m_node(node), m_osmIdToFeatureIds(osmIdToFeatureIds)
|
||||
{
|
||||
|
@ -274,13 +275,13 @@ void GraphData::DeserializeFromJson(my::Json const & root, OsmIdToFeatureIdsMap
|
|||
Visit(deserializer);
|
||||
}
|
||||
|
||||
void GraphData::SerializeToMwm(FileWriter & writer) const
|
||||
void GraphData::SerializeToMwm(Writer & writer) const
|
||||
{
|
||||
TransitHeader header;
|
||||
|
||||
auto const startOffset = writer.Pos();
|
||||
Serializer<FileWriter> serializer(writer);
|
||||
FixedSizeSerializer<FileWriter> numberSerializer(writer);
|
||||
Serializer<Writer> serializer(writer);
|
||||
FixedSizeSerializer<Writer> numberSerializer(writer);
|
||||
numberSerializer(header);
|
||||
header.m_stopsOffset = base::checked_cast<uint32_t>(writer.Pos() - startOffset);
|
||||
|
||||
|
@ -315,6 +316,47 @@ void GraphData::SerializeToMwm(FileWriter & writer) const
|
|||
LOG(LINFO, (TRANSIT_FILE_TAG, "section is ready. Header:", header));
|
||||
}
|
||||
|
||||
void GraphData::DeserializeForTesting(MemReader & reader)
|
||||
{
|
||||
ReaderSource<MemReader> src(reader);
|
||||
transit::Deserializer<ReaderSource<MemReader>> deserializer(src);
|
||||
transit::FixedSizeDeserializer<ReaderSource<MemReader>> numberDeserializer(src);
|
||||
|
||||
transit::TransitHeader header;
|
||||
numberDeserializer(header);
|
||||
CHECK(header.IsValid(), ());
|
||||
|
||||
CHECK_EQUAL(src.Pos(), header.m_stopsOffset, ("Wrong", TRANSIT_FILE_TAG, "section format."));
|
||||
deserializer(m_stops);
|
||||
CHECK(transit::IsValid(m_stops), ());
|
||||
|
||||
CHECK_EQUAL(src.Pos(), header.m_gatesOffset, ("Wrong", TRANSIT_FILE_TAG, "section format."));
|
||||
deserializer(m_gates);
|
||||
CHECK(transit::IsValid(m_gates), ());
|
||||
|
||||
CHECK_EQUAL(src.Pos(), header.m_edgesOffset, ("Wrong", TRANSIT_FILE_TAG, "section format."));
|
||||
deserializer(m_edges);
|
||||
CHECK(transit::IsValid(m_edges), ());
|
||||
|
||||
CHECK_EQUAL(src.Pos(), header.m_transfersOffset, ("Wrong", TRANSIT_FILE_TAG, "section format."));
|
||||
deserializer(m_transfers);
|
||||
CHECK(transit::IsValid(m_transfers), ());
|
||||
|
||||
CHECK_EQUAL(src.Pos(), header.m_linesOffset, ("Wrong", TRANSIT_FILE_TAG, "section format."));
|
||||
deserializer(m_lines);
|
||||
CHECK(transit::IsValid(m_lines), ());
|
||||
|
||||
CHECK_EQUAL(src.Pos(), header.m_shapesOffset, ("Wrong", TRANSIT_FILE_TAG, "section format."));
|
||||
deserializer(m_shapes);
|
||||
CHECK(transit::IsValid(m_shapes), ());
|
||||
|
||||
CHECK_EQUAL(src.Pos(), header.m_networksOffset, ("Wrong", TRANSIT_FILE_TAG, "section format."));
|
||||
deserializer(m_networks);
|
||||
CHECK(transit::IsValid(m_networks), ());
|
||||
|
||||
CHECK_EQUAL(src.Pos(), header.m_endOffset, ("Wrong", TRANSIT_FILE_TAG, "section format."));
|
||||
}
|
||||
|
||||
void GraphData::AppendTo(GraphData const & rhs)
|
||||
{
|
||||
::Append(rhs.m_stops, m_stops);
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
#include "geometry/point2d.hpp"
|
||||
#include "geometry/region2d.hpp"
|
||||
|
||||
#include "coding/file_writer.hpp"
|
||||
#include "coding/reader.hpp"
|
||||
#include "coding/writer.hpp"
|
||||
|
||||
#include "base/macros.hpp"
|
||||
#include "base/osm_id.hpp"
|
||||
|
@ -30,7 +31,7 @@ using OsmIdToFeatureIdsMap = std::map<osm::Id, std::vector<FeatureId>>;
|
|||
class DeserializerFromJson
|
||||
{
|
||||
public:
|
||||
DeserializerFromJson(json_struct_t* node, OsmIdToFeatureIdsMap const & osmIdToFeatureIds);
|
||||
DeserializerFromJson(json_struct_t * node, OsmIdToFeatureIdsMap const & osmIdToFeatureIds);
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<std::is_integral<T>::value || std::is_enum<T>::value ||
|
||||
|
@ -126,7 +127,8 @@ class GraphData
|
|||
{
|
||||
public:
|
||||
void DeserializeFromJson(my::Json const & root, OsmIdToFeatureIdsMap const & mapping);
|
||||
void SerializeToMwm(FileWriter & writer) const;
|
||||
void SerializeToMwm(Writer & writer) const;
|
||||
void DeserializeForTesting(MemReader & reader);
|
||||
void AppendTo(GraphData const & rhs);
|
||||
void Clear();
|
||||
bool IsValid() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue