From 4e02b29ed50f0f2f0d794e6ee5d70c572f0dcdec Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Fri, 25 Sep 2015 16:40:19 +0300 Subject: [PATCH] PR fixes. --- routing/route.cpp | 5 ++--- routing/speed_camera.cpp | 24 +++++++----------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/routing/route.cpp b/routing/route.cpp index c12e42a721..bcfa78f873 100644 --- a/routing/route.cpp +++ b/routing/route.cpp @@ -152,9 +152,8 @@ Route::TTurns::const_iterator Route::GetCurrentTurn() const double Route::GetCurrentCam(SpeedCameraRestriction & camera, Index const & index) const { - size_t current_index = max(m_poly.GetCurrentIter().m_ind, m_lastCheckedCamera); - SpeedCameraRestriction cam(static_cast(current_index), 0 /* maxspeed */); - for (size_t i = current_index; i < m_poly.GetPolyline().GetSize(); ++i) + size_t const currentIndex = max(m_poly.GetCurrentIter().m_ind, m_lastCheckedCamera); + for (size_t i = currentIndex; i < m_poly.GetPolyline().GetSize(); ++i) { uint8_t speed = CheckCameraInPoint(m_poly.GetPolyline().GetPoint(i), index); if (speed != kNoSpeedCamera) diff --git a/routing/speed_camera.cpp b/routing/speed_camera.cpp index ed72b88832..0d1ab450f0 100644 --- a/routing/speed_camera.cpp +++ b/routing/speed_camera.cpp @@ -33,30 +33,20 @@ uint8_t ReadCamRestriction(FeatureType & ft) uint8_t CheckCameraInPoint(m2::PointD const & point, Index const & index) { - Classificator & c = classif(); - uint32_t const req = c.GetTypeByPath({"highway", "speed_camera"}); - uint32_t speedLimit = kNoSpeedCamera; - auto const f = [&req, &c, &point, &speedLimit](FeatureType & ft) + auto const f = [&point, &speedLimit](FeatureType & ft) { if (ft.GetFeatureType() != feature::GEOM_POINT) return; feature::TypesHolder hl = ft; - for (uint32_t t : hl) - { - uint32_t const type = ftypes::BaseChecker::PrepareToMatch(t, 2); - if (type == req) - { - ft.ParseGeometry(FeatureType::BEST_GEOMETRY); - if (ft.GetCenter() == point) - { - speedLimit = ReadCamRestriction(ft); - return; - } - } - } + if (!ftypes::IsSpeedCamChecker::Instance()(hl)) + return; + + ft.ParseGeometry(FeatureType::BEST_GEOMETRY); + if (ft.GetCenter() == point) + speedLimit = ReadCamRestriction(ft); }; index.ForEachInRect(f,