diff options
author | Yuri Gorshenin <y@mmaps.me> | 2015-04-07 12:59:56 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:46:33 +0300 |
commit | b406151a884da7f48e7908f411ec0d88e17ed0d3 (patch) | |
tree | c3813fd10c6fa4f83fce296f1e556228e71f5e4b /routing/routing_tests/road_graph_builder.cpp | |
parent | bad708e551e98964d40915261ad9d26fa27aef21 (diff) |
Review fixes.
Diffstat (limited to 'routing/routing_tests/road_graph_builder.cpp')
-rw-r--r-- | routing/routing_tests/road_graph_builder.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/routing/routing_tests/road_graph_builder.cpp b/routing/routing_tests/road_graph_builder.cpp index e8209b4c95..5ed354d41c 100644 --- a/routing/routing_tests/road_graph_builder.cpp +++ b/routing/routing_tests/road_graph_builder.cpp @@ -1,5 +1,7 @@ #include "road_graph_builder.hpp" +#include "../../base/logging.hpp" + #include "../../std/algorithm.hpp" using namespace routing; @@ -16,34 +18,30 @@ void RoadInfo::Swap(RoadInfo & r) void RoadGraphMockSource::AddRoad(RoadInfo & rd) { /// @todo Do ASSERT for RoadInfo params. + uint32_t const roadId = m_roads.size(); - uint32_t const id = m_roads.size(); + if (rd.m_points.size() < 2) + { + LOG(LERROR, ("Empty road")); + return; + } - // Count of sections! (not points) - size_t const count = rd.m_points.size(); - ASSERT_GREATER(count, 1, ()); + size_t const numSegments = rd.m_points.size() - 1; + ASSERT_GREATER(numSegments, 0, ()); - for (size_t i = 0; i < count; ++i) + for (size_t segId = 0; segId < numSegments; ++segId) { - TurnsMapT::iterator j = m_turns.insert(make_pair(rd.m_points[i], TurnsVectorT())).first; - PossibleTurn t; t.m_startPoint = rd.m_points.front(); t.m_endPoint = rd.m_points.back(); t.m_speed = rd.m_speedMS; - if (i > 0) - { - t.m_pos = RoadPos(id /* featureId */, true /* forward */, i - 1 /* segmentId */, - rd.m_points[i] /* segEndPoint */); - j->second.push_back(t); - } - - if (rd.m_bidirectional && (i < count - 1)) + t.m_pos = RoadPos(roadId, true /* forward */, segId, rd.m_points[segId + 1] /* segEndPoint */); + m_turns[t.m_pos.GetSegEndpoint()].push_back(t); + if (rd.m_bidirectional) { - t.m_pos = RoadPos(id /* featureId */, false /* forward */, i /* segmentId */, - rd.m_points[i] /* segEndPoint */); - j->second.push_back(t); + t.m_pos = RoadPos(roadId, false /* forward */, segId, rd.m_points[segId] /* segEndPoint */); + m_turns[t.m_pos.GetSegEndpoint()].push_back(t); } } @@ -60,7 +58,7 @@ void RoadGraphMockSource::GetPossibleTurns(RoadPos const & pos, TurnsVectorT & t vector<m2::PointD> const & points = m_roads[fID].m_points; int const inc = pos.IsForward() ? -1 : 1; - int startID = pos.GetSegmentId(); + int startID = pos.GetSegId(); int const count = static_cast<int>(points.size()); if (!pos.IsForward()) |