From 4df2fd4662ac9e3a266a13d4922c26c5cd27d974 Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Wed, 27 May 2015 12:35:11 +0300 Subject: [PATCH] exclude m_ prefix before structure fields --- routing/osrm_engine.cpp | 52 ++++++++++++++++++------------------ routing/osrm_engine.hpp | 33 ++++++++++++----------- routing/osrm_router.cpp | 58 ++++++++++++++++++++--------------------- routing/osrm_router.hpp | 21 +++++---------- 4 files changed, 78 insertions(+), 86 deletions(-) diff --git a/routing/osrm_engine.cpp b/routing/osrm_engine.cpp index 188ba5a7b3..d4d3013011 100644 --- a/routing/osrm_engine.cpp +++ b/routing/osrm_engine.cpp @@ -37,9 +37,9 @@ void FindWeightsMatrix(TRoutingNodes const & sources, TRoutingNodes const & targ PhantomNodeArray sourcesTaskVector(sources.size()); PhantomNodeArray targetsTaskVector(targets.size()); for (size_t i = 0; i < sources.size(); ++i) - sourcesTaskVector[i].push_back(sources[i].m_node); + sourcesTaskVector[i].push_back(sources[i].node); for (size_t i = 0; i < targets.size(); ++i) - targetsTaskVector[i].push_back(targets[i].m_node); + targetsTaskVector[i].push_back(targets[i].node); // Calculate time consumption of a NtoM path finding. my::HighResTimer timer(true); @@ -57,8 +57,8 @@ bool FindSingleRoute(FeatureGraphNode const & source, FeatureGraphNode const & t InternalRouteResult result; ShortestPathRouting pathFinder(&facade, engineData); PhantomNodes nodes; - nodes.source_phantom = source.m_node; - nodes.target_phantom = target.m_node; + nodes.source_phantom = source.node; + nodes.target_phantom = target.node; if ((nodes.source_phantom.forward_node_id != INVALID_NODE_ID || nodes.source_phantom.reverse_node_id != INVALID_NODE_ID) && @@ -71,9 +71,9 @@ bool FindSingleRoute(FeatureGraphNode const & source, FeatureGraphNode const & t if (IsRouteExist(result)) { - rawRoutingResult.m_sourceEdge = source; - rawRoutingResult.m_targetEdge = target; - rawRoutingResult.m_shortestPathLength = result.shortest_path_length; + rawRoutingResult.sourceEdge = source; + rawRoutingResult.targetEdge = target; + rawRoutingResult.shortestPathLength = result.shortest_path_length; for (auto const & path : result.unpacked_path_segments) { vector data; @@ -82,7 +82,7 @@ bool FindSingleRoute(FeatureGraphNode const & source, FeatureGraphNode const & t { data.emplace_back(element.node, element.segment_duration); } - rawRoutingResult.m_unpackedPathSegments.emplace_back(move(data)); + rawRoutingResult.unpackedPathSegments.emplace_back(move(data)); } return true; } @@ -92,28 +92,28 @@ bool FindSingleRoute(FeatureGraphNode const & source, FeatureGraphNode const & t FeatureGraphNode::FeatureGraphNode(NodeID const nodeId, bool const isStartNode) { - m_node.forward_node_id = isStartNode ? nodeId : INVALID_NODE_ID; - m_node.reverse_node_id = isStartNode ? INVALID_NODE_ID : nodeId; - m_node.forward_weight = 0; - m_node.reverse_weight = 0; - m_node.forward_offset = 0; - m_node.reverse_offset = 0; - m_node.name_id = 1; - m_seg.m_fid = OsrmMappingTypes::FtSeg::INVALID_FID; - m_segPt = m2::PointD::Zero(); + node.forward_node_id = isStartNode ? nodeId : INVALID_NODE_ID; + node.reverse_node_id = isStartNode ? INVALID_NODE_ID : nodeId; + node.forward_weight = 0; + node.reverse_weight = 0; + node.forward_offset = 0; + node.reverse_offset = 0; + node.name_id = 1; + segment.m_fid = OsrmMappingTypes::FtSeg::INVALID_FID; + segmentPoint = m2::PointD::Zero(); } FeatureGraphNode::FeatureGraphNode() { - m_node.forward_node_id = INVALID_NODE_ID; - m_node.reverse_node_id = INVALID_NODE_ID; - m_node.forward_weight = 0; - m_node.reverse_weight = 0; - m_node.forward_offset = 0; - m_node.reverse_offset = 0; - m_node.name_id = 1; - m_seg.m_fid = OsrmMappingTypes::FtSeg::INVALID_FID; - m_segPt = m2::PointD::Zero(); + node.forward_node_id = INVALID_NODE_ID; + node.reverse_node_id = INVALID_NODE_ID; + node.forward_weight = 0; + node.reverse_weight = 0; + node.forward_offset = 0; + node.reverse_offset = 0; + node.name_id = 1; + segment.m_fid = OsrmMappingTypes::FtSeg::INVALID_FID; + segmentPoint = m2::PointD::Zero(); } } // namespace routing diff --git a/routing/osrm_engine.hpp b/routing/osrm_engine.hpp index f16551ca6f..4602a71e62 100644 --- a/routing/osrm_engine.hpp +++ b/routing/osrm_engine.hpp @@ -14,15 +14,14 @@ namespace routing /// Single graph node representation for routing task struct FeatureGraphNode { - PhantomNode m_node; - OsrmMappingTypes::FtSeg m_seg; - m2::PointD m_segPt; + PhantomNode node; + OsrmMappingTypes::FtSeg segment; + m2::PointD segmentPoint; /*! - * \brief GenerateRoutingTaskFromNodeId fill taskNode with values for making route + * \brief fill FeatureGraphNode with values * \param nodeId osrm node idetifier * \param isStartNode true if this node will first in the path - * \param taskNode output point task for router */ FeatureGraphNode(NodeID const nodeId, bool const isStartNode); @@ -37,12 +36,12 @@ struct FeatureGraphNode struct RawPathData { NodeID node; - EdgeWeight segment_duration; + EdgeWeight segmentWeight; - RawPathData() : node(SPECIAL_NODEID), segment_duration(INVALID_EDGE_WEIGHT) {} + RawPathData() : node(SPECIAL_NODEID), segmentWeight(INVALID_EDGE_WEIGHT) {} - RawPathData(NodeID node, EdgeWeight segment_duration) - : node(node), segment_duration(segment_duration) + RawPathData(NodeID node, EdgeWeight segmentWeight) + : node(node), segmentWeight(segmentWeight) { } }; @@ -50,17 +49,17 @@ struct RawPathData /*! * \brief The OSRM routing result struct. Contains the routing result, it's cost and source and * target edges. - * \property m_shortestPathLength Length of a founded route. - * \property m_unpackedPathSegments Segments of a founded route. - * \property m_sourceEdge Source graph node of a route. - * \property m_targetEdge Target graph node of a route. + * \property shortestPathLength Length of a founded route. + * \property unpackedPathSegments Segments of a founded route. + * \property sourceEdge Source graph node of a route. + * \property targetEdge Target graph node of a route. */ struct RawRoutingResult { - int m_shortestPathLength; - vector> m_unpackedPathSegments; - FeatureGraphNode m_sourceEdge; - FeatureGraphNode m_targetEdge; + int shortestPathLength; + vector> unpackedPathSegments; + FeatureGraphNode sourceEdge; + FeatureGraphNode targetEdge; }; //@todo (dragunov) make proper name diff --git a/routing/osrm_router.cpp b/routing/osrm_router.cpp index c6e9c589e6..41e2d13bab 100644 --- a/routing/osrm_router.cpp +++ b/routing/osrm_router.cpp @@ -288,13 +288,13 @@ public: void CalculateOffsets(FeatureGraphNode & node) const { - CalculateOffset(node.m_seg, node.m_segPt, node.m_node.forward_node_id, node.m_node.forward_offset, true); - CalculateOffset(node.m_seg, node.m_segPt, node.m_node.reverse_node_id, node.m_node.reverse_offset, false); + CalculateOffset(node.segment, node.segmentPoint, node.node.forward_node_id, node.node.forward_offset, true); + CalculateOffset(node.segment, node.segmentPoint, node.node.reverse_node_id, node.node.reverse_offset, false); // need to initialize weights for correct work of PhantomNode::GetForwardWeightPlusOffset // and PhantomNode::GetReverseWeightPlusOffset - node.m_node.forward_weight = 0; - node.m_node.reverse_weight = 0; + node.node.forward_weight = 0; + node.node.reverse_weight = 0; } void MakeResult(TFeatureGraphNodeVec & res, size_t maxCount) @@ -356,23 +356,23 @@ public: bool const sameDirection = (m2::DotProduct(featureDirection, m_direction) / (featureDirection.Length() * m_direction.Length()) > 0); if (sameDirection) { - node.m_node.forward_node_id = it->second.first; - node.m_node.reverse_node_id = INVALID_NODE_ID; + node.node.forward_node_id = it->second.first; + node.node.reverse_node_id = INVALID_NODE_ID; } else { - node.m_node.forward_node_id = INVALID_NODE_ID; - node.m_node.reverse_node_id = it->second.second; + node.node.forward_node_id = INVALID_NODE_ID; + node.node.reverse_node_id = it->second.second; } } else { - node.m_node.forward_node_id = it->second.first; - node.m_node.reverse_node_id = it->second.second; + node.node.forward_node_id = it->second.first; + node.node.reverse_node_id = it->second.second; } - node.m_seg = segments[idx]; - node.m_segPt = m_candidates[j].m_point; + node.segment = segments[idx]; + node.segmentPoint = m_candidates[j].m_point; CalculateOffsets(node); } @@ -417,7 +417,7 @@ string OsrmRouter::GetName() const void OsrmRouter::ClearState() { - m_cachedFinalNodes.clear(); + m_CachedTargetTask.clear(); m_indexManager.Clear(); } @@ -437,8 +437,8 @@ size_t OsrmRouter::FindNextMwmNode(OutgoingCrossNode const & startNode, TRouting { m2::PointD const startPoint = startNode.m_point; - auto income_iters = targetMapping->m_crossContext.GetIngoingIterators(); - for (auto i = income_iters.first; i < income_iters.second; ++i) + auto incomeIters = targetMapping->m_crossContext.GetIngoingIterators(); + for (auto i = incomeIters.first; i < incomeIters.second; ++i) { m2::PointD const targetPoint = i->m_point; if (ms::DistanceOnEarth(startPoint.y, startPoint.x, targetPoint.y, targetPoint.x) < FEATURE_BY_POINT_RADIUS_M) @@ -528,9 +528,9 @@ public: : m_targetContext(mapping->m_crossContext), m_mwmName(mapping->GetName()) { - auto income_iterators = m_targetContext.GetIngoingIterators(); - m_sources.reserve(distance(income_iterators.first, income_iterators.second)); - for (auto i = income_iterators.first; i < income_iterators.second; ++i) + auto incomeIterators = m_targetContext.GetIngoingIterators(); + m_sources.reserve(distance(incomeIterators.first, incomeIterators.second)); + for (auto i = incomeIterators.first; i < incomeIterators.second; ++i) m_sources.emplace_back(i->m_nodeId, true); vector weights; @@ -793,7 +793,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint, auto iit = current_in_iterators.first; while (iit < current_in_iterators.second) { - if (iit->m_nodeId == cross.startNode.m_node.forward_node_id) + if (iit->m_nodeId == cross.startNode.node.forward_node_id) break; ++iit; } @@ -912,19 +912,19 @@ OsrmRouter::ResultCode OsrmRouter::MakeTurnAnnotation(RawRoutingResult const & r turns::TurnsGeomT & turnsGeom) { typedef OsrmMappingTypes::FtSeg SegT; - SegT const & segBegin = routingResult.m_sourceEdge.m_seg; - SegT const & segEnd = routingResult.m_targetEdge.m_seg; + SegT const & segBegin = routingResult.sourceEdge.segment; + SegT const & segEnd = routingResult.targetEdge.segment; double estimateTime = 0; - LOG(LDEBUG, ("Shortest path length:", routingResult.m_shortestPathLength)); + LOG(LDEBUG, ("Shortest path length:", routingResult.shortestPathLength)); //! @todo: Improve last segment time calculation CarModel carModel; #ifdef _DEBUG size_t lastIdx = 0; #endif - for (auto const & segment : routingResult.m_unpackedPathSegments) + for (auto const & segment : routingResult.unpackedPathSegments) { INTERRUPT_WHEN_CANCELLED(); @@ -950,7 +950,7 @@ OsrmRouter::ResultCode OsrmRouter::MakeTurnAnnotation(RawRoutingResult const & r } // osrm multiple seconds to 10, so we need to divide it back - double const sTime = TIME_OVERHEAD * path_data.segment_duration / 10.0; + double const sTime = TIME_OVERHEAD * path_data.segmentWeight / 10.0; #ifdef _DEBUG double dist = 0.0; for (size_t l = lastIdx + 1; l < points.size(); ++l) @@ -1038,13 +1038,13 @@ OsrmRouter::ResultCode OsrmRouter::MakeTurnAnnotation(RawRoutingResult const & r if (points.size() < 2) return RouteNotFound; - if (routingResult.m_sourceEdge.m_seg.IsValid()) - points.front() = routingResult.m_sourceEdge.m_segPt; - if (routingResult.m_targetEdge.m_seg.IsValid()) - points.back() = routingResult.m_targetEdge.m_segPt; + if (routingResult.sourceEdge.segment.IsValid()) + points.front() = routingResult.sourceEdge.segmentPoint; + if (routingResult.targetEdge.segment.IsValid()) + points.back() = routingResult.targetEdge.segmentPoint; times.push_back(Route::TimeItemT(points.size() - 1, estimateTime)); - if (routingResult.m_targetEdge.m_seg.IsValid()) + if (routingResult.targetEdge.segment.IsValid()) turnsDir.push_back(TurnItem(points.size() - 1, turns::TurnDirection::ReachedYourDestination)); turns::FixupTurns(points, turnsDir); diff --git a/routing/osrm_router.hpp b/routing/osrm_router.hpp index 80162a1ab9..5595f0ca0e 100644 --- a/routing/osrm_router.hpp +++ b/routing/osrm_router.hpp @@ -63,7 +63,6 @@ public: class OsrmRouter : public IRouter { public: - typedef vector NodeIdVectorT; typedef vector GeomTurnCandidateT; OsrmRouter(Index const * index, TCountryFileFn const & fn, RoutingVisualizerFn routingVisualization = nullptr); @@ -95,14 +94,13 @@ protected: /*! * \brief Compute turn and time estimation structs for OSRM raw route. - * \param routingResult OSRM routing result structure to annotate - * \param mapping Feature mappings - * \param points Unpacked point pathes - * \param requestCancel flag to stop calculation - * \param turnsDir output turns annotation storage - * \param times output times annotation storage - * \param turnsGeom output turns geometry - * \return OSRM routing errors if any + * \param routingResult OSRM routing result structure to annotate. + * \param mapping Feature mappings. + * \param points Storage for unpacked points of the path. + * \param turnsDir output turns annotation storage. + * \param times output times annotation storage. + * \param turnsGeom output turns geometry. + * \return routing operation result code. */ ResultCode MakeTurnAnnotation(RawRoutingResult const & routingResult, TRoutingMappingPtr const & mapping, vector & points, @@ -182,14 +180,9 @@ private: Index const * m_pIndex; - TFeatureGraphNodeVec graphNodes; - TFeatureGraphNodeVec m_CachedTargetTask; m2::PointD m_CachedTargetPoint; RoutingIndexManager m_indexManager; - - m2::PointD m_startPt, m_finalPt, m_startDr; - TFeatureGraphNodeVec m_cachedFinalNodes; }; } // namespace routing