Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLev Dragunov <l.dragunov@corp.mail.ru>2015-08-11 18:22:57 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 03:01:44 +0300
commit839a59484b4e5c8dc7a618c09157945c9e82c1c9 (patch)
tree0a5c22bf37c520e889b74aa08c4556472db93daa
parentb8bf432fbd1b45707e70fc8dcdf896d039a73f54 (diff)
Remove TurnsGeom structure.
-rw-r--r--integration_tests/routing_test_tools.cpp32
-rw-r--r--integration_tests/routing_test_tools.hpp7
-rw-r--r--map/framework.cpp13
-rw-r--r--map/map.pro2
-rw-r--r--map/map_tests/map_tests.pro1
-rw-r--r--map/map_tests/tracks_tests.cpp157
-rw-r--r--map/route_track.hpp3
-rw-r--r--routing/directions_engine.hpp1
-rw-r--r--routing/osrm_router.cpp27
-rw-r--r--routing/osrm_router.hpp4
-rw-r--r--routing/pedestrian_directions.cpp5
-rw-r--r--routing/pedestrian_directions.hpp1
-rw-r--r--routing/road_graph_router.cpp4
-rw-r--r--routing/route.cpp25
-rw-r--r--routing/route.hpp9
-rw-r--r--routing/routing_tests/turns_generator_test.cpp67
-rw-r--r--routing/turns.cpp10
-rw-r--r--routing/turns.hpp21
-rw-r--r--routing/turns_generator.cpp42
-rw-r--r--routing/turns_generator.hpp6
20 files changed, 37 insertions, 400 deletions
diff --git a/integration_tests/routing_test_tools.cpp b/integration_tests/routing_test_tools.cpp
index fd162231dd..27f439af23 100644
--- a/integration_tests/routing_test_tools.cpp
+++ b/integration_tests/routing_test_tools.cpp
@@ -210,7 +210,7 @@ namespace integration
void TestTurnCount(routing::Route const & route, uint32_t expectedTurnCount)
{
- TEST_EQUAL(route.GetTurnsGeometry().size(), expectedTurnCount, ());
+ TEST_EQUAL(route.GetTurns().size(), expectedTurnCount, ());
}
void TestRouteLength(Route const & route, double expectedRouteMeters,
@@ -283,40 +283,12 @@ namespace integration
TestTurn GetNthTurn(routing::Route const & route, uint32_t turnNumber)
{
- turns::TTurnsGeom const & turnsGeom = route.GetTurnsGeometry();
- if (turnNumber >= turnsGeom.size())
- return TestTurn();
-
Route::TTurns const & turns = route.GetTurns();
if (turnNumber >= turns.size())
return TestTurn();
- turns::TurnGeom const & turnGeom = turnsGeom[turnNumber];
- ASSERT_LESS(turnGeom.m_turnIndex, turnGeom.m_points.size(), ());
TurnItem const & turn = turns[turnNumber];
- return TestTurn(turnGeom.m_points[turnGeom.m_turnIndex], turn.m_turn, turn.m_exitNum);
- }
-
- TestTurn GetTurnByPoint(routing::Route const & route, m2::PointD const & approximateTurnPoint,
- double inaccuracyMeters)
- {
- turns::TTurnsGeom const & turnsGeom = route.GetTurnsGeometry();
- Route::TTurns const & turns = route.GetTurns();
- ASSERT_EQUAL(turnsGeom.size() + 1, turns.size(), ());
-
- for (int i = 0; i != turnsGeom.size(); ++i)
- {
- turns::TurnGeom const & turnGeom = turnsGeom[i];
- ASSERT_LESS(turnGeom.m_turnIndex, turnGeom.m_points.size(), ());
- m2::PointD const turnPoint = turnGeom.m_points[turnGeom.m_turnIndex];
- if (ms::DistanceOnEarth(turnPoint.y, turnPoint.x, approximateTurnPoint.y, approximateTurnPoint.x) <=
- inaccuracyMeters)
- {
- TurnItem const & turn = turns[i];
- return TestTurn(turnPoint, turn.m_turn, turn.m_exitNum);
- }
- }
- return TestTurn();
+ return TestTurn(route.GetPoly().GetPoint(turn.m_index), turn.m_turn, turn.m_exitNum);
}
void TestOnlineFetcher(ms::LatLon const & startPoint, ms::LatLon const & finalPoint,
diff --git a/integration_tests/routing_test_tools.hpp b/integration_tests/routing_test_tools.hpp
index 1d06df12f6..3e12db4840 100644
--- a/integration_tests/routing_test_tools.hpp
+++ b/integration_tests/routing_test_tools.hpp
@@ -22,8 +22,7 @@
* 2. Loading maps and calculating routes is a time consumption process.
* Do this only if you really need it.
* 3. If you want to check that a turn is absent you have two options
- * - use GetTurnByPoint(...).TestNotValid();
- * - or use TestTurnCount.
+ * - use TestTurnCount.
* 4. The easiest way to gather all the information for writing an integration test is
* - to put a break point in OsrmRouter::CalculateRouteImpl;
* - to make a route with MapWithMe desktop application;
@@ -83,8 +82,6 @@ namespace integration
class TestTurn
{
friend TestTurn GetNthTurn(Route const & route, uint32_t turnNumber);
- friend TestTurn GetTurnByPoint(Route const & route, m2::PointD const & approximateTurnPoint,
- double inaccuracy);
m2::PointD const m_point;
TurnDirection const m_direction;
@@ -118,6 +115,4 @@ namespace integration
/// Extracting appropriate TestTurn if any. If not TestTurn::isValid() returns false.
/// inaccuracy is set in meters.
TestTurn GetNthTurn(Route const & route, uint32_t turnNumber);
- TestTurn GetTurnByPoint(Route const & route, m2::PointD const & approximateTurnPoint,
- double inaccuracyMeters = 3.);
}
diff --git a/map/framework.cpp b/map/framework.cpp
index 25685a7e26..991ac587cf 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -2244,16 +2244,11 @@ void Framework::InsertRoute(Route const & route)
return;
}
- vector<double> turns;
+ double mercatorDistance = 0;
+ vector<double> turnsDistances;
if (m_currentRouterType == RouterType::Vehicle)
{
- turns::TTurnsGeom const & turnsGeom = route.GetTurnsGeometry();
- if (!turnsGeom.empty())
- {
- turns.reserve(turnsGeom.size());
- for (size_t i = 0; i < turnsGeom.size(); i++)
- turns.push_back(turnsGeom[i].m_mercatorDistance);
- }
+ route.GetTurnsDistances(turnsDistances);
}
/// @todo Consider a style parameter for the route color.
@@ -2263,7 +2258,7 @@ void Framework::InsertRoute(Route const & route)
else
routeColor = graphics::Color(30, 150, 240, 204);
- m_bmManager.SetRouteTrack(route.GetPoly(), turns, routeColor);
+ m_bmManager.SetRouteTrack(route.GetPoly(), turnsDistances, routeColor);
m_informationDisplay.ResetRouteMatchingInfo();
Invalidate();
diff --git a/map/map.pro b/map/map.pro
index c8a7223e3e..152972ef17 100644
--- a/map/map.pro
+++ b/map/map.pro
@@ -39,7 +39,6 @@ HEADERS += \
pin_click_manager.hpp \
country_tree.hpp \
active_maps_layout.hpp \
- route_track.hpp \
navigator_utils.hpp \
SOURCES += \
@@ -72,7 +71,6 @@ SOURCES += \
pin_click_manager.cpp \
country_tree.cpp \
active_maps_layout.cpp \
- route_track.cpp \
navigator_utils.cpp \
!iphone*:!tizen*:!android* {
diff --git a/map/map_tests/map_tests.pro b/map/map_tests/map_tests.pro
index 74e6dff81d..17df03d4dc 100644
--- a/map/map_tests/map_tests.pro
+++ b/map/map_tests/map_tests.pro
@@ -36,7 +36,6 @@ SOURCES += \
kmz_unarchive_test.cpp \
mwm_url_tests.cpp \
navigator_test.cpp \
- tracks_tests.cpp \
!linux* {
SOURCES += working_time_tests.cpp \
diff --git a/map/map_tests/tracks_tests.cpp b/map/map_tests/tracks_tests.cpp
deleted file mode 100644
index 3c040fdb18..0000000000
--- a/map/map_tests/tracks_tests.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-#include "testing/testing.hpp"
-
-#include "map/route_track.hpp"
-
-UNIT_TEST(ClipArrowBodyAndGetArrowDirection)
-{
- /// test 1
- {
- vector<m2::PointD> ptsTurn = {{4452766.0004956936, -8008660.158053305},
- {4452767.909028396, -8008670.0188056063},
- {4452768.5452059628, -8008681.4700018261},
- {4452765.6824069088, -8008693.8754644003},
- {4452759.3206312312, -8008705.6447494039},
- {4452746.2789910901, -8008720.9130110294},
- {4452746.2789910901, -8008720.9130110294},
- {4452670.8919493081, -8008780.7137024049},
- {4452631.7670288859, -8008811.5683144433},
- {4452567.5130945379, -8008863.0986974351}};
-
- pair<m2::PointD, m2::PointD> arrowDirection;
- bool result = ClipArrowBodyAndGetArrowDirection(ptsTurn, arrowDirection, 5, 13., 13., 19.);
-
- TEST(result, ());
-
- TEST(m2::AlmostEqualULPs(arrowDirection.first, m2::PointD(4452740.7948958352, -8008725.2632638067)), ());
- TEST(m2::AlmostEqualULPs(arrowDirection.second, m2::PointD(4452736.0942427581, -8008728.9920519013)), ());
-
- TEST_EQUAL(ptsTurn.size(), 4, ());
- if (ptsTurn.size() == 4)
- {
- TEST(m2::AlmostEqualULPs(ptsTurn[0], m2::PointD(4452754.7223071428, -8008711.0281532137)), ());
- TEST(m2::AlmostEqualULPs(ptsTurn[1], m2::PointD(4452746.2789910901, -8008720.9130110294)), ());
- TEST(m2::AlmostEqualULPs(ptsTurn[2], m2::PointD(4452746.2789910901, -8008720.9130110294)), ());
- TEST(m2::AlmostEqualULPs(ptsTurn[3], m2::PointD(4452736.0942427581, -8008728.9920519013)), ());
- }
- }
- /// test 2
- {
- vector<m2::PointD> ptsTurn = {{12914322.855819134, -23248364.915229369},
- {12914293.14321561, -23248301.411821831},
- {12914293.14321561, -23248301.411821831},
- {12913951.625143414, -23247594.377110228},
- {12913951.625143414, -23247594.377110228},
- {12913554.725762228, -23246680.585511677},
- {12913554.725762228, -23246680.585511677},
- {12913622.106354846, -23246649.202769905},
- {12913891.628725335, -23246525.517846469},
- {12913891.628725335, -23246525.517846469},
- {12914043.927325094, -23246455.368188392},
- {12914043.927325094, -23246455.368188392},
- {12914123.307201328, -23246418.447315723},
- {12914474.05549168, -23246248.611301452},
- {12914474.05549168, -23246248.611301452},
- {12916033.962361945, -23245541.576589838},
- {12916319.957645988, -23245411.846770275}};
- pair<m2::PointD, m2::PointD> arrowDirection;
- bool result = ClipArrowBodyAndGetArrowDirection(ptsTurn, arrowDirection, 5, 13., 13., 19.);
-
- TEST(result, ());
-
- TEST(m2::AlmostEqualULPs(arrowDirection.first, m2::PointD(12913561.071263125, -23246677.630072903)), ());
- TEST(m2::AlmostEqualULPs(arrowDirection.second, m2::PointD(12913566.510263896, -23246675.096839666)), ());
-
- TEST_EQUAL(ptsTurn.size(), 4, ());
- if (ptsTurn.size() == 4)
- {
- TEST(m2::AlmostEqualULPs(ptsTurn[0], m2::PointD(12913559.904797219, -23246692.509336423)), ());
- TEST(m2::AlmostEqualULPs(ptsTurn[1], m2::PointD(12913554.725762228, -23246680.585511677)), ());
- TEST(m2::AlmostEqualULPs(ptsTurn[2], m2::PointD(12913554.725762228, -23246680.585511677)), ());
- TEST(m2::AlmostEqualULPs(ptsTurn[3], m2::PointD(12913566.510263896, -23246675.096839666)), ());
- }
- }
- /// test 3
- {
- vector<m2::PointD> ptsTurn = {{8815765.3299729209, -15869538.380037762},
- {8815545.8558755163, -15869644.271852948},
- {8815493.5605482981, -15869666.954163551},
- {8815493.5605482981, -15869666.954163551},
- {8815429.2940016072, -15869529.600171586},
- {8815429.2940016072, -15869529.600171586},
- {8815196.1702537816, -15869046.971007187},
- {8815196.1702537816, -15869046.971007187},
- {8815012.9423559866, -15868625.120730862}};
- pair<m2::PointD, m2::PointD> arrowDirection;
- bool result = ClipArrowBodyAndGetArrowDirection(ptsTurn, arrowDirection, 2, 5., 13., 14.);
-
- TEST(result, ());
-
- TEST(m2::AlmostEqualULPs(arrowDirection.first, m2::PointD(8815488.4750074092, -15869656.085066356)), ());
- TEST(m2::AlmostEqualULPs(arrowDirection.second, m2::PointD(8815488.051212335, -15869655.179308256)), ());
-
- TEST_EQUAL(ptsTurn.size(), 4, ());
- if (ptsTurn.size() == 4)
- {
- TEST(m2::AlmostEqualULPs(ptsTurn[0], m2::PointD(8815498.1476540733, -15869664.964575503)), ());
- TEST(m2::AlmostEqualULPs(ptsTurn[1], m2::PointD(8815493.5605482981, -15869666.954163551)), ());
- TEST(m2::AlmostEqualULPs(ptsTurn[2], m2::PointD(8815493.5605482981, -15869666.954163551)), ());
- TEST(m2::AlmostEqualULPs(ptsTurn[3], m2::PointD(8815488.051212335, -15869655.179308256)), ());
- }
- }
-}
-
-UNIT_TEST(MergeArrows)
-{
- double const arrowLen = 19;
- double const bodyLen = 26;
-
- /// Merging arrows bodies
- {
- vector<m2::Point<double>> ptsCurrentTurn = {{942781.30335104989, -1704679.4222819123},
- {942770.40578790777, -1704686.5105198855},
- {942770.40578790777, -1704686.5105198855},
- {942772.83924417838, -1704690.2283002988},
- {942772.83924417838, -1704690.2283002988},
- {942777.65950491628, -1704697.298016048}};
- vector<m2::Point<double>> const ptsNextTurn = {{942772.61973019898, -1704689.8929317191},
- {942772.83924417838, -1704690.2283002988},
- {942772.83924417838, -1704690.2283002988},
- {942779.93682496831, -1704700.6380854577},
- {942779.93682496831, -1704700.6380854577},
- {942779.12567287835, -1704701.0436615027},
- {942768.95600306219, -1704707.5874363843}};
-
- bool const mergeArrows = MergeArrows(ptsCurrentTurn, ptsNextTurn, bodyLen, arrowLen);
-
- TEST(mergeArrows, ());
- TEST_EQUAL(ptsCurrentTurn.size(), 4, ());
- if (ptsCurrentTurn.size() == 4)
- {
- TEST(m2::AlmostEqualULPs(ptsCurrentTurn[0], m2::PointD(942781.30335104989, -1704679.4222819123)), ());
- TEST(m2::AlmostEqualULPs(ptsCurrentTurn[1], m2::PointD(942770.40578790777, -1704686.5105198855)), ());
- TEST(m2::AlmostEqualULPs(ptsCurrentTurn[2], m2::PointD(942770.40578790777, -1704686.5105198855)), ());
- TEST(m2::AlmostEqualULPs(ptsCurrentTurn[3], m2::PointD(942772.83924417838, -1704690.2283002988)), ());
- }
- }
-
- /// No need merging
- {
- vector<m2::Point<double>> ptsCurrentTurn = {{5076492.1418151176, -9129678.8727533203},
- {5076492.1418151176, -9129678.8727533203},
- {5076492.2410291191, -9129680.013714334}};
- vector<m2::Point<double>> const ptsNextTurn = {{5076440.1457105754, -9129732.8748834748},
- {5076428.3278678777, -9129727.458372239},
- {5076428.3278678777, -9129727.458372239}};
- double const arrowLen = 19;
- double const bodyLen = 26;
- bool const mergeArrows = MergeArrows(ptsCurrentTurn, ptsNextTurn, bodyLen, arrowLen);
- TEST(!mergeArrows, ());
- TEST_EQUAL(ptsCurrentTurn.size(), 3, ());
- if (ptsCurrentTurn.size() == 3)
- {
- TEST(m2::AlmostEqualULPs(ptsCurrentTurn[0], m2::PointD(5076492.1418151176, -9129678.8727533203)), ());
- TEST(m2::AlmostEqualULPs(ptsCurrentTurn[1], m2::PointD(5076492.1418151176, -9129678.8727533203)), ());
- TEST(m2::AlmostEqualULPs(ptsCurrentTurn[2], m2::PointD(5076492.2410291191, -9129680.013714334)), ());
- }
- }
-}
diff --git a/map/route_track.hpp b/map/route_track.hpp
index 76a22450f4..e7301992bc 100644
--- a/map/route_track.hpp
+++ b/map/route_track.hpp
@@ -22,8 +22,6 @@ public:
virtual void CleanUp() const;
virtual bool HasDisplayLists() const;
- void SetTurnsGeometry(routing::turns::TTurnsGeom const & turnsGeom) { m_turnsGeom = turnsGeom; }
-
void AddClosingSymbol(bool isBeginSymbol, string const & symbolName,
graphics::EPosition pos, double depth);
@@ -50,7 +48,6 @@ private:
vector<ClosingSymbol> m_beginSymbols;
vector<ClosingSymbol> m_endSymbols;
- routing::turns::TTurnsGeom m_turnsGeom;
mutable location::RouteMatchingInfo m_relevantMatchedInfo;
mutable graphics::DisplayList * m_closestSegmentDL = nullptr;
diff --git a/routing/directions_engine.hpp b/routing/directions_engine.hpp
index 3706db21a2..966f9707eb 100644
--- a/routing/directions_engine.hpp
+++ b/routing/directions_engine.hpp
@@ -16,7 +16,6 @@ public:
virtual void Generate(IRoadGraph const & graph, vector<Junction> const & path,
Route::TTimes & times,
Route::TTurns & turnsDir,
- turns::TTurnsGeom & turnsGeom,
my::Cancellable const & cancellable) = 0;
};
diff --git a/routing/osrm_router.cpp b/routing/osrm_router.cpp
index 0a91ae3f63..0b62d1bd9f 100644
--- a/routing/osrm_router.cpp
+++ b/routing/osrm_router.cpp
@@ -470,7 +470,6 @@ OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(TCheckedPath const &
Route::TTurns TurnsDir;
Route::TTimes Times;
vector<m2::PointD> Points;
- turns::TTurnsGeom TurnsGeom;
for (RoutePathCross cross : path)
{
ASSERT_EQUAL(cross.startNode.mwmName, cross.finalNode.mwmName, ());
@@ -488,9 +487,7 @@ OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(TCheckedPath const &
Route::TTurns mwmTurnsDir;
Route::TTimes mwmTimes;
vector<m2::PointD> mwmPoints;
- turns::TTurnsGeom mwmTurnsGeom;
- MakeTurnAnnotation(routingResult, mwmMapping, delegate, mwmPoints, mwmTurnsDir, mwmTimes,
- mwmTurnsGeom);
+ MakeTurnAnnotation(routingResult, mwmMapping, delegate, mwmPoints, mwmTurnsDir, mwmTimes);
// Connect annotated route.
const uint32_t pSize = Points.size();
for (auto turn : mwmTurnsDir)
@@ -515,27 +512,13 @@ OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(TCheckedPath const &
{
// We're at the end point.
Points.pop_back();
- for (auto & turnGeom : mwmTurnsGeom)
- {
- if (turnGeom.m_indexInRoute)
- turnGeom.m_indexInRoute += pSize;
- }
}
Points.insert(Points.end(), mwmPoints.begin(), mwmPoints.end());
-
- if (!TurnsGeom.empty())
- {
- double const mercatorLength = TurnsGeom.back().m_mercatorDistance;
- for (auto & turnGeom : mwmTurnsGeom)
- turnGeom.m_mercatorDistance += mercatorLength;
- }
- TurnsGeom.insert(TurnsGeom.end(), mwmTurnsGeom.begin(), mwmTurnsGeom.end());
}
route.SetGeometry(Points.begin(), Points.end());
route.SetTurnInstructions(TurnsDir);
route.SetSectionTimes(Times);
- route.SetTurnInstructionsGeometry(TurnsGeom);
return OsrmRouter::NoError;
}
@@ -629,14 +612,12 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
Route::TTurns turnsDir;
Route::TTimes times;
vector<m2::PointD> points;
- turns::TTurnsGeom turnsGeom;
- MakeTurnAnnotation(routingResult, startMapping, delegate, points, turnsDir, times, turnsGeom);
+ MakeTurnAnnotation(routingResult, startMapping, delegate, points, turnsDir, times);
route.SetGeometry(points.begin(), points.end());
route.SetTurnInstructions(turnsDir);
route.SetSectionTimes(times);
- route.SetTurnInstructionsGeometry(turnsGeom);
return NoError;
}
@@ -695,7 +676,7 @@ IRouter::ResultCode OsrmRouter::FindPhantomNodes(m2::PointD const & point,
OsrmRouter::ResultCode OsrmRouter::MakeTurnAnnotation(
RawRoutingResult const & routingResult, TRoutingMappingPtr const & mapping,
RouterDelegate const & delegate, vector<m2::PointD> & points, Route::TTurns & turnsDir,
- Route::TTimes & times, turns::TTurnsGeom & turnsGeom)
+ Route::TTimes & times)
{
ASSERT(mapping, ());
@@ -844,8 +825,6 @@ OsrmRouter::ResultCode OsrmRouter::MakeTurnAnnotation(
}
turns::FixupTurns(points, turnsDir);
- turns::CalculateTurnGeometry(points, turnsDir, turnsGeom);
-
#ifdef DEBUG
for (auto t : turnsDir)
{
diff --git a/routing/osrm_router.hpp b/routing/osrm_router.hpp
index 2b2d098cc4..2dca161544 100644
--- a/routing/osrm_router.hpp
+++ b/routing/osrm_router.hpp
@@ -81,14 +81,12 @@ protected:
* \param points Storage for unpacked points of the path.
* \param turnsDir output turns annotation storage.
* \param times output times annotation storage.
- * \param turnsGeom output turns geometry.
* \return routing operation result code.
*/
ResultCode MakeTurnAnnotation(RawRoutingResult const & routingResult,
TRoutingMappingPtr const & mapping,
RouterDelegate const & delegate, vector<m2::PointD> & points,
- Route::TTurns & turnsDir, Route::TTimes & times,
- turns::TTurnsGeom & turnsGeom);
+ Route::TTurns & turnsDir, Route::TTimes & times);
private:
/*!
diff --git a/routing/pedestrian_directions.cpp b/routing/pedestrian_directions.cpp
index 00dc0fef98..53e5d4009d 100644
--- a/routing/pedestrian_directions.cpp
+++ b/routing/pedestrian_directions.cpp
@@ -38,7 +38,6 @@ PedestrianDirectionsEngine::PedestrianDirectionsEngine()
void PedestrianDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junction> const & path,
Route::TTimes & times,
Route::TTurns & turnsDir,
- turns::TTurnsGeom & turnsGeom,
my::Cancellable const & cancellable)
{
CHECK_GREATER(path.size(), 1, ());
@@ -55,10 +54,6 @@ void PedestrianDirectionsEngine::Generate(IRoadGraph const & graph, vector<Junct
}
CalculateTurns(graph, routeEdges, turnsDir, cancellable);
-
- // Do not show arrows for pedestrian routing until a good design solution
- // turns::CalculateTurnGeometry(path, turnsDir, turnsGeom);
- UNUSED_VALUE(turnsGeom);
}
bool PedestrianDirectionsEngine::ReconstructPath(IRoadGraph const & graph, vector<Junction> const & path,
diff --git a/routing/pedestrian_directions.hpp b/routing/pedestrian_directions.hpp
index 162a9e37f4..a82dd8001b 100644
--- a/routing/pedestrian_directions.hpp
+++ b/routing/pedestrian_directions.hpp
@@ -14,7 +14,6 @@ public:
void Generate(IRoadGraph const & graph, vector<Junction> const & path,
Route::TTimes & times,
Route::TTurns & turnsDir,
- turns::TTurnsGeom & turnsGeom,
my::Cancellable const & cancellable) override;
private:
diff --git a/routing/road_graph_router.cpp b/routing/road_graph_router.cpp
index 16688b803b..f4b50e0eeb 100644
--- a/routing/road_graph_router.cpp
+++ b/routing/road_graph_router.cpp
@@ -251,14 +251,12 @@ void RoadGraphRouter::ReconstructRoute(vector<Junction> && path, Route & route,
Route::TTimes times;
Route::TTurns turnsDir;
- turns::TTurnsGeom turnsGeom;
if (m_directionsEngine)
- m_directionsEngine->Generate(*m_roadGraph, path, times, turnsDir, turnsGeom, cancellable);
+ m_directionsEngine->Generate(*m_roadGraph, path, times, turnsDir, cancellable);
route.SetGeometry(geometry.begin(), geometry.end());
route.SetSectionTimes(times);
route.SetTurnInstructions(turnsDir);
- route.SetTurnInstructionsGeometry(turnsGeom);
}
unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index, TCountryFileFn const & countryFileFn)
diff --git a/routing/route.cpp b/routing/route.cpp
index 37d37bff51..3695fa1bf5 100644
--- a/routing/route.cpp
+++ b/routing/route.cpp
@@ -1,4 +1,5 @@
-#include "routing/route.hpp"
+#include "route.hpp"
+#include "turns_generator.hpp"
#include "indexer/mercator.hpp"
@@ -42,7 +43,6 @@ void Route::Swap(Route & rhs)
swap(m_currentTime, rhs.m_currentTime);
swap(m_turns, rhs.m_turns);
swap(m_times, rhs.m_times);
- m_turnsGeom.swap(rhs.m_turnsGeom);
m_absentCountries.swap(rhs.m_absentCountries);
// m_pedestrianFollower.Swap(rhs.m_pedestrianFollower);
}
@@ -61,6 +61,27 @@ double Route::GetCurrentDistanceFromBeginMeters() const
MercatorBounds::DistanceOnEarth(m_poly.GetPoint(m_current.m_ind), m_current.m_pt));
}
+void Route::GetTurnsDistances(vector<double> & distances) const
+{
+ double mercatorDistance = 0;
+ distances.clear();
+ for (auto currentTurn = m_turns.begin(); currentTurn != m_turns.end(); ++currentTurn)
+ {
+ uint32_t formerTurnIndex = 0;
+ if (currentTurn != m_turns.begin())
+ formerTurnIndex = (currentTurn - 1)->m_index;
+
+ //TODO (ldragunov) Extract CalculateMercatorDistance higher to avoid including turns generator.
+ double const mercatorDistanceBetweenTurns =
+ turns::CalculateMercatorDistanceAlongPath(formerTurnIndex, currentTurn->m_index, m_poly.GetPoints());
+ mercatorDistance += mercatorDistanceBetweenTurns;
+
+ if (currentTurn->m_index == 0 || currentTurn->m_index == (m_poly.GetSize() - 1))
+ continue;
+ distances.push_back(mercatorDistance);
+ }
+}
+
double Route::GetCurrentDistanceToEndMeters() const
{
ASSERT(m_current.IsValid(), ());
diff --git a/routing/route.hpp b/routing/route.hpp
index a3f4df17ca..dd939e22ce 100644
--- a/routing/route.hpp
+++ b/routing/route.hpp
@@ -57,18 +57,13 @@ public:
swap(m_times, v);
}
- inline void SetTurnInstructionsGeometry(turns::TTurnsGeom & v)
- {
- swap(m_turnsGeom, v);
- }
-
uint32_t GetTotalTimeSec() const;
uint32_t GetCurrentTimeToEndSec() const;
string const & GetRouterId() const { return m_router; }
m2::PolylineD const & GetPoly() const { return m_poly; }
- turns::TTurnsGeom const & GetTurnsGeometry() const { return m_turnsGeom; }
TTurns const & GetTurns() const { return m_turns; }
+ void GetTurnsDistances(vector<double> & distances) const;
string const & GetName() const { return m_name; }
bool IsValid() const { return (m_poly.GetSize() > 1); }
@@ -147,8 +142,6 @@ private:
TTurns m_turns;
TTimes m_times;
- turns::TTurnsGeom m_turnsGeom;
-
/// Cached result iterator for last MoveIterator query.
mutable IterT m_current;
mutable double m_currentTime;
diff --git a/routing/routing_tests/turns_generator_test.cpp b/routing/routing_tests/turns_generator_test.cpp
index 23179a47af..5b8de984eb 100644
--- a/routing/routing_tests/turns_generator_test.cpp
+++ b/routing/routing_tests/turns_generator_test.cpp
@@ -170,73 +170,6 @@ UNIT_TEST(TestFixupTurns)
TEST_EQUAL(turnsDir3, expectedTurnDir3, ());
}
-UNIT_TEST(TestCalculateTurnGeometry)
-{
- double constexpr kHalfSquareSideMeters = 10.;
- double constexpr kSquareSideMeters = 2 * kHalfSquareSideMeters;
- double const kErrorMeters = 1.;
- m2::PointD const kSquareCenterLonLat = {0., 0.};
- m2::RectD const kSquareNearZero = MercatorBounds::MetresToXY(kSquareCenterLonLat.x,
- kSquareCenterLonLat.y, kHalfSquareSideMeters);
-
- // Empty vectors
- vector<m2::PointD> const points1;
- Route::TTurns const turnsDir1;
- TTurnsGeom turnsGeom1;
- CalculateTurnGeometry(points1, turnsDir1, turnsGeom1);
- TEST(turnsGeom1.empty(), ());
-
- // A turn is in the middle of a very short route.
- vector<m2::PointD> const points2 = {
- { kSquareNearZero.minX(), kSquareNearZero.minY() },
- { kSquareNearZero.maxX(), kSquareNearZero.maxY() },
- { kSquareNearZero.minX(), kSquareNearZero.maxY() }
- };
- Route::TTurns const turnsDir2 = {{1, TurnDirection::TurnLeft},
- {2, TurnDirection::ReachedYourDestination}};
- TTurnsGeom turnsGeom2;
-
- CalculateTurnGeometry(points2, turnsDir2, turnsGeom2);
- TEST_EQUAL(turnsGeom2.size(), 1, ());
- TEST_EQUAL(turnsGeom2[0].m_indexInRoute, 1, ());
- TEST_EQUAL(turnsGeom2[0].m_turnIndex, 1, ());
- TEST_EQUAL(turnsGeom2[0].m_points.size(), 3, ());
- TEST_LESS(fabs(MercatorBounds::DistanceOnEarth(turnsGeom2[0].m_points[1],
- turnsGeom2[0].m_points[2]) - kSquareSideMeters),
- kErrorMeters, ());
-
- // Two turns. One is in the very beginnig of a short route and another one is at the end.
- // The first turn is located at point 0 and the second one at the point 3.
- // 1----->2
- // ^ |
- // | 4 |
- // | \ v
- // 0 3
- vector<m2::PointD> const points3 = {
- { kSquareNearZero.minX(), kSquareNearZero.minY() },
- { kSquareNearZero.minX(), kSquareNearZero.maxY() },
- { kSquareNearZero.maxX(), kSquareNearZero.maxY() },
- { kSquareNearZero.maxX(), kSquareNearZero.minY() },
- { kSquareCenterLonLat.x, kSquareCenterLonLat.y }
- };
- Route::TTurns const turnsDir3 = {{0, TurnDirection::GoStraight},
- {3, TurnDirection::TurnSharpRight},
- {4, TurnDirection::ReachedYourDestination}};
- TTurnsGeom turnsGeom3;
-
- CalculateTurnGeometry(points3, turnsDir3, turnsGeom3);
- TEST_EQUAL(turnsGeom3.size(), 1, ());
- TEST_EQUAL(turnsGeom3[0].m_indexInRoute, 3, ());
- TEST_EQUAL(turnsGeom3[0].m_turnIndex, 3, ());
- TEST_EQUAL(turnsGeom3[0].m_points.size(), 5, ());
- TEST_LESS(fabs(MercatorBounds::DistanceOnEarth(turnsGeom3[0].m_points[1],
- turnsGeom3[0].m_points[2]) - kSquareSideMeters),
- kErrorMeters, ());
- TEST_LESS(fabs(MercatorBounds::DistanceOnEarth(turnsGeom3[0].m_points[2],
- turnsGeom3[0].m_points[3]) - kSquareSideMeters),
- kErrorMeters, ());
-}
-
UNIT_TEST(TestIsLaneWayConformedTurnDirection)
{
TEST(IsLaneWayConformedTurnDirection(LaneWay::Left, TurnDirection::TurnLeft), ());
diff --git a/routing/turns.cpp b/routing/turns.cpp
index 28b9001b38..41761b7281 100644
--- a/routing/turns.cpp
+++ b/routing/turns.cpp
@@ -213,16 +213,6 @@ bool ParseLanes(string lanesString, vector<SingleLaneInfo> & lanes)
return true;
}
-string DebugPrint(TurnGeom const & turnGeom)
-{
- stringstream out;
- out << "[ TurnGeom: m_indexInRoute = " << turnGeom.m_indexInRoute
- << ", m_turnIndex = " << turnGeom.m_turnIndex
- << ", m_mercatorDistance = " << turnGeom.m_mercatorDistance
- << " ]" << endl;
- return out.str();
-}
-
string DebugPrint(LaneWay const l)
{
auto const it = find_if(g_laneWayNames.begin(), g_laneWayNames.end(),
diff --git a/routing/turns.hpp b/routing/turns.hpp
index 4f0073050e..f842303fac 100644
--- a/routing/turns.hpp
+++ b/routing/turns.hpp
@@ -14,8 +14,7 @@ namespace routing
namespace turns
{
/// @todo(vbykoianko) It's a good idea to gather all the turns information into one entity.
-/// For the time being several separate entities reflect the turn information. Like Route::TTurns or
-/// turns::TTurnsGeom
+/// For the time being several separate entities reflect the turn information. Like Route::TTurns
/*!
* \warning The order of values below shall not be changed.
@@ -89,24 +88,6 @@ enum class LaneWay
string DebugPrint(LaneWay const l);
-struct TurnGeom
-{
- TurnGeom(uint32_t indexInRoute, uint32_t turnIndex, double mercatorDistance,
- vector<m2::PointD>::const_iterator b, vector<m2::PointD>::const_iterator e)
- : m_indexInRoute(indexInRoute), m_turnIndex(turnIndex),
- m_mercatorDistance(mercatorDistance), m_points(b, e)
- {
- }
-
- uint32_t m_indexInRoute;
- uint32_t m_turnIndex;
- double m_mercatorDistance;
- vector<m2::PointD> m_points;
-};
-
-string DebugPrint(TurnGeom const & turnGeom);
-
-typedef vector<TurnGeom> TTurnsGeom;
typedef vector<LaneWay> TSingleLane;
struct SingleLaneInfo
diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp
index ac205460a0..6e351fda5c 100644
--- a/routing/turns_generator.cpp
+++ b/routing/turns_generator.cpp
@@ -521,48 +521,6 @@ double CalculateMercatorDistanceAlongPath(uint32_t startPointIndex, uint32_t end
return mercatorDistanceBetweenTurns;
}
-void CalculateTurnGeometry(vector<m2::PointD> const & points, Route::TTurns const & turnsDir,
- TTurnsGeom & turnsGeom)
-{
- size_t const kNumPoints = points.size();
- // "Pivot point" is a point of bifurcation (a point of a turn).
- // kNumPointsBeforePivot is number of points before the pivot point.
- uint32_t const kNumPointsBeforePivot = 10;
- // kNumPointsAfterPivot is a number of points follows by the pivot point.
- // kNumPointsAfterPivot is greater because there are half body and the arrow after the pivot point
- uint32_t constexpr kNumPointsAfterPivot = kNumPointsBeforePivot + 10;
-
- /// mercatorDistance is a distance in mercator units from the start of the route.
- double mercatorDistance = 0;
-
- auto const turnsDirEnd = turnsDir.end();
- for (auto currentTurn = turnsDir.begin(); currentTurn != turnsDirEnd; ++currentTurn)
- {
- ASSERT_LESS(currentTurn->m_index, kNumPoints, ());
-
- uint32_t formerTurnIndex = 0;
- if (currentTurn != turnsDir.begin())
- formerTurnIndex = (currentTurn - 1)->m_index;
-
- double const mercatorDistanceBetweenTurns =
- CalculateMercatorDistanceAlongPath(formerTurnIndex, currentTurn->m_index, points);
- mercatorDistance += mercatorDistanceBetweenTurns;
-
- if (currentTurn->m_index == 0 || currentTurn->m_index == (kNumPoints - 1))
- continue;
-
- uint32_t const fromIndex = (currentTurn->m_index <= kNumPointsBeforePivot) ?
- 0 : currentTurn->m_index - kNumPointsBeforePivot;
- uint32_t const nextPossibleIndex = currentTurn->m_index + kNumPointsAfterPivot;
- uint32_t const toIndex = min(static_cast<uint32_t>(kNumPoints), nextPossibleIndex);
- uint32_t const turnIndex = min(currentTurn->m_index, kNumPointsBeforePivot);
-
- turnsGeom.emplace_back(currentTurn->m_index, turnIndex, mercatorDistance, points.begin() + fromIndex,
- points.begin() + toIndex);
- }
- return;
-}
-
void FixupTurns(vector<m2::PointD> const & points, Route::TTurns & turnsDir)
{
double const kMergeDistMeters = 30.0;
diff --git a/routing/turns_generator.hpp b/routing/turns_generator.hpp
index f9ff5e8939..c9c250ea26 100644
--- a/routing/turns_generator.hpp
+++ b/routing/turns_generator.hpp
@@ -64,12 +64,6 @@ double CalculateMercatorDistanceAlongPath(uint32_t startPointIndex, uint32_t end
vector<m2::PointD> const & points);
/*!
- * \brief Returns geometry for all the turns. It means that for every turn CalculateTurnGeometry
- * calculates a sequence of points.
- */
-void CalculateTurnGeometry(vector<m2::PointD> const & points, Route::TTurns const & turnsDir,
- TTurnsGeom & turnsGeom);
-/*!
* \brief Selects lanes which are recommended for an end user.
*/
void SelectRecommendedLanes(Route::TTurns & turnsDir);