Review fixes.

This commit is contained in:
Vladimir Byko-Ianko 2016-08-09 14:52:35 +03:00
parent 6fadcd3ac0
commit 277b635d73
5 changed files with 72 additions and 48 deletions

View file

@ -47,6 +47,7 @@ double constexpr kSpeedStepsKMpH = 1.0;
double constexpr kSpeedPedestrianKMpH = 5.0;
double constexpr kSpeedFootwayKMpH = 7.0;
double constexpr kSpeedPlatformKMpH = 3.0;
double constexpr kSpeedPierKMpH = 7.0;
// Default
routing::VehicleModel::InitListT const g_bicycleLimitsDefault =
@ -607,8 +608,10 @@ void BicycleModel::Init()
m_noBicycleType = classif().GetTypeByPath({"hwtag", "nobicycle"});
m_bidirBicycleType = classif().GetTypeByPath({"hwtag", "bidir_bicycle"});
vector<AdditionalRoadTags> additionalTags = {
{ hwtagYesBicycle, m_maxSpeedKMpH }, {{"route", "ferry"}, m_maxSpeedKMpH}, {{"man_made", "pier"}, 7.0 },
vector<AdditionalRoadTags> const additionalTags = {
{hwtagYesBicycle, m_maxSpeedKMpH},
{{"route", "ferry"}, m_maxSpeedKMpH},
{{"man_made", "pier"}, kSpeedPierKMpH},
};
SetAdditionalRoadTypes(classif(), additionalTags);

View file

@ -8,26 +8,47 @@
namespace
{
double constexpr kSpeedMotorwayKMpH = 90.0;
double constexpr kSpeedMotorwayLinkKMpH = 75.0;
double constexpr kSpeedTrunkKMpH = 85.0;
double constexpr kSpeedTrunkLinkKMpH = 70.0;
double constexpr kSpeedPrimaryKMpH = 65.0;
double constexpr kSpeedPrimaryLinkKMpH = 60.0;
double constexpr kSpeedSecondaryKMpH = 55.0;
double constexpr kSpeedSecondaryLinkKMpH = 50.0;
double constexpr kSpeedTertiaryKMpH = 40.0;
double constexpr kSpeedTertiaryLinkKMpH = 30.0;
double constexpr kSpeedResidentialKMpH = 25.0;
double constexpr kSpeedPedestrianKMpH = 25.0;
double constexpr kSpeedUnclassifiedKMpH = 25.0;
double constexpr kSpeedServiceKMpH = 15.0;
double constexpr kSpeedLivingStreetKMpH = 10.0;
double constexpr kSpeedRoadKMpH = 10.0;
double constexpr kSpeedTrackKMpH = 5.0;
double constexpr kSpeedFerryMotorcarKMpH = 15.0;
double constexpr kSpeedFerryMotorcarVehicleKMpH = 15.0;
double constexpr kSpeedRailMotorcarVehicleKMpH = 25.0;
double constexpr kSpeedShuttleTrainKMpH = 25.0;
routing::VehicleModel::InitListT const s_carLimits =
{
{ {"highway", "motorway"}, 90 },
{ {"highway", "trunk"}, 85 },
{ {"highway", "motorway_link"}, 75 },
{ {"highway", "trunk_link"}, 70 },
{ {"highway", "primary"}, 65 },
{ {"highway", "primary_link"}, 60 },
{ {"highway", "secondary"}, 55 },
{ {"highway", "secondary_link"}, 50 },
{ {"highway", "tertiary"}, 40 },
{ {"highway", "tertiary_link"}, 30 },
{ {"highway", "residential"}, 25 },
{ {"highway", "pedestrian"}, 25 },
{ {"highway", "unclassified"}, 25 },
{ {"highway", "service"}, 15 },
{ {"highway", "living_street"}, 10 },
{ {"highway", "road"}, 10 },
{ {"highway", "track"}, 5 },
{ {"highway", "motorway"}, kSpeedMotorwayKMpH },
{ {"highway", "trunk"}, kSpeedTrunkKMpH },
{ {"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH },
{ {"highway", "trunk_link"}, kSpeedTrunkLinkKMpH },
{ {"highway", "primary"}, kSpeedPrimaryKMpH },
{ {"highway", "primary_link"}, kSpeedPrimaryLinkKMpH },
{ {"highway", "secondary"}, kSpeedSecondaryKMpH },
{ {"highway", "secondary_link"}, kSpeedSecondaryLinkKMpH },
{ {"highway", "tertiary"}, kSpeedTertiaryKMpH },
{ {"highway", "tertiary_link"}, kSpeedTertiaryLinkKMpH },
{ {"highway", "residential"}, kSpeedResidentialKMpH },
{ {"highway", "pedestrian"}, kSpeedPedestrianKMpH },
{ {"highway", "unclassified"}, kSpeedUnclassifiedKMpH },
{ {"highway", "service"}, kSpeedServiceKMpH },
{ {"highway", "living_street"}, kSpeedLivingStreetKMpH },
{ {"highway", "road"}, kSpeedRoadKMpH },
{ {"highway", "track"}, kSpeedTrackKMpH },
/// @todo: Add to classificator
//{ {"highway", "shuttle_train"}, 10 },
//{ {"highway", "ferry"}, 5 },
@ -44,12 +65,11 @@ namespace routing
CarModel::CarModel()
: VehicleModel(classif(), s_carLimits)
{
vector<AdditionalRoadTags> additionalTags =
{
{{ "route", "ferry", "motorcar" }, 15.0 },
{{ "route", "ferry", "motor_vehicle" }, 15.0 },
{{ "railway", "rail", "motor_vehicle" }, 40.0 },
{{ "route", "shuttle_train"}, 40.0 },
vector<AdditionalRoadTags> const additionalTags = {
{{"route", "ferry", "motorcar"}, kSpeedFerryMotorcarKMpH},
{{"route", "ferry", "motor_vehicle"}, kSpeedFerryMotorcarVehicleKMpH},
{{"railway", "rail", "motor_vehicle"}, kSpeedRailMotorcarVehicleKMpH},
{{"route", "shuttle_train"}, kSpeedShuttleTrainKMpH},
};
SetAdditionalRoadTypes(classif(), additionalTags);

View file

@ -47,6 +47,7 @@ double constexpr kSpeedStepsKMpH = 4.9;
double constexpr kSpeedPedestrianKMpH = 5.0;
double constexpr kSpeedFootwayKMpH = 5.0;
double constexpr kSpeedPlatformKMpH = 5.0;
double constexpr kSpeedPierKMpH = 4.0;
// Default
routing::VehicleModel::InitListT const g_pedestrianLimitsDefault =
@ -626,8 +627,10 @@ void PedestrianModel::Init()
m_noFootType = classif().GetTypeByPath({ "hwtag", "nofoot" });
m_yesFootType = classif().GetTypeByPath(hwtagYesFoot);
vector<AdditionalRoadTags> additionalTags = {
{ hwtagYesFoot, m_maxSpeedKMpH }, {{"route", "ferry"}, m_maxSpeedKMpH }, {{"man_made", "pier"}, 4.0 },
vector<AdditionalRoadTags> const additionalTags = {
{hwtagYesFoot, m_maxSpeedKMpH},
{{"route", "ferry"}, m_maxSpeedKMpH},
{{"man_made", "pier"}, kSpeedPierKMpH},
};
SetAdditionalRoadTypes(classif(), additionalTags);

View file

@ -7,14 +7,14 @@
#include "base/macros.hpp"
#include "std/algorithm.hpp"
#include "std/limits.hpp"
#include "std/initializer_list.hpp"
#include "std/limits.hpp"
namespace routing
{
VehicleModel::AdditionalRoadTypes::AdditionalRoadTypes(Classificator const & c, AdditionalRoadTags const & tag)
: m_type(c.GetTypeByPath(tag.m_hwtag)), m_speedKmPerH(tag.m_speedKmPerH)
VehicleModel::AdditionalRoadType::AdditionalRoadType(Classificator const & c,
AdditionalRoadTags const & tag)
: m_type(c.GetTypeByPath(tag.m_hwtag)), m_speedKMpH(tag.m_speedKMpH)
{
}
@ -35,7 +35,7 @@ void VehicleModel::SetAdditionalRoadTypes(Classificator const & c,
for (auto const & tag : additionalTags)
{
m_addRoadTypes.emplace_back(c, tag);
m_maxSpeedKMpH = max(m_maxSpeedKMpH, tag.m_speedKmPerH);
m_maxSpeedKMpH = max(m_maxSpeedKMpH, tag.m_speedKMpH);
}
}
@ -49,8 +49,7 @@ double VehicleModel::GetSpeed(FeatureType const & f) const
if (restriction != RoadAvailability::NotAvailable && HasRoadType(types))
return GetMinTypeSpeed(types);
LOG(LERROR, ("Wrong routing types:", types));
return 0.5 /* Small speed to prevent routing along this edge. */;
return 0.0 /* Speed */;
}
double VehicleModel::GetMinTypeSpeed(feature::TypesHolder const & types) const
@ -64,14 +63,13 @@ double VehicleModel::GetMinTypeSpeed(feature::TypesHolder const & types) const
speed = min(speed, it->second);
auto const addRoadInfoIter = GetRoadTypeIter(type);
if (addRoadInfoIter!= m_addRoadTypes.end())
speed = min(speed, addRoadInfoIter->m_speedKmPerH);
if (addRoadInfoIter != m_addRoadTypes.end())
speed = min(speed, addRoadInfoIter->m_speedKMpH);
}
if (speed <= m_maxSpeedKMpH)
return speed;
LOG(LERROR, ("Wrong routing types:", types));
return 0.5 /* Small speed to prevent routing along this edge. */;
return 0.0 /* Speed */;
}
bool VehicleModel::IsOneWay(FeatureType const & f) const
@ -107,10 +105,11 @@ IVehicleModel::RoadAvailability VehicleModel::GetRoadAvailability(feature::Types
return RoadAvailability::Unknown;
}
vector<VehicleModel::AdditionalRoadTypes>::const_iterator VehicleModel::GetRoadTypeIter(uint32_t type) const
vector<VehicleModel::AdditionalRoadType>::const_iterator VehicleModel::GetRoadTypeIter(
uint32_t type) const
{
return find_if(m_addRoadTypes.begin(), m_addRoadTypes.end(),
[&type](AdditionalRoadTypes const & t){ return t.m_type == type;});
[&type](AdditionalRoadType const & t) { return t.m_type == type; });
}
string DebugPrint(IVehicleModel::RoadAvailability const l)

View file

@ -92,7 +92,7 @@ protected:
struct AdditionalRoadTags
{
initializer_list<char const *> m_hwtag;
double m_speedKmPerH;
double m_speedKMpH;
};
/// @returns a special restriction which is set to the feature.
@ -114,21 +114,20 @@ protected:
double m_maxSpeedKMpH;
private:
struct AdditionalRoadTypes
struct AdditionalRoadType
{
AdditionalRoadTypes(Classificator const & c, AdditionalRoadTags const & tag);
bool operator==(AdditionalRoadTypes const & rhs) const { return m_type == rhs.m_type; }
AdditionalRoadType(Classificator const & c, AdditionalRoadTags const & tag);
bool operator==(AdditionalRoadType const & rhs) const { return m_type == rhs.m_type; }
uint32_t const m_type;
double const m_speedKmPerH;
double const m_speedKMpH;
};
vector<AdditionalRoadTypes>::const_iterator GetRoadTypeIter(uint32_t type) const;
vector<AdditionalRoadType>::const_iterator GetRoadTypeIter(uint32_t type) const;
unordered_map<uint32_t, double> m_types;
vector<AdditionalRoadTypes> m_addRoadTypes;
vector<AdditionalRoadType> m_addRoadTypes;
uint32_t m_onewayType;
};