Desktop frontend for routing strategies completed
Also added the UI for adjusting avoid routing options for desktop
This commit is contained in:
parent
6a4cb5c168
commit
6406c9da1b
6 changed files with 97 additions and 8 deletions
|
@ -3,6 +3,7 @@
|
|||
#include "map/framework.hpp"
|
||||
|
||||
#include "routing/router.hpp"
|
||||
#include "routing/edge_estimator.hpp"
|
||||
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
|
@ -26,12 +27,26 @@ std::string const kUseCachedRoutingSettings = "use_cached_settings_desktop";
|
|||
std::string const kStartCoordsCachedSettings = "start_coords_desktop";
|
||||
std::string const kFinishCoordsCachedSettings = "finish_coords_desktop";
|
||||
std::string const kRouterTypeCachedSettings = "router_type_desktop";
|
||||
std::string const kRouterStrategyCachedSettings = "router_strategy";
|
||||
std::string const kAvoidRoutingOptionSettings = "avoid_routing_options_car";
|
||||
|
||||
int constexpr DefaultRouterIndex()
|
||||
{
|
||||
// Car router by default.
|
||||
return static_cast<int>(routing::RouterType::Vehicle);
|
||||
}
|
||||
|
||||
int constexpr DefaultStrategyIndex()
|
||||
{
|
||||
// Routing strategy by default
|
||||
return static_cast<int>(routing::EdgeEstimator::Strategy::Fastest);
|
||||
}
|
||||
|
||||
int constexpr DefaultAvoidOptionIndex()
|
||||
{
|
||||
// Avoid routing option by default
|
||||
return static_cast<int>(routing::RoutingOptions::Road::Usual);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
|
@ -135,6 +150,20 @@ RoutingSettings::RoutingSettings(QWidget * parent, Framework & framework)
|
|||
m_routerType->insertItem(static_cast<int>(RouterType::Transit), "transit");
|
||||
form->addRow("Choose router:", m_routerType);
|
||||
|
||||
m_routerStrategy = new QComboBox(frame);
|
||||
m_routerStrategy->insertItem(static_cast<int>(EdgeEstimator::Strategy::Fastest), "fastest");
|
||||
m_routerStrategy->insertItem(static_cast<int>(EdgeEstimator::Strategy::Shortest), "shortest");
|
||||
m_routerStrategy->insertItem(static_cast<int>(EdgeEstimator::Strategy::FewerTurns), "fewer turns");
|
||||
form->addRow("Choose strategy:", m_routerStrategy);
|
||||
|
||||
m_avoidRoutingOptions = new QComboBox(frame);
|
||||
m_avoidRoutingOptions->insertItem(static_cast<int>(RoutingOptions::Road::Dirty), "dirty");
|
||||
m_avoidRoutingOptions->insertItem(static_cast<int>(RoutingOptions::Road::Ferry), "ferry");
|
||||
m_avoidRoutingOptions->insertItem(static_cast<int>(RoutingOptions::Road::Motorway), "motorway");
|
||||
m_avoidRoutingOptions->insertItem(static_cast<int>(RoutingOptions::Road::Toll), "toll");
|
||||
m_avoidRoutingOptions->insertItem(static_cast<int>(RoutingOptions::Road::Usual), "usual");
|
||||
form->addRow("Choose avoid option:", m_avoidRoutingOptions);
|
||||
|
||||
m_showTurnsCheckbox = new QCheckBox({}, frame);
|
||||
form->addRow("Show turns:", m_showTurnsCheckbox);
|
||||
|
||||
|
@ -191,6 +220,8 @@ bool RoutingSettings::SaveSettings()
|
|||
settings::Set(kUseDebugGuideSettings, m_useDebugGuideCheckbox->isChecked());
|
||||
settings::Set(kUseCachedRoutingSettings, m_saveSessionCheckbox->isChecked());
|
||||
settings::Set(kRouterTypeCachedSettings, m_routerType->currentIndex());
|
||||
settings::Set(kRouterStrategyCachedSettings, m_routerStrategy->currentIndex());
|
||||
settings::Set(kAvoidRoutingOptionSettings, m_avoidRoutingOptions->currentIndex());
|
||||
return ValidateAndSaveCoordsFromInput();
|
||||
}
|
||||
|
||||
|
@ -208,6 +239,14 @@ void RoutingSettings::LoadSettings()
|
|||
settings::TryGet(kRouterTypeCachedSettings, routerType);
|
||||
m_routerType->setCurrentIndex(routerType);
|
||||
|
||||
int routerStrategy = DefaultStrategyIndex();
|
||||
settings::TryGet(kRouterStrategyCachedSettings, routerStrategy);
|
||||
m_routerStrategy->setCurrentIndex(routerStrategy);
|
||||
|
||||
int avoidRoutingOption = DefaultAvoidOptionIndex();
|
||||
settings::TryGet(kAvoidRoutingOptionSettings, avoidRoutingOption);
|
||||
m_avoidRoutingOptions->setCurrentIndex(avoidRoutingOption);
|
||||
|
||||
bool showTurns = false;
|
||||
settings::TryGet(kShowTurnsSettings, showTurns);
|
||||
m_showTurnsCheckbox->setChecked(showTurns);
|
||||
|
|
|
@ -40,6 +40,8 @@ private:
|
|||
QLineEdit * m_finishInput;
|
||||
|
||||
QComboBox * m_routerType;
|
||||
QComboBox * m_routerStrategy;
|
||||
QComboBox * m_avoidRoutingOptions;
|
||||
QCheckBox * m_showTurnsCheckbox;
|
||||
QCheckBox * m_useDebugGuideCheckbox;
|
||||
QCheckBox * m_saveSessionCheckbox;
|
||||
|
|
|
@ -348,7 +348,8 @@ void AsyncRouter::CalculateRoute()
|
|||
RoutingOptions const routingOptions = RoutingOptions::LoadCarOptionsFromSettings();
|
||||
router->SetEstimatorOptions(routingOptions.GetOptions());
|
||||
|
||||
router->SetEstimatorStrategy(EdgeEstimator::Strategy::Fastest);
|
||||
EdgeEstimator::Strategy routingStrategy = EdgeEstimator::LoadRoutingStrategyFromSettings();
|
||||
router->SetEstimatorStrategy(routingStrategy);
|
||||
|
||||
// Run basic request.
|
||||
code = router->CalculateRoute(checkpoints, startDirection, adjustToPrevRoute,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "routing/edge_estimator.hpp"
|
||||
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
#include "routing/geometry.hpp"
|
||||
#include "routing/latlon_with_altitude.hpp"
|
||||
#include "routing/routing_exceptions.hpp"
|
||||
|
@ -123,6 +125,19 @@ double GetCarClimbPenalty(EdgeEstimator::Purpose /* purpose */, double /* tangen
|
|||
}
|
||||
|
||||
// EdgeEstimator -----------------------------------------------------------------------------------
|
||||
|
||||
string const EdgeEstimator::kRoutingStrategySettings = "router_strategy";
|
||||
|
||||
//static
|
||||
EdgeEstimator::Strategy EdgeEstimator::LoadRoutingStrategyFromSettings()
|
||||
{
|
||||
uint32_t mode = 0;
|
||||
if (!settings::Get(kRoutingStrategySettings, mode))
|
||||
mode = 0;
|
||||
|
||||
return (EdgeEstimator::Strategy) mode;
|
||||
}
|
||||
|
||||
EdgeEstimator::EdgeEstimator(double maxWeightSpeedKMpH, SpeedKMpH const & offroadSpeedKMpH,
|
||||
DataSource * /*dataSourcePtr*/, std::shared_ptr<NumMwmIds> /*numMwmIds*/)
|
||||
: m_maxWeightSpeedMpS(KmphToMps(maxWeightSpeedKMpH))
|
||||
|
@ -247,7 +262,17 @@ public:
|
|||
}
|
||||
|
||||
// EdgeEstimator overrides:
|
||||
double GetUTurnPenalty(Purpose /* purpose */) const override { return 0.0 /* seconds */; }
|
||||
double GetUTurnPenalty(Purpose purpose) const override
|
||||
{
|
||||
if (purpose == EdgeEstimator::Purpose::Weight)
|
||||
{
|
||||
if (this->GetStrategy() == EdgeEstimator::Strategy::FewerTurns)
|
||||
{
|
||||
return 24 * 60 * 60;
|
||||
}
|
||||
}
|
||||
return 0.0 /* seconds */;
|
||||
}
|
||||
double GetTurnPenalty(Purpose purpose) const override
|
||||
{
|
||||
if (purpose == EdgeEstimator::Purpose::Weight)
|
||||
|
@ -297,7 +322,17 @@ public:
|
|||
}
|
||||
|
||||
// EdgeEstimator overrides:
|
||||
double GetUTurnPenalty(Purpose /* purpose */) const override { return 20.0 /* seconds */; }
|
||||
double GetUTurnPenalty(Purpose purpose) const override
|
||||
{
|
||||
if (purpose == EdgeEstimator::Purpose::Weight)
|
||||
{
|
||||
if (this->GetStrategy() == EdgeEstimator::Strategy::FewerTurns)
|
||||
{
|
||||
return 24 * 60 * 60;
|
||||
}
|
||||
}
|
||||
return 20.0 /* seconds */;
|
||||
}
|
||||
double GetTurnPenalty(Purpose purpose) const override
|
||||
{
|
||||
if (purpose == EdgeEstimator::Purpose::Weight)
|
||||
|
@ -307,7 +342,7 @@ public:
|
|||
return 24 * 60 * 60;
|
||||
}
|
||||
}
|
||||
return 10.0;
|
||||
return 0.0;
|
||||
}
|
||||
// Based on: https://confluence.mail.ru/display/MAPSME/Ferries
|
||||
double GetFerryLandingPenalty(Purpose purpose) const override
|
||||
|
@ -347,7 +382,7 @@ public:
|
|||
|
||||
// EdgeEstimator overrides:
|
||||
double CalcSegmentWeight(Segment const & segment, RoadGeometry const & road, Purpose purpose) const override;
|
||||
double GetUTurnPenalty(Purpose /* purpose */) const override;
|
||||
double GetUTurnPenalty(Purpose purpose) const override;
|
||||
double GetTurnPenalty(Purpose purpose) const override;
|
||||
double GetFerryLandingPenalty(Purpose purpose) const override;
|
||||
|
||||
|
@ -363,8 +398,16 @@ CarEstimator::CarEstimator(DataSource * dataSourcePtr, std::shared_ptr<NumMwmIds
|
|||
{
|
||||
}
|
||||
|
||||
double CarEstimator::GetUTurnPenalty(Purpose /* purpose */) const
|
||||
double CarEstimator::GetUTurnPenalty(Purpose purpose) const
|
||||
{
|
||||
if (purpose == EdgeEstimator::Purpose::Weight)
|
||||
{
|
||||
if (this->GetStrategy() == EdgeEstimator::Strategy::FewerTurns)
|
||||
{
|
||||
return 24 * 60 * 60;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds 2 minutes penalty for U-turn. The value is quite arbitrary
|
||||
// and needs to be properly selected after a number of real-world
|
||||
// experiments.
|
||||
|
@ -380,7 +423,7 @@ double CarEstimator::GetTurnPenalty(Purpose purpose) const
|
|||
return 24 * 60 * 60;
|
||||
}
|
||||
}
|
||||
return 60;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double CarEstimator::GetFerryLandingPenalty(Purpose purpose) const
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
ETA
|
||||
};
|
||||
|
||||
static std::string const kRoutingStrategySettings;
|
||||
|
||||
enum class Strategy
|
||||
{
|
||||
Fastest,
|
||||
|
@ -40,6 +42,8 @@ public:
|
|||
DataSource * dataSourcePtr = nullptr, std::shared_ptr<NumMwmIds> numMwmIds = nullptr);
|
||||
virtual ~EdgeEstimator() = default;
|
||||
|
||||
static Strategy LoadRoutingStrategyFromSettings();
|
||||
|
||||
double CalcHeuristic(ms::LatLon const & from, ms::LatLon const & to) const;
|
||||
// Estimates time in seconds it takes to go from point |from| to point |to| along a leap (fake)
|
||||
// edge |from|-|to| using real features.
|
||||
|
|
|
@ -596,7 +596,7 @@ bool IndexGraph::IsTurn(Segment const & u, Segment const & v) const
|
|||
//convert to degree value
|
||||
angle = angle * 180 / 3.141592;
|
||||
|
||||
if (abs(angle) >= 45)
|
||||
if (abs(angle) >= 30)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
Reference in a new issue