diff --git a/base/math.hpp b/base/math.hpp index 6549fe059a..c54f74843c 100644 --- a/base/math.hpp +++ b/base/math.hpp @@ -189,7 +189,7 @@ Number constexpr GCD(Number const a, Number const b) { return b == 0 ? a : GCD(b template ::value, void>::type> -// Lowest common multiple. +// Lowest Common Multiple. Number constexpr LCM(Number const a, Number const b) { return a / GCD(a, b) * b; } /// Calculate hash for the pair of values. diff --git a/omim.pro b/omim.pro index 46d405a792..47d2a3ca85 100644 --- a/omim.pro +++ b/omim.pro @@ -263,7 +263,7 @@ SUBDIRS = 3party base coding geometry editor indexer routing search openlr SUBDIRS *= traffic_tests openlr_tests.subdir = openlr/openlr_tests - opnelr_tests.depends = $$SUBDIRS platform_tests_support + openlr_tests.depends = $$SUBDIRS platform_tests_support SUBDIRS *= openlr_tests } # !no-tests } # !gtool diff --git a/openlr/openlr_model.hpp b/openlr/openlr_model.hpp index d68fca99ad..0efad8395e 100644 --- a/openlr/openlr_model.hpp +++ b/openlr/openlr_model.hpp @@ -3,7 +3,9 @@ #include "geometry/latlon.hpp" #include "geometry/point2d.hpp" +#include #include +#include namespace openlr { diff --git a/openlr/openlr_sample.hpp b/openlr/openlr_sample.hpp index cefff0df8f..8a8df36450 100644 --- a/openlr/openlr_sample.hpp +++ b/openlr/openlr_sample.hpp @@ -5,6 +5,7 @@ #include "base/exception.hpp" #include "base/newtype.hpp" +#include #include #include diff --git a/openlr/openlr_simple_parser.hpp b/openlr/openlr_simple_parser.hpp index 20a3d58f48..24add66771 100644 --- a/openlr/openlr_simple_parser.hpp +++ b/openlr/openlr_simple_parser.hpp @@ -10,5 +10,6 @@ class xml_document; namespace openlr { struct LinearSegment; + bool ParseOpenlr(pugi::xml_document const & document, vector & segments); } // namespace openlr diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 18acbbe095..7540330499 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -167,7 +167,7 @@ MainWindow::MainWindow() m_saveTrafficSampleAction->setEnabled(false); m_quitTrafficModeAction = new QAction(tr("Quit traffic mode"), this); - // On Macos actions with names started with quit or exit are threadet specially, + // On macOS actions with names started with quit or exit are treated specially, // see QMenuBar documentation. m_quitTrafficModeAction->setMenuRole(QAction::MenuRole::NoRole); m_quitTrafficModeAction->setEnabled(false); @@ -688,7 +688,6 @@ void MainWindow::OnRetryDownloadClicked() m_pDrawWidget->RetryToDownloadCountry(m_lastCountry); } - void MainWindow::OnTrafficEnabled() { bool const enabled = m_trafficEnableAction->isChecked(); diff --git a/qt/traffic_mode.cpp b/qt/traffic_mode.cpp index 072d159448..174c48b4e2 100644 --- a/qt/traffic_mode.cpp +++ b/qt/traffic_mode.cpp @@ -5,6 +5,8 @@ #include "indexer/index.hpp" #include "indexer/scales.hpp" +#include "base/stl_add.hpp" + #include "3party/pugixml/src/pugixml.hpp" #include @@ -20,20 +22,16 @@ DecodedSample::DecodedSample(Index const & index, openlr::SamplePool const & sam auto const & fid = mwmSegment.m_fid; Index::FeaturesLoaderGuard g(index, fid.m_mwmId); CHECK(fid.m_mwmId.IsAlive(), ("Mwm id is not alive.")); - if (m_points.find(fid) == end(m_points)) - { - FeatureType ft; - CHECK(g.GetFeatureByIndex(fid.m_index, ft), ("Can't read feature", fid)); - ft.ParseGeometry(FeatureType::BEST_GEOMETRY); + if (m_points.find(fid) != end(m_points)) + continue; - auto & v = m_points[fid]; - v.reserve(ft.GetPointsCount()); - auto insIt = back_inserter(v); - ft.ForEachPoint([insIt](m2::PointD const & p) mutable { - insIt++ = p; - }, - scales::GetUpperScale()); - } + FeatureType ft; + CHECK(g.GetFeatureByIndex(fid.m_index, ft), ("Can't read feature", fid)); + ft.ParseGeometry(FeatureType::BEST_GEOMETRY); + + auto & v = m_points[fid]; + v.reserve(ft.GetPointsCount()); + ft.ForEachPoint(MakeBackInsertFunctor(v), scales::GetUpperScale()); } } } @@ -54,6 +52,7 @@ std::vector DecodedSample::GetPoints(size_t const index) const auto const ftIt = m_points.find(seg.m_fid); CHECK(ftIt != end(m_points), ("Can't find feature with id:", seg.m_fid)); auto const & ftPoints = ftIt->second; + CHECK_LESS(seg.m_segId + 1, ftPoints.size(), ()); auto const firstP = ftPoints[seg.m_segId]; auto const secondP = ftPoints[seg.m_segId + 1]; if (seg.m_isForward)