From 78a7ff92f3cd45497ff2f0c7060b07274a9259a7 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 9 Oct 2017 15:54:28 +0300 Subject: [PATCH] Special handling for pedestrian feature ids. --- generator/transit_generator.cpp | 14 +++++++++++++- routing_common/transit_types.hpp | 12 ++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/generator/transit_generator.cpp b/generator/transit_generator.cpp index 61a501ab1a..20ad5c5fd7 100644 --- a/generator/transit_generator.cpp +++ b/generator/transit_generator.cpp @@ -15,6 +15,8 @@ #include "base/logging.hpp" #include "base/macros.hpp" +#include + #include "3party/jansson/src/jansson.h" using namespace platform; @@ -43,12 +45,17 @@ string GetFileName(string const & filePath) /// \brief Reads from |root| (json) and serializes an array to |serializer|. template -void SerializeObject(my::Json const & root, string const & key, Serializer & serializer) +void SerializeObject(my::Json const & root, string const & key, Serializer & serializer, + function &)> handler = nullptr) { vector items; DeserializerFromJson deserializer(root.get()); deserializer(items, key.c_str()); + + if (handler) + handler(items); + serializer(items); } } // namespace @@ -125,6 +132,11 @@ void BuildTransit(string const & mwmPath, string const & transitDir) SerializeObject(root, "stops", serializer); header.m_gatesOffset = base::checked_cast(w.Pos() - startOffset); + auto const fillPedestrianFeatureIds = [](function &)> & handler) + { + // @TODO(bykoianko) |m_pedestrianFeatureIds| is not filled from json but should be calculated based on |m_point|. + }; + UNUSED_VALUE(fillPedestrianFeatureIds); SerializeObject(root, "gates", serializer); header.m_edgesOffset = base::checked_cast(w.Pos() - startOffset); diff --git a/routing_common/transit_types.hpp b/routing_common/transit_types.hpp index 8ec2d5a2db..fcfd596784 100644 --- a/routing_common/transit_types.hpp +++ b/routing_common/transit_types.hpp @@ -104,20 +104,16 @@ public: m2::PointD const & GetPoint() const { return m_point; } DECLARE_VISITOR_AND_DEBUG_PRINT(Gate, visitor(m_featureId, "osm_id"), - visitor(m_entrance, "entrance"), - visitor(m_exit, "exit"), visitor(m_weight, "weight"), - visitor(m_stopIds, "stop_ids"), visitor(m_point, "point")) + visitor(m_pedestrianFeatureIds, "" /* name */), + visitor(m_entrance, "entrance"), visitor(m_exit, "exit"), + visitor(m_weight, "weight"), visitor(m_stopIds, "stop_ids"), + visitor(m_point, "point")) private: // |m_featureId| is feature id of a point feature which represents gates. FeatureId m_featureId = kInvalidFeatureId; // |m_pedestrianFeatureIds| is linear feature ids which can be used for pedestrian routing // to leave (to enter) the gate. - // @TODO(bykoianko) |m_pedestrianFeatureIds| is not filled from json but should be calculated based on |m_point|. - // It should be filled after "gates" are deserialized from json to vector of Gate but before serialization to mwm. - // That means that it's necessary to implement two visitors. One of them without visiting |m_pedestrianFeatureIds| - // for deserialization from json. And another with visiting |m_pedestrianFeatureIds| for serialization to mwm, - // deserialization from mwm and debug print. std::vector m_pedestrianFeatureIds; bool m_entrance = true; bool m_exit = true;