Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'routing/road_index.hpp')
-rw-r--r--routing/road_index.hpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/routing/road_index.hpp b/routing/road_index.hpp
index 90bd61e70a..fd077538c3 100644
--- a/routing/road_index.hpp
+++ b/routing/road_index.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "routing/joint.hpp"
+#include "routing/routing_serialization.hpp"
#include "coding/reader.hpp"
#include "coding/write_to_sink.hpp"
@@ -74,8 +75,14 @@ public:
return make_pair(Joint::kInvalidId, 0);
}
- template <class Sink>
- void Serialize(Sink & sink) const
+ Joint::Id Front() const { return m_jointIds.front(); }
+
+ Joint::Id Back() const { return m_jointIds.back(); }
+
+ size_t GetSize() const { return m_jointIds.size(); }
+
+ template <class TSink>
+ void Serialize(TSink & sink) const
{
WriteToSink(sink, static_cast<Joint::Id>(m_jointIds.size()));
for (Joint::Id jointId : m_jointIds)
@@ -106,6 +113,12 @@ class RoadIndex final
public:
void Import(vector<Joint> const & joints);
+ /// \brief if |featureIdFrom| and |featureIdTo| are adjacent and if they are connected by
+ /// its ends fills |from| and |to| with corresponding |from| and |to| and return true.
+ /// If not returns false.
+ bool GetAdjacentFtPoints(uint32_t featureIdFrom, uint32_t featureIdTo,
+ RoadPoint & from, RoadPoint & to, Joint::Id & jointId) const;
+
void AddJoint(RoadPoint rp, Joint::Id jointId)
{
m_roads[rp.GetFeatureId()].AddJoint(rp.GetPointId(), jointId);
@@ -158,6 +171,16 @@ public:
f(it.first, it.second);
}
+ template <typename F>
+ void ForEachJoint(uint32_t featureId, F && f) const
+ {
+ auto const it = m_roads.find(featureId);
+ if (it == m_roads.cend())
+ return;
+
+ it->second.ForEachJoint(f);
+ }
+
private:
// Map from feature id to RoadJointIds.
unordered_map<uint32_t, RoadJointIds> m_roads;