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:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-11-16 08:26:16 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-11-25 10:25:11 +0300
commit91ead6af9046745416b136c39561d1ba598f1b07 (patch)
tree6b8eff31b91ba709b6f943ea998256eea2181a2c /routing/road_index.cpp
parenteb1c85bce50a6d98fa92b1cec278643b26b59946 (diff)
Generating restriction, implementaion implementation using them at runtimeĀ§:wq, applying them on index graph and tests on it.
Diffstat (limited to 'routing/road_index.cpp')
-rw-r--r--routing/road_index.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/routing/road_index.cpp b/routing/road_index.cpp
index e6668e8a0d..fbea8cba5f 100644
--- a/routing/road_index.cpp
+++ b/routing/road_index.cpp
@@ -18,6 +18,59 @@ void RoadIndex::Import(vector<Joint> const & joints)
}
}
+bool RoadIndex::GetAdjacentFtPoints(uint32_t featureIdFrom, uint32_t featureIdTo, RoadPoint & from,
+ RoadPoint & to, Joint::Id & jointId) const
+{
+ auto const fromIt = m_roads.find(featureIdFrom);
+ if (fromIt == m_roads.cend())
+ return false;
+
+ auto const toIt = m_roads.find(featureIdTo);
+ if (toIt == m_roads.cend())
+ return false;
+
+ RoadJointIds const & roadJointIdsFrom = fromIt->second;
+ RoadJointIds const & roadJointIdsTo = toIt->second;
+ if (roadJointIdsFrom.GetSize() == 0 || roadJointIdsTo.GetSize() == 0)
+ return false; // No sence in restrictions on features without joints.
+
+ // Note. It's important to check other variant besides a restriction from last segment
+ // of featureIdFrom to first segment of featureIdTo since two way features can have
+ // reverse point order.
+ if (roadJointIdsFrom.Back() == roadJointIdsTo.Front())
+ {
+ from = RoadPoint(featureIdFrom, roadJointIdsFrom.GetSize() - 1);
+ to = RoadPoint(featureIdTo, 0);
+ jointId = roadJointIdsFrom.Back();
+ return true;
+ }
+
+ if (roadJointIdsFrom.Front() == roadJointIdsTo.Back())
+ {
+ from = RoadPoint(featureIdFrom, 0);
+ to = RoadPoint(featureIdTo, roadJointIdsTo.GetSize() - 1);
+ jointId = roadJointIdsFrom.Front();
+ return true;
+ }
+
+ if (roadJointIdsFrom.Back() == roadJointIdsTo.Back())
+ {
+ from = RoadPoint(featureIdFrom, roadJointIdsFrom.GetSize() - 1);
+ to = RoadPoint(featureIdTo, roadJointIdsTo.GetSize() - 1);
+ jointId = roadJointIdsFrom.Back();
+ return true;
+ }
+
+ if (roadJointIdsFrom.Front() == roadJointIdsTo.Front())
+ {
+ from = RoadPoint(featureIdFrom, 0);
+ to = RoadPoint(featureIdTo, 0);
+ jointId = roadJointIdsFrom.Front();
+ return true;
+ }
+ return false; // |featureIdFrom| and |featureIdTo| are not adjacent.
+}
+
pair<Joint::Id, uint32_t> RoadIndex::FindNeighbor(RoadPoint rp, bool forward) const
{
auto const it = m_roads.find(rp.GetFeatureId());