Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tatiana-yan authored and dobriy-eeh committed Aug 2, 2017
1 parent d47bbef commit 8617cfa
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 95 deletions.
66 changes: 34 additions & 32 deletions routing_common/bicycle_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "indexer/classificator.hpp"
#include "indexer/feature.hpp"

using namespace routing;

namespace
{

Expand Down Expand Up @@ -49,7 +51,7 @@ double constexpr kSpeedPlatformKMpH = 3.0;
double constexpr kSpeedPierKMpH = 7.0;

// Default
routing::VehicleModel::InitListT const g_bicycleLimitsDefault =
VehicleModel::InitListT const g_bicycleLimitsDefault =
{
{ {"highway", "trunk"}, kSpeedTrunkKMpH, true /* transitAllowed */ },
{ {"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true },
Expand All @@ -72,7 +74,7 @@ routing::VehicleModel::InitListT const g_bicycleLimitsDefault =
};

// All options available.
routing::VehicleModel::InitListT const g_bicycleLimitsAll =
VehicleModel::InitListT const g_bicycleLimitsAll =
{
{ {"highway", "trunk"}, kSpeedTrunkKMpH, true },
{ {"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true },
Expand All @@ -98,7 +100,7 @@ routing::VehicleModel::InitListT const g_bicycleLimitsAll =
};

// Same as defaults except trunk and trunk_link are not allowed
routing::VehicleModel::InitListT const g_bicycleLimitsNoTrunk =
VehicleModel::InitListT const g_bicycleLimitsNoTrunk =
{
{ {"highway", "primary"}, kSpeedPrimaryKMpH, true },
{ {"highway", "primary_link"}, kSpeedPrimaryLinkKMpH, true },
Expand All @@ -119,7 +121,7 @@ routing::VehicleModel::InitListT const g_bicycleLimitsNoTrunk =
};

// Same as defaults except pedestrian is allowed
routing::VehicleModel::InitListT const g_bicycleLimitsPedestrianAllowed =
VehicleModel::InitListT const g_bicycleLimitsPedestrianAllowed =
{
{ {"highway", "trunk"}, kSpeedTrunkKMpH, true },
{ {"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true },
Expand All @@ -143,7 +145,7 @@ routing::VehicleModel::InitListT const g_bicycleLimitsPedestrianAllowed =
};

// Same as defaults except bridleway is allowed
routing::VehicleModel::InitListT const g_bicycleLimitsBridlewayAllowed =
VehicleModel::InitListT const g_bicycleLimitsBridlewayAllowed =
{
{ {"highway", "trunk"}, kSpeedTrunkKMpH, true },
{ {"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true },
Expand All @@ -167,10 +169,10 @@ routing::VehicleModel::InitListT const g_bicycleLimitsBridlewayAllowed =
};

// Australia
routing::VehicleModel::InitListT const g_bicycleLimitsAustralia = g_bicycleLimitsAll;
VehicleModel::InitListT const g_bicycleLimitsAustralia = g_bicycleLimitsAll;

// Austria
routing::VehicleModel::InitListT const g_bicycleLimitsAustria =
VehicleModel::InitListT const g_bicycleLimitsAustria =
{
// No trunk, trunk_link, path
{ {"highway", "primary"}, kSpeedPrimaryKMpH, true },
Expand All @@ -191,7 +193,7 @@ routing::VehicleModel::InitListT const g_bicycleLimitsAustria =
};

// Belarus
routing::VehicleModel::InitListT const g_bicycleLimitsBelarus =
VehicleModel::InitListT const g_bicycleLimitsBelarus =
{
// Footway and pedestrian are allowed
{ {"highway", "trunk"}, kSpeedTrunkKMpH, true },
Expand All @@ -217,7 +219,7 @@ routing::VehicleModel::InitListT const g_bicycleLimitsBelarus =
};

// Belgium
routing::VehicleModel::InitListT const g_bicycleLimitsBelgium =
VehicleModel::InitListT const g_bicycleLimitsBelgium =
{
// No trunk, trunk_link
// Pedestrian is allowed
Expand All @@ -241,7 +243,7 @@ routing::VehicleModel::InitListT const g_bicycleLimitsBelgium =
};

// Brazil
routing::VehicleModel::InitListT const g_bicycleLimitsBrazil =
VehicleModel::InitListT const g_bicycleLimitsBrazil =
{
// Bridleway and fotway are allowed
{ {"highway", "trunk"}, kSpeedTrunkKMpH, true },
Expand All @@ -267,10 +269,10 @@ routing::VehicleModel::InitListT const g_bicycleLimitsBrazil =
};

// Denmark
routing::VehicleModel::InitListT const g_bicycleLimitsDenmark = g_bicycleLimitsNoTrunk;
VehicleModel::InitListT const g_bicycleLimitsDenmark = g_bicycleLimitsNoTrunk;

// France
routing::VehicleModel::InitListT const g_bicycleLimitsFrance =
VehicleModel::InitListT const g_bicycleLimitsFrance =
{
// No trunk, trunk_link
// Pedestrian is allowed
Expand All @@ -294,34 +296,34 @@ routing::VehicleModel::InitListT const g_bicycleLimitsFrance =
};

// Finland
routing::VehicleModel::InitListT const g_bicycleLimitsFinland = g_bicycleLimitsPedestrianAllowed;
VehicleModel::InitListT const g_bicycleLimitsFinland = g_bicycleLimitsPedestrianAllowed;

// Germany
routing::VehicleModel::InitListT const g_bicycleLimitsGermany = g_bicycleLimitsDefault;
VehicleModel::InitListT const g_bicycleLimitsGermany = g_bicycleLimitsDefault;

// Hungary
routing::VehicleModel::InitListT const g_bicycleLimitsHungary = g_bicycleLimitsNoTrunk;
VehicleModel::InitListT const g_bicycleLimitsHungary = g_bicycleLimitsNoTrunk;

// Iceland
routing::VehicleModel::InitListT const g_bicycleLimitsIceland = g_bicycleLimitsAll;
VehicleModel::InitListT const g_bicycleLimitsIceland = g_bicycleLimitsAll;

// Netherlands
routing::VehicleModel::InitListT const g_bicycleLimitsNetherlands = g_bicycleLimitsNoTrunk;
VehicleModel::InitListT const g_bicycleLimitsNetherlands = g_bicycleLimitsNoTrunk;

// Norway
routing::VehicleModel::InitListT const g_bicycleLimitsNorway = g_bicycleLimitsAll;
VehicleModel::InitListT const g_bicycleLimitsNorway = g_bicycleLimitsAll;

// Oman
routing::VehicleModel::InitListT const g_bicycleLimitsOman = g_bicycleLimitsBridlewayAllowed;
VehicleModel::InitListT const g_bicycleLimitsOman = g_bicycleLimitsBridlewayAllowed;

// Poland
routing::VehicleModel::InitListT const g_bicycleLimitsPoland = g_bicycleLimitsNoTrunk;
VehicleModel::InitListT const g_bicycleLimitsPoland = g_bicycleLimitsNoTrunk;

// Romania
routing::VehicleModel::InitListT const g_bicycleLimitsRomania = g_bicycleLimitsNoTrunk;
VehicleModel::InitListT const g_bicycleLimitsRomania = g_bicycleLimitsNoTrunk;

// Russian Federation
routing::VehicleModel::InitListT const g_bicycleLimitsRussia =
VehicleModel::InitListT const g_bicycleLimitsRussia =
{
// Footway and pedestrian are allowed
// No transit for service and living_street
Expand All @@ -348,19 +350,19 @@ routing::VehicleModel::InitListT const g_bicycleLimitsRussia =
};

// Slovakia
routing::VehicleModel::InitListT const g_bicycleLimitsSlovakia = g_bicycleLimitsNoTrunk;
VehicleModel::InitListT const g_bicycleLimitsSlovakia = g_bicycleLimitsNoTrunk;

// Spain
routing::VehicleModel::InitListT const g_bicycleLimitsSpain = g_bicycleLimitsPedestrianAllowed;
VehicleModel::InitListT const g_bicycleLimitsSpain = g_bicycleLimitsPedestrianAllowed;

// Switzerland
routing::VehicleModel::InitListT const g_bicycleLimitsSwitzerland = g_bicycleLimitsNoTrunk;
VehicleModel::InitListT const g_bicycleLimitsSwitzerland = g_bicycleLimitsNoTrunk;

// Turkey
routing::VehicleModel::InitListT const g_bicycleLimitsTurkey = g_bicycleLimitsDefault;
VehicleModel::InitListT const g_bicycleLimitsTurkey = g_bicycleLimitsDefault;

// Ukraine
routing::VehicleModel::InitListT const g_bicycleLimitsUkraine =
VehicleModel::InitListT const g_bicycleLimitsUkraine =
{
// No trunk
// Footway and perestrian are allowed
Expand All @@ -386,10 +388,10 @@ routing::VehicleModel::InitListT const g_bicycleLimitsUkraine =
};

// United Kingdom
routing::VehicleModel::InitListT const g_bicycleLimitsUK = g_bicycleLimitsBridlewayAllowed;
VehicleModel::InitListT const g_bicycleLimitsUK = g_bicycleLimitsBridlewayAllowed;

// United States of America
routing::VehicleModel::InitListT const g_bicycleLimitsUS =
VehicleModel::InitListT const g_bicycleLimitsUS =
{
// Bridleway and pedesprian are allowed
{ {"highway", "trunk"}, kSpeedTrunkKMpH, true },
Expand Down Expand Up @@ -484,7 +486,7 @@ BicycleModel const & BicycleModel::AllLimitsInstance()
BicycleModelFactory::BicycleModelFactory()
{
// Names must be the same with country names from countries.txt
m_models[string()] = make_shared<BicycleModel>(g_bicycleLimitsDefault);
m_models[""] = make_shared<BicycleModel>(g_bicycleLimitsDefault);
m_models["Australia"] = make_shared<BicycleModel>(g_bicycleLimitsAustralia);
m_models["Austria"] = make_shared<BicycleModel>(g_bicycleLimitsAustria);
m_models["Belarus"] = make_shared<BicycleModel>(g_bicycleLimitsBelarus);
Expand Down Expand Up @@ -513,7 +515,7 @@ BicycleModelFactory::BicycleModelFactory()

shared_ptr<IVehicleModel> BicycleModelFactory::GetVehicleModel() const
{
auto const itr = m_models.find(string());
auto const itr = m_models.find("");
ASSERT(itr != m_models.end(), ());
return itr->second;
}
Expand All @@ -527,6 +529,6 @@ shared_ptr<IVehicleModel> BicycleModelFactory::GetVehicleModelForCountry(string
return itr->second;
}
LOG(LDEBUG, ("Bicycle model wasn't found, default bicycle model is used instead:", country));
return BicycleModelFactory::GetVehicleModel();
return GetVehicleModel();
}
} // routing
63 changes: 32 additions & 31 deletions routing_common/car_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <vector>

using namespace std;
using namespace routing;

namespace
{
Expand Down Expand Up @@ -37,9 +38,9 @@ double constexpr kSpeedFerryMotorcarVehicleKMpH = 15.0;
double constexpr kSpeedRailMotorcarVehicleKMpH = 25.0;
double constexpr kSpeedShuttleTrainKMpH = 25.0;

routing::VehicleModel::InitListT const g_carLimitsDefault =
VehicleModel::InitListT const g_carLimitsDefault =
{
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true},
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true /* isTransitAllowed */ },
{{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true},
{{"highway", "trunk"}, kSpeedTrunkKMpH, true},
{{"highway", "trunk_link"}, kSpeedTrunkLinkKMpH, true},
Expand All @@ -63,7 +64,7 @@ routing::VehicleModel::InitListT const g_carLimitsDefault =
//{ {"highway", "construction"}, 40 },
};

routing::VehicleModel::InitListT const g_carLimitsNoLivingStreetTransit =
VehicleModel::InitListT const g_carLimitsNoLivingStreetTransit =
{
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true},
{{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true},
Expand All @@ -83,7 +84,7 @@ routing::VehicleModel::InitListT const g_carLimitsNoLivingStreetTransit =
{{"highway", "track"}, kSpeedTrackKMpH, true},
};

routing::VehicleModel::InitListT const g_carLimitsNoLivingStreetAndServiceTransit =
VehicleModel::InitListT const g_carLimitsNoLivingStreetAndServiceTransit =
{
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true},
{{"highway", "motorway_link"}, kSpeedMotorwayLinkKMpH, true},
Expand All @@ -103,17 +104,17 @@ routing::VehicleModel::InitListT const g_carLimitsNoLivingStreetAndServiceTransi
{{"highway", "track"}, kSpeedTrackKMpH, true},
};

routing::VehicleModel::InitListT const g_carLimitsAustralia = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsAustralia = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsAustria = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsAustria = g_carLimitsNoLivingStreetTransit;

routing::VehicleModel::InitListT const g_carLimitsBelarus = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsBelarus = g_carLimitsNoLivingStreetTransit;

routing::VehicleModel::InitListT const g_carLimitsBelgium = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsBelgium = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsBrazil = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsBrazil = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsDenmark =
VehicleModel::InitListT const g_carLimitsDenmark =
{
// No track
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true},
Expand All @@ -133,11 +134,11 @@ routing::VehicleModel::InitListT const g_carLimitsDenmark =
{{"highway", "road"}, kSpeedRoadKMpH, true},
};

routing::VehicleModel::InitListT const g_carLimitsFrance = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsFrance = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsFinland = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsFinland = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsGermany =
VehicleModel::InitListT const g_carLimitsGermany =
{
// No transit for track
{{"highway", "motorway"}, kSpeedMotorwayKMpH, true},
Expand All @@ -158,35 +159,35 @@ routing::VehicleModel::InitListT const g_carLimitsGermany =
{{"highway", "track"}, kSpeedTrackKMpH, false},
};

routing::VehicleModel::InitListT const g_carLimitsHungary = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsHungary = g_carLimitsNoLivingStreetTransit;

routing::VehicleModel::InitListT const g_carLimitsIceland = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsIceland = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsNetherlands = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsNetherlands = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsNorway = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsNorway = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsOman = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsOman = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsPoland = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsPoland = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsRomania = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsRomania = g_carLimitsNoLivingStreetTransit;

routing::VehicleModel::InitListT const g_carLimitsRussia = g_carLimitsNoLivingStreetAndServiceTransit;
VehicleModel::InitListT const g_carLimitsRussia = g_carLimitsNoLivingStreetAndServiceTransit;

routing::VehicleModel::InitListT const g_carLimitsSlovakia = g_carLimitsNoLivingStreetTransit;
VehicleModel::InitListT const g_carLimitsSlovakia = g_carLimitsNoLivingStreetTransit;

routing::VehicleModel::InitListT const g_carLimitsSpain = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsSpain = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsSwitzerland = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsSwitzerland = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsTurkey = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsTurkey = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsUkraine = g_carLimitsNoLivingStreetAndServiceTransit;
VehicleModel::InitListT const g_carLimitsUkraine = g_carLimitsNoLivingStreetAndServiceTransit;

routing::VehicleModel::InitListT const g_carLimitsUK = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsUK = g_carLimitsDefault;

routing::VehicleModel::InitListT const g_carLimitsUS = g_carLimitsDefault;
VehicleModel::InitListT const g_carLimitsUS = g_carLimitsDefault;

} // namespace

Expand Down Expand Up @@ -227,7 +228,7 @@ CarModel const & CarModel::AllLimitsInstance()
CarModelFactory::CarModelFactory()
{
// Names must be the same with country names from countries.txt
m_models[string()] = make_shared<CarModel>(g_carLimitsDefault);
m_models[""] = make_shared<CarModel>(g_carLimitsDefault);
m_models["Australia"] = make_shared<CarModel>(g_carLimitsAustralia);
m_models["Austria"] = make_shared<CarModel>(g_carLimitsAustria);
m_models["Belarus"] = make_shared<CarModel>(g_carLimitsBelarus);
Expand Down Expand Up @@ -256,7 +257,7 @@ CarModelFactory::CarModelFactory()

shared_ptr<IVehicleModel> CarModelFactory::GetVehicleModel() const
{
auto const itr = m_models.find(string());
auto const itr = m_models.find("");
ASSERT(itr != m_models.end(), ());
return itr->second;
}
Expand All @@ -270,6 +271,6 @@ shared_ptr<IVehicleModel> CarModelFactory::GetVehicleModelForCountry(string cons
return itr->second;
}
LOG(LDEBUG, ("Car model wasn't found, default car model is used instead:", country));
return CarModelFactory::GetVehicleModel();
return GetVehicleModel();
}
} // namespace routing
Loading

0 comments on commit 8617cfa

Please sign in to comment.