[traffxml] Add router-based decoder, still crude, ugly and buggy

To use it, redefine DefaultTraffDecoder in traffxml/traff_decoder.hpp

Signed-off-by: mvglasow <michael -at- vonglasow.com>
This commit is contained in:
mvglasow
2025-05-24 21:08:58 +03:00
parent bd178932c1
commit 9afb28aaa1
7 changed files with 474 additions and 10 deletions

View File

@@ -276,6 +276,40 @@ IndexRouter::IndexRouter(VehicleType vehicleType, bool loadAltitudes,
CHECK(m_directionsEngine, ());
}
IndexRouter::IndexRouter(VehicleType vehicleType, bool loadAltitudes,
CountryParentNameGetterFn const & countryParentNameGetterFn,
TCountryFileFn const & countryFileFn, CountryRectFn const & countryRectFn,
shared_ptr<NumMwmIds> numMwmIds, unique_ptr<m4::Tree<NumMwmId>> numMwmTree,
DataSource & dataSource)
: m_vehicleType(vehicleType)
, m_loadAltitudes(loadAltitudes)
, m_name("astar-bidirectional-" + ToString(m_vehicleType))
, m_dataSource(dataSource, numMwmIds)
, m_vehicleModelFactory(CreateVehicleModelFactory(m_vehicleType, countryParentNameGetterFn))
, m_countryFileFn(countryFileFn)
, m_countryRectFn(countryRectFn)
, m_numMwmIds(std::move(numMwmIds))
, m_numMwmTree(std::move(numMwmTree))
, m_trafficStash(nullptr)
, m_roadGraph(m_dataSource,
vehicleType == VehicleType::Pedestrian || vehicleType == VehicleType::Transit
? IRoadGraph::Mode::IgnoreOnewayTag
: IRoadGraph::Mode::ObeyOnewayTag,
m_vehicleModelFactory)
, m_estimator(EdgeEstimator::Create(
m_vehicleType, CalcMaxSpeed(*m_numMwmIds, *m_vehicleModelFactory, m_vehicleType),
CalcOffroadSpeed(*m_vehicleModelFactory), m_trafficStash,
&dataSource, m_numMwmIds))
, m_directionsEngine(CreateDirectionsEngine(m_vehicleType, m_numMwmIds, m_dataSource))
, m_countryParentNameGetterFn(countryParentNameGetterFn)
{
CHECK(!m_name.empty(), ());
CHECK(m_numMwmIds, ());
CHECK(m_numMwmTree, ());
CHECK(m_estimator, ());
CHECK(m_directionsEngine, ());
}
unique_ptr<WorldGraph> IndexRouter::MakeSingleMwmWorldGraph()
{
auto worldGraph = MakeWorldGraph();

View File

@@ -65,6 +65,23 @@ public:
m2::PointD const m_direction;
};
/**
* @brief Creates a new `IndexRouter` instance.
*
* This is the constructor intended for normal routing. It requires a `TrafficCache` argument,
* from which it may create a traffic stash so the traffic situation can be considered for the
* route, depending on the vehicle type.
*
* @param vehicleType The vehichle type
* @param loadAltitudes Whether to load altitudes
* @param countryParentNameGetterFn Function which converts a country name into the name of its parent country)
* @param countryFileFn Function which converts a pointer to its country name
* @param countryRectFn Function which returns the rect for a country
* @param numMwmIds
* @param numMwmTree
* @param trafficCache The traffic cache (used only if `vehicleType` is `VehicleType::Car`)
* @param dataSource The MWM data source
*/
IndexRouter(VehicleType vehicleType, bool loadAltitudes,
CountryParentNameGetterFn const & countryParentNameGetterFn,
TCountryFileFn const & countryFileFn, CountryRectFn const & countryRectFn,
@@ -89,6 +106,29 @@ public:
VehicleType GetVehicleType() const { return m_vehicleType; }
protected:
/**
* @brief Creates a new `IndexRouter` instance.
*
* This constructor is intended for use by the TraFF decoder, not for normal routing. It lacks the
* `TrafficCache` argument and never creates a traffic stash. This creates a router instance which
* ignores the traffic situation, regardless of the vehicle type.
*
* @param vehicleType The vehichle type
* @param loadAltitudes Whether to load altitudes
* @param countryParentNameGetterFn Function which converts a country name into the name of its parent country)
* @param countryFileFn Function which converts a pointer to its country name
* @param countryRectFn Function which returns the rect for a country
* @param numMwmIds
* @param numMwmTree
* @param dataSource The MWM data source
*/
IndexRouter(VehicleType vehicleType, bool loadAltitudes,
CountryParentNameGetterFn const & countryParentNameGetterFn,
TCountryFileFn const & countryFileFn, CountryRectFn const & countryRectFn,
std::shared_ptr<NumMwmIds> numMwmIds, std::unique_ptr<m4::Tree<NumMwmId>> numMwmTree,
DataSource & dataSource);
private:
RouterResultCode CalculateSubrouteJointsMode(IndexGraphStarter & starter,
RouterDelegate const & delegate,