forked from organicmaps/organicmaps
Review fixes.
This commit is contained in:
parent
f61de40e04
commit
4cac8206b3
6 changed files with 53 additions and 46 deletions
|
@ -58,7 +58,7 @@ public:
|
|||
class Index : public MwmSet
|
||||
{
|
||||
protected:
|
||||
/// @name MwmSet overrides.
|
||||
/// MwmSet overrides:
|
||||
//@{
|
||||
unique_ptr<MwmInfo> CreateInfo(platform::LocalCountryFile const & localFile) const override;
|
||||
|
||||
|
|
|
@ -617,28 +617,28 @@ void BicycleModel::Init()
|
|||
SetAdditionalRoadTypes(classif(), arr, ARRAY_SIZE(arr));
|
||||
}
|
||||
|
||||
bool BicycleModel::IsNoBicycle(feature::TypesHolder const & types) const
|
||||
VehicleModel::Restriction BicycleModel::IsNoBicycle(feature::TypesHolder const & types) const
|
||||
{
|
||||
return find(types.begin(), types.end(), m_noBicycleType) != types.end();
|
||||
return types.Has(m_noBicycleType) ? Restriction::Yes : Restriction::Unknown;
|
||||
}
|
||||
|
||||
bool BicycleModel::IsYesBicycle(feature::TypesHolder const & types) const
|
||||
VehicleModel::Restriction BicycleModel::IsYesBicycle(feature::TypesHolder const & types) const
|
||||
{
|
||||
return find(types.begin(), types.end(), m_yesBicycleType) != types.end();
|
||||
return types.Has(m_yesBicycleType) ? Restriction::Yes : Restriction::Unknown;
|
||||
}
|
||||
|
||||
bool BicycleModel::IsBicycleBidir(feature::TypesHolder const & types) const
|
||||
VehicleModel::Restriction BicycleModel::IsBicycleBidir(feature::TypesHolder const & types) const
|
||||
{
|
||||
return find(types.begin(), types.end(), m_bicycleBidirType) != types.end();
|
||||
return types.Has(m_bicycleBidirType) ? Restriction::Yes : Restriction::Unknown;
|
||||
}
|
||||
|
||||
double BicycleModel::GetSpeed(FeatureType const & f) const
|
||||
{
|
||||
feature::TypesHolder types(f);
|
||||
feature::TypesHolder const types(f);
|
||||
|
||||
if (IsYesBicycle(types))
|
||||
if (IsYesBicycle(types) == Restriction::Yes)
|
||||
return VehicleModel::GetMaxSpeed();
|
||||
if (!IsNoBicycle(types) && HasRoadType(types))
|
||||
if (IsNoBicycle(types) == Restriction::Unknown && HasRoadType(types))
|
||||
return VehicleModel::GetMinTypeSpeed(types);
|
||||
|
||||
return 0.0;
|
||||
|
@ -648,7 +648,7 @@ bool BicycleModel::IsOneWay(FeatureType const & f) const
|
|||
{
|
||||
feature::TypesHolder const types(f);
|
||||
|
||||
if (IsBicycleBidir(types))
|
||||
if (IsBicycleBidir(types) == Restriction::Yes)
|
||||
return false;
|
||||
|
||||
return VehicleModel::IsOneWay(f);
|
||||
|
@ -659,9 +659,9 @@ bool BicycleModel::IsRoad(FeatureType const & f) const
|
|||
if (f.GetFeatureType() != feature::GEOM_LINE)
|
||||
return false;
|
||||
|
||||
feature::TypesHolder types(f);
|
||||
feature::TypesHolder const types(f);
|
||||
|
||||
if (IsNoBicycle(types))
|
||||
if (IsNoBicycle(types) == Restriction::Yes)
|
||||
return false;
|
||||
return VehicleModel::HasRoadType(types);
|
||||
}
|
||||
|
|
|
@ -14,25 +14,27 @@ public:
|
|||
BicycleModel();
|
||||
BicycleModel(VehicleModel::InitListT const & speedLimits);
|
||||
|
||||
/// VehicleModel overrides.
|
||||
/// VehicleModel overrides:
|
||||
double GetSpeed(FeatureType const & f) const override;
|
||||
bool IsOneWay(FeatureType const & f) const override;
|
||||
/// @returns true if |f| could be considered as a road.
|
||||
/// @note If BicycleModel::IsRoad(f) returns false for a feature f and for an instance
|
||||
/// of |BicycleModel| created by default constructor
|
||||
/// BicycleModel::IsRoad(f) for the same feature f and for any instance
|
||||
/// of |BicycleModel| created by |BicycleModel(VehicleModel::InitListT const &)| must return false.
|
||||
bool IsRoad(FeatureType const & f) const override;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
/// @return true if road is prohibited for bicycle,
|
||||
/// but if function returns false, real prohibition is unknown.
|
||||
bool IsNoBicycle(feature::TypesHolder const & types) const;
|
||||
/// @return Restriction::Yes if road is prohibited for bicycle.
|
||||
Restriction IsNoBicycle(feature::TypesHolder const & types) const;
|
||||
|
||||
/// @return true if road is allowed for bicycle,
|
||||
/// but if function returns false, real allowance is unknown.
|
||||
bool IsYesBicycle(feature::TypesHolder const & types) const;
|
||||
/// @return Restriction::Yes if road is allowed for bicycle.
|
||||
Restriction IsYesBicycle(feature::TypesHolder const & types) const;
|
||||
|
||||
/// @return true if it is allowed to ride bicycle in two directions,
|
||||
/// but if function returns false, real allowance is unknown.
|
||||
bool IsBicycleBidir(feature::TypesHolder const & types) const;
|
||||
/// @return Restriction::Yes if it is allowed to ride bicycle in two directions.
|
||||
Restriction IsBicycleBidir(feature::TypesHolder const & types) const;
|
||||
|
||||
uint32_t m_noBicycleType = 0;
|
||||
uint32_t m_yesBicycleType = 0;
|
||||
|
|
|
@ -636,23 +636,23 @@ void PedestrianModel::Init()
|
|||
SetAdditionalRoadTypes(classif(), arr, ARRAY_SIZE(arr));
|
||||
}
|
||||
|
||||
bool PedestrianModel::IsNoFoot(feature::TypesHolder const & types) const
|
||||
VehicleModel::Restriction PedestrianModel::IsNoFoot(feature::TypesHolder const & types) const
|
||||
{
|
||||
return find(types.begin(), types.end(), m_noFootType) != types.end();
|
||||
return types.Has(m_noFootType) ? Restriction::Yes : Restriction::Unknown;
|
||||
}
|
||||
|
||||
bool PedestrianModel::IsYesFoot(feature::TypesHolder const & types) const
|
||||
VehicleModel::Restriction PedestrianModel::IsYesFoot(feature::TypesHolder const & types) const
|
||||
{
|
||||
return find(types.begin(), types.end(), m_yesFootType) != types.end();
|
||||
return types.Has(m_yesFootType) ? Restriction::Yes : Restriction::Unknown;
|
||||
}
|
||||
|
||||
double PedestrianModel::GetSpeed(FeatureType const & f) const
|
||||
{
|
||||
feature::TypesHolder types(f);
|
||||
feature::TypesHolder const types(f);
|
||||
|
||||
if (IsYesFoot(types))
|
||||
if (IsYesFoot(types) == Restriction::Yes)
|
||||
return VehicleModel::GetMaxSpeed();
|
||||
if (!IsNoFoot(types) && HasRoadType(types))
|
||||
if (IsNoFoot(types) == Restriction::Unknown && HasRoadType(types))
|
||||
return VehicleModel::GetMinTypeSpeed(types);
|
||||
|
||||
return 0.0;
|
||||
|
@ -663,9 +663,9 @@ bool PedestrianModel::IsRoad(FeatureType const & f) const
|
|||
if (f.GetFeatureType() != feature::GEOM_LINE)
|
||||
return false;
|
||||
|
||||
feature::TypesHolder types(f);
|
||||
feature::TypesHolder const types(f);
|
||||
|
||||
if (IsNoFoot(types))
|
||||
if (IsNoFoot(types) == Restriction::Yes)
|
||||
return false;
|
||||
return VehicleModel::HasRoadType(types);
|
||||
}
|
||||
|
|
|
@ -14,21 +14,24 @@ public:
|
|||
PedestrianModel();
|
||||
PedestrianModel(VehicleModel::InitListT const & speedLimits);
|
||||
|
||||
/// VehicleModel overrides.
|
||||
/// VehicleModel overrides:
|
||||
double GetSpeed(FeatureType const & f) const override;
|
||||
bool IsOneWay(FeatureType const &) const override { return false; }
|
||||
/// @returns true if |f| could be considered as a road for pedestrian routing.
|
||||
/// @note If PedestrianModel::IsRoad(f) returns false for a feature f and for an instance
|
||||
/// of |PedestrianModel| created by default constructor
|
||||
/// PedestrianModel::IsRoad(f) for the same feature f and for any instance
|
||||
/// of |PedestrianModel| created by |PedestrianModel(VehicleModel::InitListT const &)| must return false.
|
||||
bool IsRoad(FeatureType const & f) const override;
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
/// @return True if road is prohibited for pedestrian,
|
||||
/// but if function returns False, real prohibition is unknown.
|
||||
bool IsNoFoot(feature::TypesHolder const & types) const;
|
||||
/// @return Restriction::Yes if road is prohibited for pedestrian.
|
||||
Restriction IsNoFoot(feature::TypesHolder const & types) const;
|
||||
|
||||
/// @return True if road is allowed for pedestrian,
|
||||
/// but if function returns False, real allowance is unknown.
|
||||
bool IsYesFoot(feature::TypesHolder const & types) const;
|
||||
/// @return Restriction::Yes if road is allowed for pedestrian.
|
||||
Restriction IsYesFoot(feature::TypesHolder const & types) const;
|
||||
|
||||
uint32_t m_noFootType = 0;
|
||||
uint32_t m_yesFootType = 0;
|
||||
|
|
|
@ -60,29 +60,31 @@ public:
|
|||
|
||||
VehicleModel(Classificator const & c, InitListT const & speedLimits);
|
||||
|
||||
/// IVehicleModel overrides.
|
||||
/// IVehicleModel overrides:
|
||||
double GetSpeed(FeatureType const & f) const override;
|
||||
double GetMaxSpeed() const override { return m_maxSpeedKMpH; }
|
||||
bool IsOneWay(FeatureType const & f) const override;
|
||||
/// @note If VehicleModel::IsRoad() returns true for a feature its implementation in
|
||||
/// inherited class may return true or false.
|
||||
/// If VehicleModel::IsRoad() returns false for a feature its implementation in
|
||||
/// inherited class must return false as well.
|
||||
bool IsRoad(FeatureType const & f) const override;
|
||||
|
||||
/// @returns true if |m_types| or |m_addRoadTypes| contains |type| and false otherwise.
|
||||
/// @note The set of |types| IsRoadType method returns true for should contain any set of feature types
|
||||
/// IsRoad method (and its implementation in inherited classes) returns true for.
|
||||
bool IsRoadType(uint32_t type) const;
|
||||
template <class TList> bool HasRoadType(TList const & types) const
|
||||
{
|
||||
for (uint32_t t : types)
|
||||
{
|
||||
if (IsRoadType(t))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
enum class Restriction
|
||||
{
|
||||
Unknown,
|
||||
Yes,
|
||||
};
|
||||
|
||||
/// Used in derived class constructors only. Not for public use.
|
||||
void SetAdditionalRoadTypes(Classificator const & c,
|
||||
initializer_list<char const *> const * arr, size_t sz);
|
||||
|
|
Loading…
Add table
Reference in a new issue