forked from organicmaps/organicmaps
Merge pull request #6378 from bykoianko/master-segment-based-Route-stage-3
Generating segments in case of pedestrian routing.
This commit is contained in:
commit
6b813fa9fc
7 changed files with 49 additions and 13 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "routing/directions_engine.hpp"
|
||||
#include "routing/loaded_path_segment.hpp"
|
||||
#include "routing/num_mwm_id.hpp"
|
||||
#include "routing/turn_candidate.hpp"
|
||||
|
||||
#include "indexer/index.hpp"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "routing/pedestrian_directions.hpp"
|
||||
|
||||
#include "routing/road_graph.hpp"
|
||||
#include "routing/routing_helpers.hpp"
|
||||
|
||||
#include "indexer/classificator.hpp"
|
||||
#include "indexer/feature.hpp"
|
||||
|
@ -9,6 +10,8 @@
|
|||
#include "base/assert.hpp"
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace
|
||||
{
|
||||
bool HasType(uint32_t type, feature::TypesHolder const & types)
|
||||
|
@ -26,10 +29,11 @@ bool HasType(uint32_t type, feature::TypesHolder const & types)
|
|||
namespace routing
|
||||
{
|
||||
|
||||
PedestrianDirectionsEngine::PedestrianDirectionsEngine()
|
||||
PedestrianDirectionsEngine::PedestrianDirectionsEngine(std::shared_ptr<NumMwmIds> numMwmIds)
|
||||
: m_typeSteps(classif().GetTypeByPath({"highway", "steps"}))
|
||||
, m_typeLiftGate(classif().GetTypeByPath({"barrier", "lift_gate"}))
|
||||
, m_typeGate(classif().GetTypeByPath({"barrier", "gate"}))
|
||||
, m_numMwmIds(std::move(numMwmIds))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -38,11 +42,12 @@ void PedestrianDirectionsEngine::Generate(RoadGraphBase const & graph,
|
|||
my::Cancellable const & cancellable,
|
||||
Route::TTimes & times, Route::TTurns & turns,
|
||||
vector<Junction> & routeGeometry,
|
||||
vector<Segment> & /* segments */)
|
||||
vector<Segment> & segments)
|
||||
{
|
||||
times.clear();
|
||||
turns.clear();
|
||||
routeGeometry.clear();
|
||||
segments.clear();
|
||||
|
||||
if (path.size() <= 1)
|
||||
return;
|
||||
|
@ -59,6 +64,11 @@ void PedestrianDirectionsEngine::Generate(RoadGraphBase const & graph,
|
|||
}
|
||||
|
||||
CalculateTurns(graph, routeEdges, turns, cancellable);
|
||||
|
||||
segments.reserve(routeEdges.size());
|
||||
for (Edge const & e : routeEdges)
|
||||
segments.push_back(ConvertEdgeToSegment(*m_numMwmIds, e));
|
||||
|
||||
routeGeometry = path;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "routing/directions_engine.hpp"
|
||||
#include "routing/num_mwm_id.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace routing
|
||||
{
|
||||
|
@ -8,7 +11,7 @@ namespace routing
|
|||
class PedestrianDirectionsEngine : public IDirectionsEngine
|
||||
{
|
||||
public:
|
||||
PedestrianDirectionsEngine();
|
||||
PedestrianDirectionsEngine(std::shared_ptr<NumMwmIds> numMwmIds);
|
||||
|
||||
// IDirectionsEngine override:
|
||||
void Generate(RoadGraphBase const & graph, vector<Junction> const & path,
|
||||
|
@ -22,6 +25,7 @@ private:
|
|||
uint32_t const m_typeSteps;
|
||||
uint32_t const m_typeLiftGate;
|
||||
uint32_t const m_typeGate;
|
||||
std::shared_ptr<NumMwmIds> const m_numMwmIds;
|
||||
};
|
||||
|
||||
} // namespace routing
|
||||
|
|
|
@ -24,11 +24,13 @@
|
|||
|
||||
#include "geometry/distance.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
#include "std/algorithm.hpp"
|
||||
#include "std/queue.hpp"
|
||||
#include "std/set.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
#include <utility>
|
||||
|
||||
using platform::CountryFile;
|
||||
using platform::LocalCountryFile;
|
||||
|
@ -223,11 +225,14 @@ IRouter::ResultCode RoadGraphRouter::CalculateRoute(m2::PointD const & startPoin
|
|||
return IRouter::RouteNotFound;
|
||||
}
|
||||
|
||||
unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index, TCountryFileFn const & countryFileFn)
|
||||
unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index,
|
||||
TCountryFileFn const & countryFileFn,
|
||||
shared_ptr<NumMwmIds> numMwmIds)
|
||||
{
|
||||
unique_ptr<VehicleModelFactory> vehicleModelFactory(new PedestrianModelFactory());
|
||||
unique_ptr<IRoutingAlgorithm> algorithm(new AStarRoutingAlgorithm());
|
||||
unique_ptr<IDirectionsEngine> directionsEngine(new PedestrianDirectionsEngine());
|
||||
unique_ptr<IDirectionsEngine> directionsEngine(
|
||||
new PedestrianDirectionsEngine(std::move(numMwmIds)));
|
||||
unique_ptr<IRouter> router(new RoadGraphRouter(
|
||||
"astar-pedestrian", index, countryFileFn, IRoadGraph::Mode::IgnoreOnewayTag,
|
||||
move(vehicleModelFactory), move(algorithm), move(directionsEngine)));
|
||||
|
@ -236,11 +241,12 @@ unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index, TCountryFileFn co
|
|||
|
||||
unique_ptr<IRouter> CreatePedestrianAStarBidirectionalRouter(Index & index,
|
||||
TCountryFileFn const & countryFileFn,
|
||||
shared_ptr<NumMwmIds> /* numMwmIds */)
|
||||
shared_ptr<NumMwmIds> numMwmIds)
|
||||
{
|
||||
unique_ptr<VehicleModelFactory> vehicleModelFactory(new PedestrianModelFactory());
|
||||
unique_ptr<IRoutingAlgorithm> algorithm(new AStarBidirectionalRoutingAlgorithm());
|
||||
unique_ptr<IDirectionsEngine> directionsEngine(new PedestrianDirectionsEngine());
|
||||
unique_ptr<IDirectionsEngine> directionsEngine(
|
||||
new PedestrianDirectionsEngine(std::move(numMwmIds)));
|
||||
unique_ptr<IRouter> router(new RoadGraphRouter(
|
||||
"astar-bidirectional-pedestrian", index, countryFileFn, IRoadGraph::Mode::IgnoreOnewayTag,
|
||||
move(vehicleModelFactory), move(algorithm), move(directionsEngine)));
|
||||
|
|
|
@ -51,7 +51,9 @@ private:
|
|||
unique_ptr<IDirectionsEngine> const m_directionsEngine;
|
||||
};
|
||||
|
||||
unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index, TCountryFileFn const & countryFileFn);
|
||||
unique_ptr<IRouter> CreatePedestrianAStarRouter(Index & index,
|
||||
TCountryFileFn const & countryFileFn,
|
||||
shared_ptr<NumMwmIds> numMwmIds);
|
||||
unique_ptr<IRouter> CreatePedestrianAStarBidirectionalRouter(Index & index,
|
||||
TCountryFileFn const & countryFileFn,
|
||||
shared_ptr<NumMwmIds> /* numMwmIds */);
|
||||
|
|
|
@ -7,8 +7,12 @@
|
|||
|
||||
#include "routing_common/pedestrian_model.hpp"
|
||||
|
||||
#include "std/set.hpp"
|
||||
#include "std/string.hpp"
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -39,9 +43,10 @@ public:
|
|||
protected:
|
||||
// RoutingTest overrides:
|
||||
unique_ptr<routing::IDirectionsEngine> CreateDirectionsEngine(
|
||||
shared_ptr<routing::NumMwmIds> /* numMwmIds */) override
|
||||
shared_ptr<routing::NumMwmIds> numMwmIds) override
|
||||
{
|
||||
unique_ptr<routing::IDirectionsEngine> engine(new routing::PedestrianDirectionsEngine());
|
||||
unique_ptr<routing::IDirectionsEngine> engine(
|
||||
new routing::PedestrianDirectionsEngine(move(numMwmIds)));
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
#include "traffic/traffic_info.hpp"
|
||||
|
||||
#include "base/stl_helpers.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace routing
|
||||
{
|
||||
using namespace traffic;
|
||||
|
@ -31,6 +35,7 @@ void ReconstructRoute(IDirectionsEngine & engine, RoadGraphBase const & graph,
|
|||
Route::TStreets streetNames;
|
||||
vector<Segment> segments;
|
||||
engine.Generate(graph, path, cancellable, times, turnsDir, junctions, segments);
|
||||
CHECK_EQUAL(segments.size() + 1, junctions.size(), ());
|
||||
|
||||
if (cancellable.IsCancelled())
|
||||
return;
|
||||
|
@ -42,6 +47,9 @@ void ReconstructRoute(IDirectionsEngine & engine, RoadGraphBase const & graph,
|
|||
return;
|
||||
}
|
||||
|
||||
CHECK(std::is_sorted(times.cbegin(), times.cend(), my::LessBy(&Route::TTimeItem::first)), ());
|
||||
CHECK(std::is_sorted(turnsDir.cbegin(), turnsDir.cend(), my::LessBy(&turns::TurnItem::m_index)), ());
|
||||
|
||||
// @TODO(bykoianko) If the start and the finish of a route lies on the same road segment
|
||||
// engine->Generate() fills with empty vectors |times|, |turnsDir|, |junctions| and |segments|.
|
||||
// It's not correct and should be fixed. It's necessary to work corrrectly with such routes.
|
||||
|
|
Loading…
Add table
Reference in a new issue