diff --git a/generator/generator_tests/transit_test.cpp b/generator/generator_tests/transit_test.cpp index a54c3ea461..51f2039315 100644 --- a/generator/generator_tests/transit_test.cpp +++ b/generator/generator_tests/transit_test.cpp @@ -219,6 +219,7 @@ UNIT_TEST(DeserializerFromJson_Lines) "lines": [ { "id": 19207936, + "interval": 150, "network_id": 2, "number": "1", "stop_ids": [ @@ -234,6 +235,7 @@ UNIT_TEST(DeserializerFromJson_Lines) }, { "id": 19207937, + "interval": 150, "network_id": 2, "number": "2", "stop_ids": [ @@ -253,11 +255,12 @@ UNIT_TEST(DeserializerFromJson_Lines) vector const expected = {Line(19207936 /* line id */, "1" /* number */, "Московская линия" /* title */, "subway" /* type */, "green" /* color */, 2 /* network id */, - {{343262691, 343259523, 343252898, 209191847, 2947858576}} /* stop ids */), + {{343262691, 343259523, 343252898, 209191847, 2947858576}} /* stop ids */, + 150.0 /* interval */), Line(19207937 /* line id */, "2" /* number */, "Московская линия" /* title */, "subway" /* type */, "red" /* color */, 2 /* network id */, {{246659391, 246659390, 209191855, 209191854, 209191853, - 209191852, 209191851}} /* stop ids */)}; + 209191852, 209191851}} /* stop ids */, 150.0 /* interval */)}; TestDeserializerFromJson(jsonBuffer, "lines", expected); } diff --git a/routing_common/routing_common_tests/transit_test.cpp b/routing_common/routing_common_tests/transit_test.cpp index a4830ac098..9a6cc53423 100644 --- a/routing_common/routing_common_tests/transit_test.cpp +++ b/routing_common/routing_common_tests/transit_test.cpp @@ -226,21 +226,22 @@ UNIT_TEST(Transit_LineSerialization) { { Line line(1 /* line id */, "2" /* number */, "Линия" /* title */, - "subway" /* type */, "red" /* color */, 3 /* network id */, {{1}} /* stop ids */); + "subway" /* type */, "red" /* color */, 3 /* network id */, {{1}} /* stop ids */, + 10.0 /* interval */); TestSerialization(line); TEST(line.IsValid(), (line)); } { Line line(10 /* line id */, "11" /* number */, "Линия" /* title */, "subway" /* type */, "green" /* color */, 12 /* network id */, - {{13, 14, 15}} /* stop ids */); + {{13, 14, 15}} /* stop ids */, 15.0 /* interval */); TestSerialization(line); TEST(line.IsValid(), (line)); } { Line line(100 /* line id */, "101" /* number */, "Линия" /* title */, "subway" /* type */, "blue" /* color */, 103 /* network id */, - {{1, 2, 3}, {7, 8, 9}} /* stop ids */); + {{1, 2, 3}, {7, 8, 9}} /* stop ids */, 15.0 /* interval */); TestSerialization(line); TEST(line.IsValid(), (line)); } diff --git a/routing_common/transit_types.cpp b/routing_common/transit_types.cpp index f043d89624..d31302ee7b 100644 --- a/routing_common/transit_types.cpp +++ b/routing_common/transit_types.cpp @@ -294,7 +294,7 @@ bool Transfer::IsValid() const // Line ------------------------------------------------------------------------------------------- Line::Line(LineId id, std::string const & number, std::string const & title, std::string const & type, std::string const & color, NetworkId networkId, - Ranges const & stopIds) + Ranges const & stopIds, Weight interval) : m_id(id) , m_number(number) , m_title(title) @@ -302,6 +302,7 @@ Line::Line(LineId id, std::string const & number, std::string const & title, , m_color(color) , m_networkId(networkId) , m_stopIds(stopIds) + , m_interval(interval) { } @@ -309,13 +310,13 @@ bool Line::IsEqualForTesting(Line const & line) const { return m_id == line.m_id && m_number == line.m_number && m_title == line.m_title && m_type == line.m_type && m_color == line.m_color && m_networkId == line.m_networkId && - m_stopIds == line.m_stopIds; + m_stopIds == line.m_stopIds && my::AlmostEqualAbs(m_interval, line.m_interval, kWeightEqualEpsilon); } bool Line::IsValid() const { return m_id != kInvalidLineId && m_color != kInvalidColor && m_networkId != kInvalidNetworkId && - m_stopIds.IsValid(); + m_stopIds.IsValid(), m_interval != kInvalidWeight; } // Shape ------------------------------------------------------------------------------------------ diff --git a/routing_common/transit_types.hpp b/routing_common/transit_types.hpp index 524d931acd..00506c893a 100644 --- a/routing_common/transit_types.hpp +++ b/routing_common/transit_types.hpp @@ -341,7 +341,7 @@ class Line public: Line() = default; Line(LineId id, std::string const & number, std::string const & title, std::string const & type, - std::string const & color, NetworkId networkId, Ranges const & stopIds); + std::string const & color, NetworkId networkId, Ranges const & stopIds, Weight interval); bool operator<(Line const & rhs) const { return m_id < rhs.m_id; } bool operator==(Line const & rhs) const { return m_id == rhs.m_id; } @@ -355,13 +355,14 @@ public: std::string const & GetColor() const { return m_color; } NetworkId GetNetworkId() const { return m_networkId; } Ranges const & GetStopIds() const { return m_stopIds.GetIds(); } + Weight GetInterval() const { return m_interval; } private: DECLARE_TRANSIT_TYPE_FRIENDS DECLARE_VISITOR_AND_DEBUG_PRINT(Line, visitor(m_id, "id"), visitor(m_number, "number"), visitor(m_title, "title"), visitor(m_type, "type"), visitor(m_color, "color"), visitor(m_networkId, "network_id"), - visitor(m_stopIds, "stop_ids")) + visitor(m_stopIds, "stop_ids"), visitor(m_interval, "interval")) LineId m_id = kInvalidLineId; std::string m_number; @@ -370,6 +371,7 @@ private: std::string m_color = kInvalidColor; NetworkId m_networkId = kInvalidNetworkId; StopIdRanges m_stopIds; + Weight m_interval = kInvalidWeight; }; class Shape