diff options
Diffstat (limited to 'routing/road_index.cpp')
-rw-r--r-- | routing/road_index.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/routing/road_index.cpp b/routing/road_index.cpp new file mode 100644 index 0000000000..acc1a9d8e8 --- /dev/null +++ b/routing/road_index.cpp @@ -0,0 +1,31 @@ +#include "routing/road_index.hpp" + +#include "base/exception.hpp" + +#include "std/utility.hpp" + +namespace routing +{ +void RoadIndex::Import(vector<Joint> const & joints) +{ + for (Joint::Id jointId = 0; jointId < joints.size(); ++jointId) + { + Joint const & joint = joints[jointId]; + for (uint32_t i = 0; i < joint.GetSize(); ++i) + { + RoadPoint const & entry = joint.GetEntry(i); + RoadJointIds & roadJoints = m_roads[entry.GetFeatureId()]; + roadJoints.AddJoint(entry.GetPointId(), jointId); + } + } +} + +pair<Joint::Id, uint32_t> RoadIndex::FindNeighbor(RoadPoint rp, bool forward) const +{ + auto const it = m_roads.find(rp.GetFeatureId()); + if (it == m_roads.cend()) + MYTHROW(RootException, ("RoadIndex doesn't contains feature", rp.GetFeatureId())); + + return it->second.FindNeighbor(rp.GetPointId(), forward); +} +} // namespace routing |