diff options
author | Lev Dragunov <l.dragunov@corp.mail.ru> | 2015-02-20 14:38:19 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:37:40 +0300 |
commit | d81da1422bd976ee8632b7f893f1b99876faab23 (patch) | |
tree | a6683273df5789133915c0819477579e3cbb670e /routing/cross_routing_context.hpp | |
parent | 57872f6b24c218e6b346ec73b644edd11bf3b063 (diff) |
[routing] Storing points of border crossing
Diffstat (limited to 'routing/cross_routing_context.hpp')
-rw-r--r-- | routing/cross_routing_context.hpp | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/routing/cross_routing_context.hpp b/routing/cross_routing_context.hpp index 749c571481..4e9f111b31 100644 --- a/routing/cross_routing_context.hpp +++ b/routing/cross_routing_context.hpp @@ -2,21 +2,54 @@ #include "../coding/file_container.hpp" +#include "../geometry/point2d.hpp" + #include "../std/string.hpp" #include "../std/vector.hpp" namespace routing { using WritedEdgeWeightT = uint32_t; -using IngoingEdgeIteratorT = vector<uint32_t>::const_iterator; -using OutgoingEdgeIteratorT = vector<pair<uint32_t,uint32_t>>::const_iterator; static const WritedEdgeWeightT INVALID_CONTEXT_EDGE_WEIGHT = std::numeric_limits<WritedEdgeWeightT>::max(); +static const WritedEdgeWeightT INVALID_CONTEXT_EDGE_NODE_ID = std::numeric_limits<uint32_t>::max(); + +struct IngoingCrossNode +{ + uint32_t m_nodeId; + m2::PointD m_point; + + IngoingCrossNode() : m_nodeId(INVALID_CONTEXT_EDGE_NODE_ID), m_point(m2::PointD::Zero()) {} + IngoingCrossNode(uint32_t nodeId, m2::PointD const & point) : m_nodeId(nodeId), m_point(point) {} + + void Save(Writer & w); + + size_t Load(Reader const & r, size_t pos); +}; + +struct OutgoingCrossNode +{ + uint32_t m_nodeId; + m2::PointD m_point; + unsigned char m_outgoingIndex; + + OutgoingCrossNode() : m_nodeId(INVALID_CONTEXT_EDGE_NODE_ID), m_point(m2::PointD::Zero()), m_outgoingIndex(0) {} + OutgoingCrossNode(uint32_t nodeId, size_t const index, m2::PointD const & point) : m_nodeId(nodeId), + m_point(point), + m_outgoingIndex(static_cast<unsigned char>(index)){} + + void Save(Writer & w); + + size_t Load(Reader const & r, size_t pos); +}; + +using IngoingEdgeIteratorT = vector<IngoingCrossNode>::const_iterator; +using OutgoingEdgeIteratorT = vector<OutgoingCrossNode>::const_iterator; /// Reader class from cross context section in mwm.routing file class CrossRoutingContextReader { - vector<uint32_t> m_ingoingNodes; - vector<pair<uint32_t,uint32_t> > m_outgoingNodes; + vector<IngoingCrossNode> m_ingoingNodes; + vector<OutgoingCrossNode> m_outgoingNodes; vector<string> m_neighborMwmList; unique_ptr<Reader> mp_reader = nullptr; @@ -37,8 +70,8 @@ public: /// Helper class to generate cross context section in mwm.routing file class CrossRoutingContextWriter { - vector<uint32_t> m_ingoingNodes; - vector<pair<uint32_t,uint32_t> > m_outgoingNodes; + vector<IngoingCrossNode> m_ingoingNodes; + vector<OutgoingCrossNode> m_outgoingNodes; vector<WritedEdgeWeightT> m_adjacencyMatrix; vector<string> m_neighborMwmList; @@ -47,9 +80,9 @@ class CrossRoutingContextWriter public: void Save(Writer & w); - void addIngoingNode(size_t const nodeId); + void addIngoingNode(size_t const nodeId, m2::PointD const & point); - void addOutgoingNode(size_t const nodeId, string const & targetMwm); + void addOutgoingNode(size_t const nodeId, string const & targetMwm, m2::PointD const & point); void reserveAdjacencyMatrix(); |