OSRM plugin nearest finding distance restriction.

This commit is contained in:
Lev Dragunov 2016-01-19 16:19:20 +03:00
parent e3d97cc6c9
commit 9a5ea7a51f
2 changed files with 19 additions and 6 deletions

View file

@ -29,6 +29,8 @@
#include <string>
#include <vector>
double constexpr kMaxDistanceToFindMeters = 1000.0;
template <class DataFacadeT> class MapsMePlugin final : public BasePlugin
{
class GetByPoint
@ -118,16 +120,21 @@ public:
for (const auto i : osrm::irange<std::size_t>(0, route_parameters.coordinates.size()))
{
std::vector<PhantomNode> phantom_node_vector;
std::vector<std::pair<PhantomNode, double>> phantom_node_vector;
//FixedPointCoordinate &coordinate = route_parameters.coordinates[i];
if (m_facade->IncrementalFindPhantomNodeForCoordinate(route_parameters.coordinates[i],
phantom_node_vector, 1))
if (m_facade->IncrementalFindPhantomNodeForCoordinateWithMaxDistance(route_parameters.coordinates[i],
phantom_node_vector, kMaxDistanceToFindMeters, 0, 2))
{
BOOST_ASSERT(!phantom_node_vector.empty());
phantom_node_pair_list[i].first = phantom_node_vector.front();
// Don't know why, but distance may be higher that maxDistance.
if (phantom_node_vector.front().second > kMaxDistanceToFindMeters)
continue;
phantom_node_pair_list[i].first = phantom_node_vector.front().first;
if (phantom_node_vector.size() > 1)
{
phantom_node_pair_list[i].second = phantom_node_vector.back();
if (phantom_node_vector.back().second > kMaxDistanceToFindMeters)
continue;
phantom_node_pair_list[i].second = phantom_node_vector.back().first;
}
}
}

View file

@ -22,6 +22,12 @@ UNIT_TEST(OnlineRussiaNorthToSouthTest)
{"Russia_Central", "Russia_Southern", "Russia_Northwestern"}, routerComponents);
}
UNIT_TEST(OnlineRoadToSeaCenterTest)
{
integration::IRouterComponents & routerComponents = integration::GetOsrmComponents();
TestOnlineCrosses({61.76, 34.45}, {42.25,30.10}, {}, routerComponents);
}
UNIT_TEST(OnlineEuropeTestNurnbergToMoscow)
{
integration::IRouterComponents & routerComponents = integration::GetOsrmComponents();
@ -39,7 +45,7 @@ UNIT_TEST(OnlineAmericanTestOttawaToWashington)
UNIT_TEST(OnlineAsiaPhuketToPnompen)
{
integration::IRouterComponents & routerComponents = integration::GetOsrmComponents();
TestOnlineCrosses({7.90, 98.23}, {11.56, 104.86},
TestOnlineCrosses({7.89, 98.30}, {11.56, 104.86},
{"Thailand", "Cambodia"}, routerComponents);
}