diff options
author | Lev Dragunov <l.dragunov@corp.mail.ru> | 2015-10-23 16:12:06 +0300 |
---|---|---|
committer | Lev Dragunov <l.dragunov@corp.mail.ru> | 2015-10-23 16:12:06 +0300 |
commit | a6452b96c07b5e9a8c0a796d0b20fda5d4328765 (patch) | |
tree | d9248d384f4f28fe06f62ace9fc00279d9465952 /routing/cross_routing_context.hpp | |
parent | fc00ee4d41d772204ff60debc3bf5f798549e1ea (diff) |
Adjacency indexes inside cross node records.
Diffstat (limited to 'routing/cross_routing_context.hpp')
-rw-r--r-- | routing/cross_routing_context.hpp | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/routing/cross_routing_context.hpp b/routing/cross_routing_context.hpp index 87b0d5e29c..63d41944f2 100644 --- a/routing/cross_routing_context.hpp +++ b/routing/cross_routing_context.hpp @@ -11,22 +11,33 @@ namespace routing { +// TODO (ldragunov) Fix this!!!! using WritedNodeID = uint32_t; using WritedEdgeWeightT = uint32_t; static WritedEdgeWeightT const INVALID_CONTEXT_EDGE_WEIGHT = std::numeric_limits<WritedEdgeWeightT>::max(); static WritedEdgeWeightT const INVALID_CONTEXT_EDGE_NODE_ID = std::numeric_limits<uint32_t>::max(); +static size_t constexpr kInvalidAdjacencyIndex = numeric_limits<size_t>::max(); struct IngoingCrossNode { m2::PointD m_point; WritedNodeID m_nodeId; - - IngoingCrossNode() : m_point(m2::PointD::Zero()), m_nodeId(INVALID_CONTEXT_EDGE_NODE_ID) {} - IngoingCrossNode(WritedNodeID nodeId, m2::PointD const & point) :m_point(point), m_nodeId(nodeId) {} + size_t m_adjacencyIndex; + + IngoingCrossNode() + : m_point(m2::PointD::Zero()) + , m_nodeId(INVALID_CONTEXT_EDGE_NODE_ID) + , m_adjacencyIndex(kInvalidAdjacencyIndex) + { + } + IngoingCrossNode(WritedNodeID nodeId, m2::PointD const & point, size_t const adjacencyIndex) + : m_point(point), m_nodeId(nodeId), m_adjacencyIndex(adjacencyIndex) + { + } void Save(Writer & w) const; - size_t Load(Reader const & r, size_t pos); + size_t Load(Reader const & r, size_t pos, size_t adjacencyIndex); m2::RectD const GetLimitRect() const { return m2::RectD(m_point, m_point); } }; @@ -36,15 +47,27 @@ struct OutgoingCrossNode m2::PointD m_point; WritedNodeID m_nodeId; unsigned char m_outgoingIndex; - - OutgoingCrossNode() : m_point(m2::PointD::Zero()), m_nodeId(INVALID_CONTEXT_EDGE_NODE_ID), m_outgoingIndex(0) {} - OutgoingCrossNode(WritedNodeID nodeId, size_t const index, m2::PointD const & point) : m_point(point), - m_nodeId(nodeId), - m_outgoingIndex(static_cast<unsigned char>(index)){} + size_t m_adjacencyIndex; + + OutgoingCrossNode() + : m_point(m2::PointD::Zero()) + , m_nodeId(INVALID_CONTEXT_EDGE_NODE_ID) + , m_outgoingIndex(0) + , m_adjacencyIndex(kInvalidAdjacencyIndex) + { + } + OutgoingCrossNode(WritedNodeID nodeId, size_t const index, m2::PointD const & point, + size_t const adjacencyIndex) + : m_point(point) + , m_nodeId(nodeId) + , m_outgoingIndex(static_cast<unsigned char>(index)) + , m_adjacencyIndex(adjacencyIndex) + { + } void Save(Writer & w) const; - size_t Load(Reader const & r, size_t pos); + size_t Load(Reader const & r, size_t pos, size_t adjacencyIndex); }; using IngoingEdgeIteratorT = vector<IngoingCrossNode>::const_iterator; @@ -53,22 +76,22 @@ using OutgoingEdgeIteratorT = vector<OutgoingCrossNode>::const_iterator; /// Reader class from cross context section in mwm.routing file class CrossRoutingContextReader { - vector<IngoingCrossNode> m_ingoingNodes; vector<OutgoingCrossNode> m_outgoingNodes; + vector<IngoingCrossNode> m_ingoingNodes; vector<string> m_neighborMwmList; unique_ptr<Reader> mp_reader = nullptr; m4::Tree<IngoingCrossNode> m_ingoingIndex; size_t GetIndexInAdjMatrix(IngoingEdgeIteratorT ingoing, OutgoingEdgeIteratorT outgoing) const; -public: +public: void Load(Reader const & r); const string & GetOutgoingMwmName(OutgoingCrossNode const & mwmIndex) const; pair<IngoingEdgeIteratorT, IngoingEdgeIteratorT> GetIngoingIterators() const; - bool FindIngoingNodeByPoint(m2::PointD const & point, IngoingCrossNode & node) const; + bool FindIngoingNodeByPoint(m2::PointD const & point, IngoingCrossNode & node) const; pair<OutgoingEdgeIteratorT, OutgoingEdgeIteratorT> GetOutgoingIterators() const; @@ -91,7 +114,8 @@ public: void AddIngoingNode(WritedNodeID const nodeId, m2::PointD const & point); - void AddOutgoingNode(WritedNodeID const nodeId, string const & targetMwm, m2::PointD const & point); + void AddOutgoingNode(WritedNodeID const nodeId, string const & targetMwm, + m2::PointD const & point); void ReserveAdjacencyMatrix(); |