diff --git a/routing_common/transit_types.cpp b/routing_common/transit_types.cpp index 7eb3e9bc11..55036e83d8 100644 --- a/routing_common/transit_types.cpp +++ b/routing_common/transit_types.cpp @@ -54,18 +54,42 @@ bool TransitHeader::IsEqualForTesting(TransitHeader const & header) const && m_endOffset == header.m_endOffset; } +// TitleAnchor ------------------------------------------------------------------------------------ +TitleAnchor::TitleAnchor(uint8_t minZoom, std::string const & anchors) + : m_minZoom(minZoom), m_anchors(anchors) +{ +} + +bool TitleAnchor::operator==(TitleAnchor const & titleAnchor) const +{ + return m_minZoom == titleAnchor.m_minZoom && m_anchors == titleAnchor.m_anchors; +} + +bool TitleAnchor::IsEqualForTesting(TitleAnchor const & titleAnchor) const +{ + return *this == titleAnchor; +} + // Stop ------------------------------------------------------------------------------------------- -Stop::Stop(StopId id, FeatureId featureId, TransferId transferId, std::vector const & lineIds, - m2::PointD const & point) - : m_id(id), m_featureId(featureId), m_transferId(transferId), m_lineIds(lineIds), m_point(point) +Stop::Stop(StopId id, FeatureId featureId, TransferId transferId, + std::vector const & lineIds, m2::PointD const & point, + std::vector const & titleAnchors) + : m_id(id) + , m_featureId(featureId) + , m_transferId(transferId) + , m_lineIds(lineIds) + , m_point(point) + , m_titleAnchors(titleAnchors) { } bool Stop::IsEqualForTesting(Stop const & stop) const { double constexpr kPointsEqualEpsilon = 1e-6; - return m_id == stop.m_id && m_featureId == stop.m_featureId && m_transferId == stop.m_transferId && - m_lineIds == stop.m_lineIds && my::AlmostEqualAbs(m_point, stop.m_point, kPointsEqualEpsilon); + return m_id == stop.m_id && m_featureId == stop.m_featureId && + m_transferId == stop.m_transferId && m_lineIds == stop.m_lineIds && + my::AlmostEqualAbs(m_point, stop.m_point, kPointsEqualEpsilon) && + m_titleAnchors == stop.m_titleAnchors; } // SingleMwmSegment ------------------------------------------------------------------------------- @@ -74,6 +98,11 @@ SingleMwmSegment::SingleMwmSegment(FeatureId featureId, uint32_t segmentIdx, boo { } +bool SingleMwmSegment::IsEqualForTesting(SingleMwmSegment const & s) const +{ + return m_featureId == s.m_featureId && m_segmentIdx == s.m_segmentIdx && m_forward == s.m_forward; +} + // Gate ------------------------------------------------------------------------------------------- Gate::Gate(FeatureId featureId, bool entrance, bool exit, double weight, std::vector const & stopIds, m2::PointD const & point) @@ -127,8 +156,9 @@ bool Edge::operator<(Edge const & rhs) const bool Edge::IsEqualForTesting(Edge const & edge) const { return !(*this < edge || edge < *this); } // Transfer --------------------------------------------------------------------------------------- -Transfer::Transfer(StopId id, m2::PointD const & point, std::vector const & stopIds) - : m_id(id), m_point(point), m_stopIds(stopIds) +Transfer::Transfer(StopId id, m2::PointD const & point, std::vector const & stopIds, + std::vector const & titleAnchors) + : m_id(id), m_point(point), m_stopIds(stopIds), m_titleAnchors(titleAnchors) { } @@ -136,7 +166,8 @@ bool Transfer::IsEqualForTesting(Transfer const & transfer) const { return m_id == transfer.m_id && my::AlmostEqualAbs(m_point, transfer.m_point, kPointsEqualEpsilon) && - m_stopIds == transfer.m_stopIds; + m_stopIds == transfer.m_stopIds && + m_titleAnchors == transfer.m_titleAnchors; } // Line ------------------------------------------------------------------------------------------- diff --git a/routing_common/transit_types.hpp b/routing_common/transit_types.hpp index 18a588d5f0..d8e0c177be 100644 --- a/routing_common/transit_types.hpp +++ b/routing_common/transit_types.hpp @@ -1,5 +1,7 @@ #pragma once +#include "indexer/scales.hpp" + #include "geometry/point2d.hpp" #include "base/visitor.hpp" @@ -71,12 +73,33 @@ public: static_assert(sizeof(TransitHeader) == 32, "Wrong header size of transit section."); +class TitleAnchor +{ +public: + TitleAnchor() = default; + TitleAnchor(uint8_t minZoom, std::string const & anchors); + + bool operator==(TitleAnchor const & titleAnchor) const; + bool IsEqualForTesting(TitleAnchor const & titleAnchor) const; + + uint8_t GetMinZoom() const { return m_minZoom; } + std::string const & GetAnchors() const { return m_anchors; } + +private: + DECLARE_TRANSIT_TYPE_FRIENDS + DECLARE_VISITOR_AND_DEBUG_PRINT(TitleAnchor, visitor(m_minZoom, "min_zoom"), + visitor(m_anchors, "anchors")) + + uint8_t m_minZoom = scales::UPPER_STYLE_SCALE; + std::string m_anchors; +}; + class Stop { public: Stop() = default; Stop(StopId id, FeatureId featureId, TransferId transferId, std::vector const & lineIds, - m2::PointD const & point); + m2::PointD const & point, std::vector const & titleAnchors); bool IsEqualForTesting(Stop const & stop) const; StopId GetId() const { return m_id; } @@ -84,20 +107,21 @@ public: TransferId GetTransferId() const { return m_transferId; } std::vector const & GetLineIds() const { return m_lineIds; } m2::PointD const & GetPoint() const { return m_point; } + std::vector const & GetTitleAnchors() const { return m_titleAnchors; } private: DECLARE_TRANSIT_TYPE_FRIENDS DECLARE_VISITOR_AND_DEBUG_PRINT(Stop, visitor(m_id, "id"), visitor(m_featureId, "osm_id"), visitor(m_transferId, "transfer_id"), - visitor(m_lineIds, "line_ids"), visitor(m_point, "point")) + visitor(m_lineIds, "line_ids"), visitor(m_point, "point"), + visitor(m_titleAnchors, "title_anchors")) StopId m_id = kInvalidStopId; FeatureId m_featureId = kInvalidFeatureId; TransferId m_transferId = kInvalidTransferId; std::vector m_lineIds; m2::PointD m_point; - // @TODO(bykoianko) It's necessary to add field m_titleAnchors here and implement serialization - // and deserialization. + std::vector m_titleAnchors; }; class SingleMwmSegment @@ -105,6 +129,7 @@ class SingleMwmSegment public: SingleMwmSegment() = default; SingleMwmSegment(FeatureId featureId, uint32_t segmentIdx, bool forward); + bool IsEqualForTesting(SingleMwmSegment const & s) const ; FeatureId GetFeatureId() const { return m_featureId; } uint32_t GetSegmentIdx() const { return m_segmentIdx; } @@ -193,24 +218,25 @@ class Transfer { public: Transfer() = default; - Transfer(StopId id, m2::PointD const & point, std::vector const & stopIds); + Transfer(StopId id, m2::PointD const & point, std::vector const & stopIds, + std::vector const & titleAnchors); bool IsEqualForTesting(Transfer const & transfer) const; StopId GetId() const { return m_id; } m2::PointD const & GetPoint() const { return m_point; } std::vector const & GetStopIds() const { return m_stopIds; } + std::vector const & GetTitleAnchors() const { return m_titleAnchors; } private: DECLARE_TRANSIT_TYPE_FRIENDS DECLARE_VISITOR_AND_DEBUG_PRINT(Transfer, visitor(m_id, "id"), visitor(m_point, "point"), - visitor(m_stopIds, "stop_ids")) + visitor(m_stopIds, "stop_ids"), + visitor(m_titleAnchors, "title_anchors")) StopId m_id = kInvalidStopId; m2::PointD m_point; std::vector m_stopIds; - - // @TODO(bykoianko) It's necessary to add field m_titleAnchors here and implement serialization - // and deserialization. + std::vector m_titleAnchors; }; class Line