From fd08ecf76c8ae0939ee137f3d2532a26d5b78c06 Mon Sep 17 00:00:00 2001 From: Yuri Gorshenin Date: Tue, 7 Apr 2015 17:34:21 +0300 Subject: [PATCH] [pedestrian-routing-benchmarks] Added pedestrian routing benchmarks. --- omim.pro | 1 + .../pedestrian_routing_benchmarks.pro | 19 ++++++++++ .../pedestrian_routing_test.cc | 37 +++++++++++++++++++ qt/mainwindow.cpp | 4 +- routing/astar_router.cpp | 13 ++++++- 5 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 pedestrian_routing_benchmarks/pedestrian_routing_benchmarks.pro create mode 100644 pedestrian_routing_benchmarks/pedestrian_routing_test.cc diff --git a/omim.pro b/omim.pro index 6ef70df949..d69f23eb73 100644 --- a/omim.pro +++ b/omim.pro @@ -45,6 +45,7 @@ SUBDIRS = 3party \ drape_head \ map_server \ integration_tests \ + pedestrian_routing_benchmarks \ } else:drape_device { # libraries which are used on mobile devices with drape engine SUBDIRS = 3party \ diff --git a/pedestrian_routing_benchmarks/pedestrian_routing_benchmarks.pro b/pedestrian_routing_benchmarks/pedestrian_routing_benchmarks.pro new file mode 100644 index 0000000000..a061345c00 --- /dev/null +++ b/pedestrian_routing_benchmarks/pedestrian_routing_benchmarks.pro @@ -0,0 +1,19 @@ +TARGET = pedestrian_routing_benchmarks +CONFIG += console warn_on +CONFIG -= app_bundle +TEMPLATE = app + +ROOT_DIR = ../ +DEPENDENCIES = map routing search storage indexer platform geometry coding base osrm jansson protobuf tomcrypt succinct + +macx-*: LIBS *= "-framework Foundation" "-framework IOKit" + +include($$ROOT_DIR/common.pri) + +QT *= core + +win32* : LIBS *= -lShell32 + +SOURCES += \ + ../testing/testingmain.cpp \ + pedestrian_routing_test.cc \ diff --git a/pedestrian_routing_benchmarks/pedestrian_routing_test.cc b/pedestrian_routing_benchmarks/pedestrian_routing_test.cc new file mode 100644 index 0000000000..36608f917c --- /dev/null +++ b/pedestrian_routing_benchmarks/pedestrian_routing_test.cc @@ -0,0 +1,37 @@ +#include "../testing/testing.hpp" + +#include "../indexer/index.hpp" +#include "../indexer/classificator_loader.hpp" + +#include "../routing/astar_router.hpp" +#include "../routing/features_road_graph.hpp" + +#include "../base/logging.hpp" + +#include "../std/string.hpp" +#include "../std/vector.hpp" + +UNIT_TEST(PedestrianRouting_UK) +{ + string const kMapName = "UK_England"; + classificator::Load(); + Index index; + routing::AStarRouter router(&index); + + m2::RectD rect; + index.AddMap(kMapName + DATA_FILE_EXTENSION, rect); + TEST(index.IsLoaded(kMapName), ()); + MwmSet::MwmId id = index.GetMwmIdByName(kMapName + DATA_FILE_EXTENSION); + TEST_NOT_EQUAL(static_cast(-1), id, ()); + + router.SetRoadGraph(new routing::FeaturesRoadGraph(&index, id)); + + vector startPos = {{59231052, true, 8}, {59231052, false, 8}}; + vector finalPos = {{49334376, true, 0}, {49334376, false, 0}}; + router.SetFinalRoadPos(finalPos); + + vector route; + LOG(LINFO, ("Calculating routing...")); + router.CalculateRoute(startPos, route); + LOG(LINFO, ("Route length:", route.size())); +} diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index ef0611e8e6..f1def91a4b 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -278,7 +278,7 @@ void MainWindow::CreateNavigationBar() pToolBar->addSeparator(); -#ifndef OMIM_OS_LINUX +// #ifndef OMIM_OS_LINUX // add my position button with "checked" behavior m_pMyPositionAction = pToolBar->addAction(QIcon(":/navig64/location.png"), @@ -287,7 +287,7 @@ void MainWindow::CreateNavigationBar() SLOT(OnMyPosition())); m_pMyPositionAction->setCheckable(true); m_pMyPositionAction->setToolTip(tr("My Position")); -#endif +// #endif #ifndef USE_DRAPE // add view actions 1 diff --git a/routing/astar_router.cpp b/routing/astar_router.cpp index 7f0e9ea156..171dc48622 100644 --- a/routing/astar_router.cpp +++ b/routing/astar_router.cpp @@ -1,10 +1,10 @@ #include "astar_router.hpp" #include "../base/logging.hpp" +#include "../base/timer.hpp" #include "../geometry/distance_on_sphere.hpp" #include "../indexer/mercator.hpp" - namespace routing { @@ -12,6 +12,10 @@ static double const MAX_SPEED = 36.11111111111; // m/s void AStarRouter::SetFinalRoadPos(vector const & finalPos) { + LOG(LINFO, ("AStarRouter::SetFinalRoadPos() call")); + for (auto const & roadPos : finalPos) + LOG(LINFO, ("AStarRouter::SetFinalRoadPos(): finalPos:", DebugPrint(roadPos))); + ASSERT_GREATER(finalPos.size(), 0, ()); m_entries.clear(); PossiblePathQueueT().swap(m_queue); @@ -26,6 +30,11 @@ void AStarRouter::SetFinalRoadPos(vector const & finalPos) void AStarRouter::CalculateRoute(vector const & startPos, vector & route) { + my::Timer timer; + LOG(LINFO, ("AStarRouter::CalculateRoute() call start")); + for (auto const & roadPos : startPos) + LOG(LINFO, ("AStarRouter::CalculateRoute(): startPos:", DebugPrint(roadPos))); + route.clear(); set startSet(startPos.begin(), startPos.end()); set startFeatureSet; @@ -46,6 +55,7 @@ void AStarRouter::CalculateRoute(vector const & startPos, vectorGetPos()) != startSet.end()) { ReconstructRoute(current, route); + LOG(LINFO, ("AStarRouter::CalculateRoute() call finish: elapsed:", timer.ElapsedSeconds())); return; } @@ -76,6 +86,7 @@ void AStarRouter::CalculateRoute(vector const & startPos, vector