diff --git a/generator/transit_generator.cpp b/generator/transit_generator.cpp index ac79195a59..61a501ab1a 100644 --- a/generator/transit_generator.cpp +++ b/generator/transit_generator.cpp @@ -49,7 +49,6 @@ void SerializeObject(my::Json const & root, string const & key, Serializer const & vs, char const * /* name */ = nullptr) + { + CHECK_LESS_OR_EQUAL(vs.size(), std::numeric_limits::max(), ()); + WriteVarUint(m_sink, static_cast(vs.size())); + m2::PointU lastEncodedPoint; + for (auto const & p : vs) + { + m2::PointU const pointU = PointD2PointU(p, POINT_COORD_BITS); + WriteVarUint(m_sink, EncodeDelta(pointU, lastEncodedPoint)); + lastEncodedPoint = pointU; + } } template @@ -81,12 +92,8 @@ public: t.Visit(*this); } - /// \note This method should be called beforw serializing every table. - void ResetCache() { m_lastEncodedPoint = m2::PointD(); } - private: Sink & m_sink; - m2::PointU m_lastEncodedPoint; }; template @@ -116,9 +123,20 @@ public: void operator()(m2::PointD & p, char const * /* name */ = nullptr) { - m2::PointU pointU = DecodeDelta(ReadVarUint(m_source), m_lastDecodedPoint); - p = PointU2PointD(pointU, POINT_COORD_BITS); - m_lastDecodedPoint = pointU; + p = Int64ToPoint(ReadVarInt(m_source), POINT_COORD_BITS); + } + + void operator()(vector & vs, char const * /* name */ = nullptr) + { + auto const size = ReadVarUint(m_source); + m2::PointU lastDecodedPoint; + vs.resize(size); + for (auto & p : vs) + { + m2::PointU const pointU = DecodeDelta(ReadVarUint(m_source), lastDecodedPoint); + p = PointU2PointD(pointU, POINT_COORD_BITS); + lastDecodedPoint = pointU; + } } template @@ -136,12 +154,8 @@ public: t.Visit(*this); } - /// \note This method should be called beforw deserializing every table. - void ResetCache() { m_lastDecodedPoint = m2::PointD(); } - private: Source & m_source; - m2::PointU m_lastDecodedPoint; }; } // namespace transit } // namespace routing diff --git a/routing_common/transit_types.hpp b/routing_common/transit_types.hpp index c71279bd23..fda2833665 100644 --- a/routing_common/transit_types.hpp +++ b/routing_common/transit_types.hpp @@ -95,7 +95,13 @@ public: 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| should be filled after "gates" are deserialized from json + // to vector of Gate but before serialization to mwm. + std::vector m_pedestrianFeatureIds; bool m_entrance = true; bool m_exit = true; double m_weight = kInvalidWeight;