forked from organicmaps/organicmaps
Merge pull request #1341 from gardster/online_routing_fixes
Online routing fixes
This commit is contained in:
commit
46988c460f
5 changed files with 31 additions and 7 deletions
|
@ -231,7 +231,10 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
|
|||
ResultCode const code = startMapping->GetError();
|
||||
if (code != NoError)
|
||||
{
|
||||
route.AddAbsentCountry(startMapping->GetCountryName());
|
||||
string const name = startMapping->GetCountryName();
|
||||
if (name.empty())
|
||||
return IRouter::ResultCode::StartPointNotFound;
|
||||
route.AddAbsentCountry(name);
|
||||
return code;
|
||||
}
|
||||
return IRouter::StartPointNotFound;
|
||||
|
@ -241,7 +244,10 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
|
|||
ResultCode const code = targetMapping->GetError();
|
||||
if (code != NoError)
|
||||
{
|
||||
route.AddAbsentCountry(targetMapping->GetCountryName());
|
||||
string const name = targetMapping->GetCountryName();
|
||||
if (name.empty())
|
||||
return IRouter::EndPointNotFound;
|
||||
route.AddAbsentCountry(name);
|
||||
return code;
|
||||
}
|
||||
return IRouter::EndPointNotFound;
|
||||
|
|
|
@ -42,6 +42,11 @@ void Route::Swap(Route & rhs)
|
|||
m_absentCountries.swap(rhs.m_absentCountries);
|
||||
}
|
||||
|
||||
void Route::AddAbsentCountry(string const & name)
|
||||
{
|
||||
if (!name.empty()) m_absentCountries.insert(name);
|
||||
}
|
||||
|
||||
double Route::GetTotalDistanceMeters() const
|
||||
{
|
||||
return m_poly.GetTotalDistanceM();
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
bool IsCurrentOnEnd() const;
|
||||
|
||||
/// Add country name if we have no country filename to make route
|
||||
void AddAbsentCountry(string const & name) { m_absentCountries.insert(name); }
|
||||
void AddAbsentCountry(string const & name);
|
||||
|
||||
/// Get absent file list of a routing files for shortest path finding
|
||||
set<string> const & GetAbsentCountries() const { return m_absentCountries; }
|
||||
|
|
|
@ -8,8 +8,13 @@ namespace
|
|||
UNIT_TEST(OnlineCrossFetcherSmokeTest)
|
||||
{
|
||||
integration::IRouterComponents & routerComponents = integration::GetOsrmComponents();
|
||||
TestOnlineFetcher({61.76, 34.45}, {45.07, 38.94},
|
||||
{"Russia_Central", "Russia_Southern", "Russia_Northwestern"}, routerComponents);
|
||||
TestOnlineFetcher(
|
||||
{61.76, 34.45}, {45.07, 38.94},
|
||||
{"Russia_Central", "Russia_Central", "Russia_Central", "Russia_Central", "Russia_Central",
|
||||
"Russia_Central", "Russia_Central", "Russia_Central", "Russia_Central", "Russia_Central",
|
||||
"Russia_Central", "Russia_Central", "Russia_Central", "Russia_Central", "Russia_Southern",
|
||||
"Russia_Southern", "Russia_Northwestern", "Russia_Northwestern"},
|
||||
routerComponents);
|
||||
}
|
||||
|
||||
UNIT_TEST(OnlineRussiaNorthToSouthTest)
|
||||
|
|
|
@ -301,13 +301,21 @@ namespace integration
|
|||
routing::OnlineCrossFetcher fetcher(OSRM_ONLINE_SERVER_URL, startPoint, finalPoint);
|
||||
fetcher.Do();
|
||||
vector<m2::PointD> const & points = fetcher.GetMwmPoints();
|
||||
TEST_EQUAL(points.size(), expected.size(), ());
|
||||
set<string> foundMwms;
|
||||
|
||||
// Start/stop mwm workaround. Remove after borders migration.
|
||||
foundMwms.insert(routerComponents.GetCountryInfoGetter().GetRegionFile(
|
||||
MercatorBounds::FromLatLon(startPoint)));
|
||||
foundMwms.insert(routerComponents.GetCountryInfoGetter().GetRegionFile(
|
||||
MercatorBounds::FromLatLon(finalPoint)));
|
||||
|
||||
for (m2::PointD const & point : points)
|
||||
{
|
||||
string const mwmName = routerComponents.GetCountryInfoGetter().GetRegionFile(point);
|
||||
TEST(find(expected.begin(), expected.end(), mwmName) != expected.end(),
|
||||
("Can't find ", mwmName));
|
||||
foundMwms.insert(mwmName);
|
||||
}
|
||||
TestOnlineFetcher(startPoint, finalPoint, expected, routerComponents);
|
||||
TEST_EQUAL(expected.size(), foundMwms.size(), ());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue