From c74b3b42d930b8bbd61a1c076a51cecca7f7d19e Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Tue, 1 Mar 2016 14:07:55 +0300 Subject: [PATCH] Fix GetPointsCount() ASSERT for 0 values. --- routing/osrm_helpers.cpp | 9 +++++---- routing/osrm_helpers.hpp | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/routing/osrm_helpers.cpp b/routing/osrm_helpers.cpp index 729efa5a26..c83cc2e3bb 100644 --- a/routing/osrm_helpers.cpp +++ b/routing/osrm_helpers.cpp @@ -11,14 +11,15 @@ namespace helpers { // static void Point2PhantomNode::FindNearestSegment(FeatureType const & ft, m2::PointD const & point, - Candidate & res, size_t start_idx, size_t stop_idx) + Candidate & res, size_t startIdx, size_t stopIdx) { ft.ParseGeometry(FeatureType::BEST_GEOMETRY); + ASSERT_GREATER(ft.GetPointsCount(), 1, ()); + size_t const lastIdx = min(ft.GetPointsCount() - 1, stopIdx); + ASSERT_GREATER_OR_EQUAL(lastIdx, startIdx + 1, ()); - size_t const count = min(ft.GetPointsCount() - 1, stop_idx); uint32_t const featureId = ft.GetID().m_index; - ASSERT_GREATER_OR_EQUAL(count, 1, ()); - for (size_t i = start_idx + 1; i <= count; ++i) + for (size_t i = startIdx + 1; i <= lastIdx; ++i) { m2::ProjectionToSection segProj; segProj.SetBounds(ft.GetPoint(i - 1), ft.GetPoint(i)); diff --git a/routing/osrm_helpers.hpp b/routing/osrm_helpers.hpp index 23cb9b2261..ecf6164ce9 100644 --- a/routing/osrm_helpers.hpp +++ b/routing/osrm_helpers.hpp @@ -38,7 +38,7 @@ public: // Finds nearest segment to a feature geometry. static void FindNearestSegment(FeatureType const & ft, m2::PointD const & point, Candidate & res, - size_t start_idx = 0, size_t stop_idx = numeric_limits::max()); + size_t startIdx = 0, size_t stopIdx = numeric_limits::max()); // Sets point from where weights are calculated. void SetPoint(m2::PointD const & pt) { m_point = pt; }