diff --git a/generator/routing_generator.cpp b/generator/routing_generator.cpp index 7bbcd67dc8..8168fc3125 100644 --- a/generator/routing_generator.cpp +++ b/generator/routing_generator.cpp @@ -157,12 +157,12 @@ void BuildRoutingIndex(string const & baseDir, string const & countryName, strin // Check if we have geometry for our candidate if (osm2ft.GetFeatureID(startSeg.wayId) || osm2ft.GetFeatureID(endSeg.wayId)) { - m2::PointD pts[2] = { { startSeg.lon1, startSeg.lat1 }, { endSeg.lon2, endSeg.lat2 } }; + m2::PointD const pts[2] = { { startSeg.lon1, startSeg.lat1 }, { endSeg.lon2, endSeg.lat2 } }; // check nearest to goverment borders for (m2::RegionD const& border: regionBorders) { - bool outStart = border.Contains(pts[0]), outEnd = border.Contains(pts[1]); + bool const outStart = border.Contains(pts[0]), outEnd = border.Contains(pts[1]); if (outStart == true && outEnd == false) { string mwmName; @@ -182,7 +182,7 @@ void BuildRoutingIndex(string const & baseDir, string const & countryName, strin for (auto const & seg : data.m_segments) { - m2::PointD pts[2] = { { seg.lon1, seg.lat1 }, { seg.lon2, seg.lat2 } }; + m2::PointD const pts[2] = { { seg.lon1, seg.lat1 }, { seg.lon2, seg.lat2 } }; ++all; // now need to determine feature id and segments in it @@ -348,11 +348,11 @@ void BuildRoutingIndex(string const & baseDir, string const & countryName, strin auto in = crossContext.GetIngoingIterators(); auto out = crossContext.GetOutgoingIterators(); MultiroutingTaskPointT sources(distance(in.first, in.second)), targets(distance(out.first, out.second)); - for (auto i=in.first; ifirst, targets[distance(out.first, i)]); } @@ -360,8 +360,8 @@ void BuildRoutingIndex(string const & baseDir, string const & countryName, strin vector costs; OsrmRouter::FindWeightsMatrix(sources, targets, facade, costs); auto res = costs.begin(); - for (auto i=in.first; igetMwmIdByName(mwmName); @@ -507,14 +507,14 @@ bool IsRouteExist(RawRouteData const & r) MultiroutingTaskPointT::const_iterator OsrmRouter::FilterWeightsMatrix(MultiroutingTaskPointT const & sources, MultiroutingTaskPointT const & targets, std::vector &weightMatrix) { - for (size_t i=0; ibegin()+sources.size(); - for(int i=0; imapping.GetSegmentsRange(node_id); + auto nSegs = routingMapping->m_segMapping.GetSegmentsRange(node_id); ASSERT_GREATER(nSegs.second, 0, ()); OsrmFtSegMapping::FtSeg seg; if (use_start) - routingMapping->mapping.GetSegmentByIndex(nSegs.first, seg); + routingMapping->m_segMapping.GetSegmentByIndex(nSegs.first, seg); else - routingMapping->mapping.GetSegmentByIndex(nSegs.second - 1, seg); + routingMapping->m_segMapping.GetSegmentByIndex(nSegs.second - 1, seg); if (seg.m_fid == OsrmFtSegMapping::FtSeg::INVALID_FID) return m2::PointD::Zero(); @@ -638,9 +638,9 @@ size_t OsrmRouter::FindNextMwmNode(RoutingMappingPtrT const & startMapping, size m2::PointD startPointEnd = GetPointByNodeId(startId, startMapping, false); startPointStart = {MercatorBounds::XToLon(startPointStart.x), MercatorBounds::YToLat(startPointStart.y)}; startPointEnd = {MercatorBounds::XToLon(startPointEnd.x), MercatorBounds::YToLat(startPointEnd.y)}; - CrossRoutingContext const & targetContext = targetMapping->dataFacade.getRoutingContext(); + CrossRoutingContext const & targetContext = targetMapping->m_dataFacade.getRoutingContext(); auto income_iters = targetContext.GetIngoingIterators(); - for (auto i=income_iters.first; iLoadFacade(); - if (!FindSingleRoute(startTask, targetTask, mwmMapping->dataFacade, routingResult)) + if (!FindSingleRoute(startTask, targetTask, mwmMapping->m_dataFacade, routingResult)) { mwmMapping->FreeFacade(); return OsrmRouter::RouteNotFound; @@ -699,15 +699,15 @@ OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(CheckedPathT const & MakeTurnAnnotation(routingResult, mwmMapping, mwmPoints, mwmTurnsDir, mwmTimes, mwmTurnsGeom); //And connect it to result route - for (auto turn:mwmTurnsDir) + for (auto turn : mwmTurnsDir) { turn.m_index += Points.size() - 1; TurnsDir.push_back(turn); } - double const estimationTime = Times.size() ? Times.back().second :0.0; - for (auto time:mwmTimes) + double const estimationTime = Times.size() ? Times.back().second : 0.0; + for (auto time : mwmTimes) { time.first += Points.size() - 1; time.second += estimationTime; @@ -743,30 +743,30 @@ class OsrmRouter::LastCrossFinder { vector m_weights; public: - LastCrossFinder(RoutingMappingPtrT & mapping, FeatureGraphNodeVecT const & targetTask):m_targetContext(mapping->dataFacade.getRoutingContext()), m_mwmName(mapping->GetName()) + LastCrossFinder(RoutingMappingPtrT & mapping, FeatureGraphNodeVecT const & targetTask):m_targetContext(mapping->m_dataFacade.getRoutingContext()), m_mwmName(mapping->GetName()) { auto income_iterators = m_targetContext.GetIngoingIterators(); MultiroutingTaskPointT targets; m_sources.resize(distance(income_iterators.first, income_iterators.second)); - for (auto i = income_iterators.first; i weights; - OsrmRouter::FindWeightsMatrix(m_sources, targets, mapping->dataFacade, weights); + OsrmRouter::FindWeightsMatrix(m_sources, targets, mapping->m_dataFacade, weights); - for (size_t i=0; i-1; --k) + for (int k = m_sources.size() - 1; k > -1; --k) { - weights.erase(weights.begin()+k*targets.size(), weights.begin()+k*targets.size()+i); - weights.erase(weights.begin()+k*targets.size()+i+1, weights.begin()+(k+1)*targets.size()); + weights.erase(weights.begin() + k*targets.size(), weights.begin() + k*targets.size() + i); + weights.erase(weights.begin() + k*targets.size() + i + 1, weights.begin() + (k + 1) * targets.size()); } - ASSERT(weights.size()==m_sources.size(), ()); + ASSERT(weights.size() == m_sources.size(), ()); m_target = targets[i]; m_weights.swap(weights); return; @@ -833,7 +833,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRouteImpl(m2::PointD const & startPt if (startMapping->GetName() == targetMapping->GetName()) { LOG(LINFO, ("Single mwm routing case")); - if (!FindSingleRoute(startTask, m_CachedTargetTask, startMapping->dataFacade, routingResult)) + if (!FindSingleRoute(startTask, m_CachedTargetTask, startMapping->m_dataFacade, routingResult)) { return RouteNotFound; } @@ -863,16 +863,16 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRouteImpl(m2::PointD const & startPt LOG(LINFO, ("Different mwm routing case")); // Load source data - CrossRoutingContext const & startContext = startMapping->dataFacade.getRoutingContext(); + CrossRoutingContext const & startContext = startMapping->m_dataFacade.getRoutingContext(); auto out_iterators = startContext.GetOutgoingIterators(); MultiroutingTaskPointT sources, targets(distance(out_iterators.first, out_iterators.second)); - for (auto i = out_iterators.first; ifirst, targets[distance(out_iterators.first, i)]); - for (auto t: startTask) + for (auto t : startTask) sources.push_back(t); vector weights; - FindWeightsMatrix(sources, targets, startMapping->dataFacade, weights); + FindWeightsMatrix(sources, targets, startMapping->m_dataFacade, weights); auto sourceNodeIter = FilterWeightsMatrix(sources, targets,weights); @@ -892,7 +892,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRouteImpl(m2::PointD const & startPt CheckedOutsT checkedOuts; //Submit tasks from source - for (size_t j=0; jdataFacade.getRoutingContext(); + CrossRoutingContext const & currentContext = currentMapping->m_dataFacade.getRoutingContext(); auto current_in_iterators = currentContext.GetIngoingIterators(); auto current_out_iterators = currentContext.GetOutgoingIterators(); @@ -971,7 +971,7 @@ OsrmRouter::ResultCode OsrmRouter::CalculateRouteImpl(m2::PointD const & startPt ASSERT(iit != current_in_iterators.second, ()); //find outs - for (auto oit=current_out_iterators.first; oit!= current_out_iterators.second; ++oit) + for (auto oit = current_out_iterators.first; oit != current_out_iterators.second; ++oit) { const EdgeWeight outWeight = currentContext.getAdjacencyCost(iit, oit); if (outWeight != INVALID_EDGE_WEIGHT) @@ -1122,7 +1122,7 @@ OsrmRouter::ResultCode OsrmRouter::MakeTurnAnnotation(RawRoutingResultT const & } buffer_vector buffer; - mapping->mapping.ForEachFtSeg(path_data.node, MakeBackInsertFunctor(buffer)); + mapping->m_segMapping.ForEachFtSeg(path_data.node, MakeBackInsertFunctor(buffer)); auto correctFn = [&buffer] (SegT const & seg, size_t & ind) { @@ -1246,14 +1246,14 @@ NodeID OsrmRouter::GetTurnTargetNode(NodeID src, NodeID trg, QueryEdge::EdgeData if (!edgeData.shortcut) return trg; - ASSERT_LESS(edgeData.id, routingMapping->dataFacade.GetNumberOfNodes(), ()); + ASSERT_LESS(edgeData.id, routingMapping->m_dataFacade.GetNumberOfNodes(), ()); EdgeID edge = SPECIAL_EDGEID; QueryEdge::EdgeData d; - for (EdgeID e : routingMapping->dataFacade.GetAdjacentEdgeRange(edgeData.id)) + for (EdgeID e : routingMapping->m_dataFacade.GetAdjacentEdgeRange(edgeData.id)) { - if (routingMapping->dataFacade.GetTarget(e) == src ) + if (routingMapping->m_dataFacade.GetTarget(e) == src ) { - d = routingMapping->dataFacade.GetEdgeData(e, edgeData.id); + d = routingMapping->m_dataFacade.GetEdgeData(e, edgeData.id); if (d.backward) { edge = e; @@ -1264,11 +1264,11 @@ NodeID OsrmRouter::GetTurnTargetNode(NodeID src, NodeID trg, QueryEdge::EdgeData if (edge == SPECIAL_EDGEID) { - for (EdgeID e : routingMapping->dataFacade.GetAdjacentEdgeRange(src)) + for (EdgeID e : routingMapping->m_dataFacade.GetAdjacentEdgeRange(src)) { - if (routingMapping->dataFacade.GetTarget(e) == edgeData.id) + if (routingMapping->m_dataFacade.GetTarget(e) == edgeData.id) { - d = routingMapping->dataFacade.GetEdgeData(e, src); + d = routingMapping->m_dataFacade.GetEdgeData(e, src); if (d.forward) { edge = e; @@ -1292,18 +1292,18 @@ void OsrmRouter::GetPossibleTurns(NodeID node, OsrmRouter::TurnCandidatesT & candidates) { - for (EdgeID e : routingMapping->dataFacade.GetAdjacentEdgeRange(node)) + for (EdgeID e : routingMapping->m_dataFacade.GetAdjacentEdgeRange(node)) { - QueryEdge::EdgeData const data = routingMapping->dataFacade.GetEdgeData(e, node); + QueryEdge::EdgeData const data = routingMapping->m_dataFacade.GetEdgeData(e, node); if (!data.forward) continue; - NodeID trg = GetTurnTargetNode(node, routingMapping->dataFacade.GetTarget(e), data, routingMapping); + NodeID trg = GetTurnTargetNode(node, routingMapping->m_dataFacade.GetTarget(e), data, routingMapping); ASSERT_NOT_EQUAL(trg, SPECIAL_NODEID, ()); - auto const range = routingMapping->mapping.GetSegmentsRange(trg); + auto const range = routingMapping->m_segMapping.GetSegmentsRange(trg); OsrmFtSegMapping::FtSeg seg; - routingMapping->mapping.GetSegmentByIndex(range.first, seg); + routingMapping->m_segMapping.GetSegmentByIndex(range.first, seg); FeatureType ft; Index::FeaturesLoaderGuard loader(*m_pIndex, routingMapping->GetMwmId()); @@ -1468,14 +1468,14 @@ void OsrmRouter::GetTurnDirection(PathData const & node1, PathData const & node2, RoutingMappingPtrT const & routingMapping, Route::TurnItem & turn) { - auto nSegs1 = routingMapping->mapping.GetSegmentsRange(node1.node); - auto nSegs2 = routingMapping->mapping.GetSegmentsRange(node2.node); + auto nSegs1 = routingMapping->m_segMapping.GetSegmentsRange(node1.node); + auto nSegs2 = routingMapping->m_segMapping.GetSegmentsRange(node2.node); ASSERT_GREATER(nSegs1.second, 0, ()); OsrmFtSegMapping::FtSeg seg1, seg2; - routingMapping->mapping.GetSegmentByIndex(nSegs1.second - 1, seg1); - routingMapping->mapping.GetSegmentByIndex(nSegs2.first, seg2); + routingMapping->m_segMapping.GetSegmentByIndex(nSegs1.second - 1, seg1); + routingMapping->m_segMapping.GetSegmentByIndex(nSegs2.first, seg2); FeatureType ft1, ft2; Index::FeaturesLoaderGuard loader1(*m_pIndex, routingMapping->GetMwmId()); @@ -1680,7 +1680,7 @@ void OsrmRouter::FixupTurns(vector const & points, Route::TurnsT & t IRouter::ResultCode OsrmRouter::FindPhantomNodes(string const & fName, m2::PointD const & point, m2::PointD const & direction, FeatureGraphNodeVecT & res, size_t maxCount, RoutingMappingPtrT const & mapping) { - Point2PhantomNode getter(mapping->mapping, m_pIndex, direction); + Point2PhantomNode getter(mapping->m_segMapping, m_pIndex, direction); getter.SetPoint(point); m_pIndex->ForEachInRectForMWM(getter, diff --git a/routing/osrm_router.hpp b/routing/osrm_router.hpp index 67ef03dba9..cd84e86b9b 100644 --- a/routing/osrm_router.hpp +++ b/routing/osrm_router.hpp @@ -60,8 +60,8 @@ typedef vector MultipleRoutingResultT; ///Datamapping and facade for single MWM and MWM.routing file struct RoutingMapping { - DataFacadeT dataFacade; - OsrmFtSegMapping mapping; + DataFacadeT m_dataFacade; + OsrmFtSegMapping m_segMapping; ///@param fName: mwm file path RoutingMapping(string const & fName, Index const * pIndex); @@ -69,47 +69,47 @@ struct RoutingMapping ~RoutingMapping() { // Clear data while m_container is valid. - dataFacade.Clear(); - mapping.Clear(); + m_dataFacade.Clear(); + m_segMapping.Clear(); m_container.Close(); } void Map() { - ++map_counter; - if (!mapping.IsMapped()) - mapping.Map(m_container); + ++m_mapCounter; + if (!m_segMapping.IsMapped()) + m_segMapping.Map(m_container); } void Unmap() { - --map_counter; - if (map_counter < 1 && mapping.IsMapped()) - mapping.Unmap(); + --m_mapCounter; + if (m_mapCounter < 1 && m_segMapping.IsMapped()) + m_segMapping.Unmap(); } void LoadFacade() { - if (!facade_counter) - dataFacade.Load(m_container); - ++facade_counter; + if (!m_facadeCounter) + m_dataFacade.Load(m_container); + ++m_facadeCounter; } void FreeFacade() { - --facade_counter; - if (!facade_counter) - dataFacade.Clear(); + --m_facadeCounter; + if (!m_facadeCounter) + m_dataFacade.Clear(); } - string GetName() {return m_base_name;} + string GetName() {return m_baseName;} Index::MwmId GetMwmId() {return m_mwmId;} private: - size_t map_counter; - size_t facade_counter; - string m_base_name; + size_t m_mapCounter; + size_t m_facadeCounter; + string m_baseName; FilesMappingContainer m_container; Index::MwmId m_mwmId; }; diff --git a/routing/routing.pro b/routing/routing.pro index 7cf406b304..9962214fba 100644 --- a/routing/routing.pro +++ b/routing/routing.pro @@ -29,4 +29,4 @@ HEADERS += \ osrm_data_facade.hpp \ osrm2feature_map.hpp \ vehicle_model.hpp \ - cross_routing_context.hpp + cross_routing_context.hpp \