Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-06-29 18:43:32 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-07-23 10:25:11 +0300
commitec73bce900be6b5379b49200781d2b1f7c4e4411 (patch)
tree9751082508a03ac272125122f35b41d293a9922a /routing
parent72938d3d53f34256465cfd62c35825c5c8197748 (diff)
Implementing AltitudeLoader instead of using FeatureType for parsing.
Diffstat (limited to 'routing')
-rw-r--r--routing/features_road_graph.cpp30
-rw-r--r--routing/features_road_graph.hpp11
2 files changed, 28 insertions, 13 deletions
diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp
index 90546fd332..7458a9142d 100644
--- a/routing/features_road_graph.cpp
+++ b/routing/features_road_graph.cpp
@@ -257,18 +257,23 @@ 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);
+
ri.m_bidirectional = !IsOneWay(ft);
ri.m_speedKMPH = speedKMPH;
ft.ParseGeometry(FeatureType::BEST_GEOMETRY);
- ft.ParseAltitude();
+ feature::Altitudes altitudes = value.altitudeLoader.GetAltitudes(featureId.m_index);
+ LOG(LINFO, ("Feature idx =", featureId.m_index, "altitudes.begin =", altitudes.begin,
+ "altitudes.end =", altitudes.end));
+
// @TODO It's a temprarery solution until a vector of feature altitudes is saved in mwm.
- bool const isAltidudeValid = ft.GetAltitudes().begin != feature::kInvalidAltitude &&
- ft.GetAltitudes().end != feature::kInvalidAltitude;
- feature::TAltitude pointAlt = ft.GetAltitudes().begin;
+ bool const isAltidudeValid = altitudes.begin != feature::kInvalidAltitude &&
+ altitudes.end != feature::kInvalidAltitude;
+ feature::TAltitude pointAlt = altitudes.begin;
size_t const pointsCount = ft.GetPointsCount();
feature::TAltitude const diffAlt =
- isAltidudeValid ? (ft.GetAltitudes().end - ft.GetAltitudes().begin) / pointsCount : 0;
+ isAltidudeValid ? (altitudes.end - altitudes.begin) / pointsCount : 0;
ri.m_junctions.clear();
ri.m_junctions.resize(pointsCount);
@@ -283,8 +288,6 @@ void FeaturesRoadGraph::ExtractRoadInfo(FeatureID const & featureId, FeatureType
ri.m_junctions[i] = Junction(ft.GetPoint(i), pointAlt);
pointAlt += diffAlt;
}
-
- LockFeatureMwm(featureId);
}
IRoadGraph::RoadInfo const & FeaturesRoadGraph::GetCachedRoadInfo(FeatureID const & featureId) const
@@ -324,19 +327,24 @@ IRoadGraph::RoadInfo const & FeaturesRoadGraph::GetCachedRoadInfo(FeatureID cons
return ri;
}
-void FeaturesRoadGraph::LockFeatureMwm(FeatureID const & featureId) const
+FeaturesRoadGraph::Value const & FeaturesRoadGraph::LockFeatureMwm(FeatureID const & featureId) const
{
MwmSet::MwmId mwmId = featureId.m_mwmId;
ASSERT(mwmId.IsAlive(), ());
auto const itr = m_mwmLocks.find(mwmId);
if (itr != m_mwmLocks.end())
- return;
+ return itr->second;
MwmSet::MwmHandle mwmHandle = m_index.GetMwmHandleById(mwmId);
ASSERT(mwmHandle.IsAlive(), ());
- m_mwmLocks.insert(make_pair(move(mwmId), move(mwmHandle)));
-}
+ MwmValue * mwmValue = nullptr;
+ if (mwmHandle.IsAlive())
+ mwmValue = mwmHandle.GetValue<MwmValue>();
+
+ Value value = {move(mwmHandle), feature::AltitudeLoader(mwmValue)};
+ return m_mwmLocks.insert(make_pair(move(mwmId), move(value))).first->second;
+}
} // namespace routing
diff --git a/routing/features_road_graph.hpp b/routing/features_road_graph.hpp
index 1ca7957ecc..1503023f40 100644
--- a/routing/features_road_graph.hpp
+++ b/routing/features_road_graph.hpp
@@ -2,6 +2,7 @@
#include "routing/road_graph.hpp"
#include "routing/vehicle_model.hpp"
+#include "indexer/altitude_loader.hpp"
#include "indexer/feature_data.hpp"
#include "indexer/mwm_set.hpp"
@@ -78,6 +79,12 @@ public:
private:
friend class CrossFeaturesLoader;
+ struct Value
+ {
+ MwmSet::MwmHandle mwmHandle;
+ feature::AltitudeLoader altitudeLoader;
+ };
+
bool IsRoad(FeatureType const & ft) const;
bool IsOneWay(FeatureType const & ft) const;
double GetSpeedKMPHFromFt(FeatureType const & ft) const;
@@ -92,13 +99,13 @@ private:
void ExtractRoadInfo(FeatureID const & featureId, FeatureType const & ft, double speedKMPH,
RoadInfo & ri) const;
- void LockFeatureMwm(FeatureID const & featureId) const;
+ Value const & LockFeatureMwm(FeatureID const & featureId) const;
Index const & m_index;
IRoadGraph::Mode const m_mode;
mutable RoadInfoCache m_cache;
mutable CrossCountryVehicleModel m_vehicleModel;
- mutable map<MwmSet::MwmId, MwmSet::MwmHandle> m_mwmLocks;
+ mutable map<MwmSet::MwmId, Value> m_mwmLocks;
};
} // namespace routing