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-07-27 11:03:14 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-07-27 14:17:03 +0300
commit939222e72895dfcad5187148c5068ebf136acfdf (patch)
tree4a509ad87db451d43005e84d7ff88187c3a04ca0 /routing
parent3d20b30646fb6360ba72eb922b07965a97c040c1 (diff)
Review fixes.
Diffstat (limited to 'routing')
-rw-r--r--routing/features_road_graph.cpp4
-rw-r--r--routing/features_road_graph.hpp2
-rw-r--r--routing/nearest_edge_finder.cpp28
-rw-r--r--routing/road_graph.cpp2
-rw-r--r--routing/road_graph.hpp3
-rw-r--r--routing/routing_algorithm.cpp5
6 files changed, 29 insertions, 15 deletions
diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp
index eee98a85ee..23912ba928 100644
--- a/routing/features_road_graph.cpp
+++ b/routing/features_road_graph.cpp
@@ -38,7 +38,7 @@ string GetFeatureCountryName(FeatureID const featureId)
}
} // namespace
-FeaturesRoadGraph::Value::Value(MwmSet::MwmHandle && handle) : m_mwmHandle(move(handle))
+FeaturesRoadGraph::Value::Value(MwmSet::MwmHandle handle) : m_mwmHandle(move(handle))
{
if (!m_mwmHandle.IsAlive())
return;
@@ -282,7 +282,7 @@ void FeaturesRoadGraph::ExtractRoadInfo(FeatureID const & featureId, FeatureType
else
{
ASSERT(false, ());
- altitudes = feature::TAltitudes(ft.GetPointsCount(), feature::kDefautlAltitudeMeters);
+ altitudes = feature::TAltitudes(ft.GetPointsCount(), feature::kDefaultAltitudeMeters);
}
CHECK_EQUAL(altitudes.size(), pointsCount,
diff --git a/routing/features_road_graph.hpp b/routing/features_road_graph.hpp
index 59309e7bfb..1f99d2f78b 100644
--- a/routing/features_road_graph.hpp
+++ b/routing/features_road_graph.hpp
@@ -82,7 +82,7 @@ private:
struct Value
{
Value() = default;
- explicit Value(MwmSet::MwmHandle && handle);
+ explicit Value(MwmSet::MwmHandle handle);
bool IsAlive() const { return m_mwmHandle.IsAlive(); }
diff --git a/routing/nearest_edge_finder.cpp b/routing/nearest_edge_finder.cpp
index 637abc395e..fc6ebd0090 100644
--- a/routing/nearest_edge_finder.cpp
+++ b/routing/nearest_edge_finder.cpp
@@ -32,19 +32,31 @@ void NearestEdgeFinder::AddInformationSource(FeatureID const & featureId, IRoadG
double const d = m_point.SquareLength(pt);
if (d < res.m_dist)
{
+ Junction const & segStart = roadInfo.m_junctions[i - 1];
+ Junction const & segEnd = roadInfo.m_junctions[i];
+ feature::TAltitude const startAlt = segStart.GetAltitude();
+ feature::TAltitude const endAlt = segEnd.GetAltitude();
+
+ double const segLenM = MercatorBounds::DistanceOnEarth(segStart.GetPoint(), segEnd.GetPoint());
+ feature::TAltitude projPointAlt = feature::kDefaultAltitudeMeters;
+ if (segLenM == 0.0)
+ {
+ ASSERT(false, (featureId));
+ projPointAlt = startAlt;
+ }
+ double const distFromStartM = MercatorBounds::DistanceOnEarth(segStart.GetPoint(), pt);
+ ASSERT_LESS_OR_EQUAL(distFromStartM, segLenM, (featureId));
+ projPointAlt = startAlt + static_cast<feature::TAltitude>((endAlt - startAlt) * distFromStartM / segLenM);
+
res.m_dist = d;
res.m_fid = featureId;
res.m_segId = static_cast<uint32_t>(i - 1);
- res.m_segStart = roadInfo.m_junctions[i - 1];
- res.m_segEnd = roadInfo.m_junctions[i];
- // @TODO res.m_projPoint.GetAltitude() is an altitude of |pt|. |pt| is a projection of m_point
- // to segment [res.m_segStart.GetPoint(), res.m_segEnd.GetPoint()].
- // It's necessary to calculate exact value of res.m_projPoint.GetAltitude() by this
- // information.
+ res.m_segStart = segStart;
+ res.m_segEnd = segEnd;
+
ASSERT_NOT_EQUAL(res.m_segStart.GetAltitude() , feature::kInvalidAltitude, ());
ASSERT_NOT_EQUAL(res.m_segEnd.GetAltitude(), feature::kInvalidAltitude, ());
- feature::TAltitude const projPointAlt =
- static_cast<feature::TAltitude>((res.m_segStart.GetAltitude() + res.m_segEnd.GetAltitude()) / 2);
+
res.m_projPoint = Junction(pt, projPointAlt);
}
}
diff --git a/routing/road_graph.cpp b/routing/road_graph.cpp
index 52a66857e5..c7ed2612c4 100644
--- a/routing/road_graph.cpp
+++ b/routing/road_graph.cpp
@@ -66,7 +66,7 @@ void ReverseEdges(size_t beginIdx, IRoadGraph::TEdgeVector & edges)
// Junction --------------------------------------------------------------------
-Junction::Junction() : m_point(m2::PointD::Zero()), m_altitude(feature::kDefautlAltitudeMeters) {}
+Junction::Junction() : m_point(m2::PointD::Zero()), m_altitude(feature::kDefaultAltitudeMeters) {}
Junction::Junction(m2::PointD const & point, feature::TAltitude altitude)
: m_point(point), m_altitude(altitude)
{}
diff --git a/routing/road_graph.hpp b/routing/road_graph.hpp
index 2f00733633..5bab78a5a5 100644
--- a/routing/road_graph.hpp
+++ b/routing/road_graph.hpp
@@ -29,6 +29,7 @@ public:
inline m2::PointD const & GetPoint() const { return m_point; }
inline feature::TAltitude GetAltitude() const { return m_altitude; }
+
private:
friend string DebugPrint(Junction const & r);
@@ -39,7 +40,7 @@ private:
inline Junction MakeJunctionForTesting(m2::PointD const & point)
{
- return Junction(point, feature::kDefautlAltitudeMeters);
+ return Junction(point, feature::kDefaultAltitudeMeters);
}
inline bool AlmostEqualAbs(Junction const & lhs, Junction const & rhs)
diff --git a/routing/routing_algorithm.cpp b/routing/routing_algorithm.cpp
index 773bd38be3..28619d2602 100644
--- a/routing/routing_algorithm.cpp
+++ b/routing/routing_algorithm.cpp
@@ -23,8 +23,9 @@ inline double TimeBetweenSec(Junction const & j1, Junction const & j2, double sp
ASSERT_NOT_EQUAL(j2.GetAltitude(), feature::kInvalidAltitude, ());
double const distanceM = MercatorBounds::DistanceOnEarth(j1.GetPoint(), j2.GetPoint());
- feature::TAltitude const altidudeDiffM = j2.GetAltitude() - j1.GetAltitude();
- return sqrt(distanceM * distanceM + altidudeDiffM * altidudeDiffM) / speedMPS;
+ double const altitudeDiffM =
+ static_cast<double>(j2.GetAltitude()) - static_cast<double>(j1.GetAltitude());
+ return sqrt(distanceM * distanceM + altitudeDiffM * altitudeDiffM) / speedMPS;
}
/// A class which represents an weighted edge used by RoadGraph.