diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-07-25 10:49:28 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-07-26 18:51:57 +0300 |
commit | 73fccde2d4bc0e2ae41843a1f7fb574d9ccfce65 (patch) | |
tree | 3717e981cbc1d32710d138ce2caa8d7b7083864b /routing | |
parent | 979f48bfaf7322320801db215b1d0e3d231f8699 (diff) |
Review fixes.
Diffstat (limited to 'routing')
-rw-r--r-- | routing/features_road_graph.cpp | 30 | ||||
-rw-r--r-- | routing/features_road_graph.hpp | 22 | ||||
-rw-r--r-- | routing/road_graph.cpp | 6 |
3 files changed, 30 insertions, 28 deletions
diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp index 1dc3c38a25..f915d4c3ab 100644 --- a/routing/features_road_graph.cpp +++ b/routing/features_road_graph.cpp @@ -38,6 +38,14 @@ string GetFeatureCountryName(FeatureID const featureId) } } // namespace +FeaturesRoadGraph::Value::Value(MwmSet::MwmHandle && handle) + : m_mwmHandle(move(handle)) +{ + if (!m_mwmHandle.IsAlive()) + return; + + m_altitudeLoader = make_unique<feature::AltitudeLoader>(*m_mwmHandle.GetValue<MwmValue>()); +} FeaturesRoadGraph::CrossCountryVehicleModel::CrossCountryVehicleModel(unique_ptr<IVehicleModelFactory> && vehicleModelFactory) : m_vehicleModelFactory(move(vehicleModelFactory)) @@ -257,24 +265,25 @@ double FeaturesRoadGraph::GetSpeedKMPHFromFt(FeatureType const & ft) const void FeaturesRoadGraph::ExtractRoadInfo(FeatureID const & featureId, FeatureType const & ft, double speedKMPH, RoadInfo & ri) const { - Value const & value = LockFeatureMwm(featureId); + Value const & value = LockMwm(featureId.m_mwmId); if (!value.IsAlive()) - { - ASSERT(false, ()); return; - } ri.m_bidirectional = !IsOneWay(ft); ri.m_speedKMPH = speedKMPH; ft.ParseGeometry(FeatureType::BEST_GEOMETRY); - feature::TAltitudes altitudes = value.altitudeLoader->GetAltitudes(featureId.m_index, ft.GetPointsCount()); - size_t const pointsCount = ft.GetPointsCount(); - if (altitudes.size() != pointsCount) + + feature::TAltitudes altitudes; + if (value.HasAltitudeLoader()) { - ASSERT(false, ("altitudes.size is different from ft.GetPointsCount()")); - altitudes.clear(); + altitudes = value.m_altitudeLoader->GetAltitudes(featureId.m_index, ft.GetPointsCount()); + if (altitudes.size() != pointsCount) + { + ASSERT(false, ("altitudes.size() is different from ft.GetPointsCount()")); + altitudes.clear(); + } } ri.m_junctions.clear(); @@ -325,9 +334,8 @@ IRoadGraph::RoadInfo const & FeaturesRoadGraph::GetCachedRoadInfo(FeatureID cons return ri; } -FeaturesRoadGraph::Value const & FeaturesRoadGraph::LockFeatureMwm(FeatureID const & featureId) const +FeaturesRoadGraph::Value const & FeaturesRoadGraph::LockMwm(MwmSet::MwmId const & mwmId) const { - MwmSet::MwmId mwmId = featureId.m_mwmId; ASSERT(mwmId.IsAlive(), ()); auto const itr = m_mwmLocks.find(mwmId); diff --git a/routing/features_road_graph.hpp b/routing/features_road_graph.hpp index e45495adf3..63800328b5 100644 --- a/routing/features_road_graph.hpp +++ b/routing/features_road_graph.hpp @@ -82,24 +82,20 @@ private: struct Value { Value() = default; - explicit Value(MwmSet::MwmHandle && handle) - : mwmHandle(move(handle)) + explicit Value(MwmSet::MwmHandle && handle); + + bool IsAlive() const { - if (!mwmHandle.IsAlive()) - { - ASSERT(false, ()); - return; - } - altitudeLoader = make_unique<feature::AltitudeLoader>(*mwmHandle.GetValue<MwmValue>()); + return m_mwmHandle.IsAlive(); } - bool IsAlive() const + bool HasAltitudeLoader() const { - return mwmHandle.IsAlive() && altitudeLoader && altitudeLoader->IsAvailable(); + return m_altitudeLoader && m_altitudeLoader->HasAltitudes(); } - MwmSet::MwmHandle mwmHandle; - unique_ptr<feature::AltitudeLoader> altitudeLoader; + MwmSet::MwmHandle m_mwmHandle; + unique_ptr<feature::AltitudeLoader> m_altitudeLoader; }; bool IsRoad(FeatureType const & ft) const; @@ -116,7 +112,7 @@ private: void ExtractRoadInfo(FeatureID const & featureId, FeatureType const & ft, double speedKMPH, RoadInfo & ri) const; - Value const & LockFeatureMwm(FeatureID const & featureId) const; + Value const & LockMwm(MwmSet::MwmId const & mwmId) const; Index const & m_index; IRoadGraph::Mode const m_mode; diff --git a/routing/road_graph.cpp b/routing/road_graph.cpp index c362365400..db32e7d486 100644 --- a/routing/road_graph.cpp +++ b/routing/road_graph.cpp @@ -390,12 +390,10 @@ void IRoadGraph::GetEdgeTypes(Edge const & edge, feature::TypesHolder & types) c IRoadGraph::RoadInfo MakeRoadInfoForTesting(bool bidirectional, double speedKMPH, initializer_list<m2::PointD> const & points) { - buffer_vector<Junction, 32> junctions; + IRoadGraph::RoadInfo ri(bidirectional, speedKMPH, {}); for (auto const & p : points) - junctions.emplace_back(MakeJunctionForTesting(p)); + ri.m_junctions.emplace_back(MakeJunctionForTesting(p)); - IRoadGraph::RoadInfo ri(bidirectional, speedKMPH, {}); - ri.m_junctions.swap(junctions); return ri; } } // namespace routing |