From bacec3e18d9c85ba50e93417c1591d8c689916b3 Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Wed, 23 Sep 2015 11:37:56 +0300 Subject: [PATCH] Xcode warnings fixes in routing. --- routing/cross_routing_context.cpp | 16 ++++++++-------- routing/cross_routing_context.hpp | 10 +++++----- routing/nearest_edge_finder.cpp | 2 +- routing/osrm2feature_map.cpp | 8 ++++---- routing/osrm2feature_map.hpp | 6 +++--- routing/osrm_data_facade.hpp | 8 ++++---- routing/osrm_router.cpp | 16 ++++++++-------- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/routing/cross_routing_context.cpp b/routing/cross_routing_context.cpp index c750cd17b5..1f1d186c71 100644 --- a/routing/cross_routing_context.cpp +++ b/routing/cross_routing_context.cpp @@ -18,14 +18,14 @@ void OutgoingCrossNode::Save(Writer &w) const } -size_t OutgoingCrossNode::Load(const Reader &r, size_t pos) +uint32_t OutgoingCrossNode::Load(const Reader &r, size_t pos) { char buff[sizeof(m_nodeId) + sizeof(uint64_t) + sizeof(m_outgoingIndex)]; r.Read(pos, buff, sizeof(buff)); m_nodeId = *reinterpret_cast(&buff[0]); m_point = Int64ToPoint(*reinterpret_cast(&(buff[sizeof(m_nodeId)])), g_coordBits); m_outgoingIndex = *reinterpret_cast(&(buff[sizeof(m_nodeId) + sizeof(uint64_t)])); - return pos + sizeof(buff); + return static_cast(pos + sizeof(buff)); } void IngoingCrossNode::Save(Writer &w) const @@ -37,22 +37,22 @@ void IngoingCrossNode::Save(Writer &w) const w.Write(buff, sizeof(buff)); } -size_t IngoingCrossNode::Load(const Reader &r, size_t pos) +uint32_t IngoingCrossNode::Load(const Reader &r, size_t pos) { char buff[sizeof(m_nodeId) + sizeof(uint64_t)]; r.Read(pos, buff, sizeof(buff)); m_nodeId = *reinterpret_cast(&buff[0]); m_point = Int64ToPoint(*reinterpret_cast(&(buff[sizeof(m_nodeId)])), g_coordBits); - return pos + sizeof(buff); + return static_cast(pos + sizeof(buff)); } -size_t CrossRoutingContextReader::GetIndexInAdjMatrix(IngoingEdgeIteratorT ingoing, OutgoingEdgeIteratorT outgoing) const +uint32_t CrossRoutingContextReader::GetIndexInAdjMatrix(IngoingEdgeIteratorT ingoing, OutgoingEdgeIteratorT outgoing) const { size_t ingoing_index = distance(m_ingoingNodes.cbegin(), ingoing); size_t outgoing_index = distance(m_outgoingNodes.cbegin(), outgoing); ASSERT_LESS(ingoing_index, m_ingoingNodes.size(), ("ingoing index out of range")); ASSERT_LESS(outgoing_index, m_outgoingNodes.size(), ("outgoing index out of range")); - return m_outgoingNodes.size() * ingoing_index + outgoing_index; + return static_cast(m_outgoingNodes.size() * ingoing_index + outgoing_index); } void CrossRoutingContextReader::Load(Reader const & r) @@ -155,12 +155,12 @@ void CrossRoutingContextWriter::Save(Writer & w) const } } -void CrossRoutingContextWriter::AddIngoingNode(size_t const nodeId, m2::PointD const & point) +void CrossRoutingContextWriter::AddIngoingNode(uint32_t const nodeId, m2::PointD const & point) { m_ingoingNodes.push_back(IngoingCrossNode(nodeId, point)); } -void CrossRoutingContextWriter::AddOutgoingNode(size_t const nodeId, string const & targetMwm, +void CrossRoutingContextWriter::AddOutgoingNode(uint32_t const nodeId, string const & targetMwm, m2::PointD const & point) { auto it = find(m_neighborMwmList.begin(), m_neighborMwmList.end(), targetMwm); diff --git a/routing/cross_routing_context.hpp b/routing/cross_routing_context.hpp index 88a7bcf8be..c56d908fdc 100644 --- a/routing/cross_routing_context.hpp +++ b/routing/cross_routing_context.hpp @@ -23,7 +23,7 @@ struct IngoingCrossNode void Save(Writer & w) const; - size_t Load(Reader const & r, size_t pos); + uint32_t Load(Reader const & r, size_t pos); }; struct OutgoingCrossNode @@ -39,7 +39,7 @@ struct OutgoingCrossNode void Save(Writer & w) const; - size_t Load(Reader const & r, size_t pos); + uint32_t Load(Reader const & r, size_t pos); }; using IngoingEdgeIteratorT = vector::const_iterator; @@ -53,7 +53,7 @@ class CrossRoutingContextReader vector m_neighborMwmList; unique_ptr mp_reader = nullptr; - size_t GetIndexInAdjMatrix(IngoingEdgeIteratorT ingoing, OutgoingEdgeIteratorT outgoing) const; + uint32_t GetIndexInAdjMatrix(IngoingEdgeIteratorT ingoing, OutgoingEdgeIteratorT outgoing) const; public: void Load(Reader const & r); @@ -81,9 +81,9 @@ class CrossRoutingContextWriter public: void Save(Writer & w) const; - void AddIngoingNode(size_t const nodeId, m2::PointD const & point); + void AddIngoingNode(uint32_t const nodeId, m2::PointD const & point); - void AddOutgoingNode(size_t const nodeId, string const & targetMwm, m2::PointD const & point); + void AddOutgoingNode(uint32_t const nodeId, string const & targetMwm, m2::PointD const & point); void ReserveAdjacencyMatrix(); diff --git a/routing/nearest_edge_finder.cpp b/routing/nearest_edge_finder.cpp index cf59419d9d..1780d0fa8d 100644 --- a/routing/nearest_edge_finder.cpp +++ b/routing/nearest_edge_finder.cpp @@ -43,7 +43,7 @@ void NearestEdgeFinder::AddInformationSource(FeatureID const & featureId, IRoadG { res.m_dist = d; res.m_fid = featureId; - res.m_segId = i - 1; + res.m_segId = static_cast(i - 1); res.m_segStart = roadInfo.m_points[i - 1]; res.m_segEnd = roadInfo.m_points[i]; res.m_point = pt; diff --git a/routing/osrm2feature_map.cpp b/routing/osrm2feature_map.cpp index ecfcea1638..47317f8771 100644 --- a/routing/osrm2feature_map.cpp +++ b/routing/osrm2feature_map.cpp @@ -205,7 +205,7 @@ void OsrmFtSegMapping::GetOsrmNodes(FtSegSetT & segments, OsrmNodesT & res) cons for (uint32_t nodeId : nodeIds) { auto const & range = GetSegmentsRange(nodeId); - for (int i = range.first; i != range.second; ++i) + for (size_t i = range.first; i != range.second; ++i) { OsrmMappingTypes::FtSeg const s(m_segments[i]); if (s.m_fid != seg.m_fid) @@ -242,7 +242,7 @@ void OsrmFtSegMapping::GetSegmentByIndex(size_t idx, OsrmMappingTypes::FtSeg & s OsrmMappingTypes::FtSeg(m_segments[idx]).Swap(seg); } -pair OsrmFtSegMapping::GetSegmentsRange(TOsrmNodeId nodeId) const +pair OsrmFtSegMapping::GetSegmentsRange(TOsrmNodeId nodeId) const { SegOffsetsT::const_iterator it = lower_bound(m_offsets.begin(), m_offsets.end(), OsrmMappingTypes::SegOffset(nodeId, 0), [] (OsrmMappingTypes::SegOffset const & o, OsrmMappingTypes::SegOffset const & val) @@ -259,7 +259,7 @@ pair OsrmFtSegMapping::GetSegmentsRange(TOsrmNodeId nodeId) cons return make_pair(start, start + 1); } -TOsrmNodeId OsrmFtSegMapping::GetNodeId(size_t segInd) const +TOsrmNodeId OsrmFtSegMapping::GetNodeId(uint32_t segInd) const { SegOffsetsT::const_iterator it = lower_bound(m_offsets.begin(), m_offsets.end(), OsrmMappingTypes::SegOffset(segInd, 0), [] (OsrmMappingTypes::SegOffset const & o, OsrmMappingTypes::SegOffset const & val) @@ -422,7 +422,7 @@ void OsrmFtSegBackwardIndex::Construct(OsrmFtSegMapping & mapping, uint32_t maxN size_t removedNodes = 0; for (size_t i = 0; i < m_table->size(); ++i) { - uint32_t const fid = m_oldFormat ? m_table->GetFeatureOffset(i) : i; + uint32_t const fid = m_oldFormat ? m_table->GetFeatureOffset(i) : static_cast(i); auto it = temporaryBackwardIndex.find(fid); if (it != temporaryBackwardIndex.end()) { diff --git a/routing/osrm2feature_map.hpp b/routing/osrm2feature_map.hpp index cfe0a046e9..6971a9f416 100644 --- a/routing/osrm2feature_map.hpp +++ b/routing/osrm2feature_map.hpp @@ -136,7 +136,7 @@ public: template void ForEachFtSeg(TOsrmNodeId nodeId, ToDo toDo) const { - pair r = GetSegmentsRange(nodeId); + pair r = GetSegmentsRange(nodeId); while (r.first != r.second) { OsrmMappingTypes::FtSeg s(m_segments[r.first]); @@ -164,9 +164,9 @@ public: /// @name For unit test purpose only. //@{ /// @return STL-like range [s, e) of segments indexies for passed node. - pair GetSegmentsRange(uint32_t nodeId) const; + pair GetSegmentsRange(uint32_t nodeId) const; /// @return Node id for segment's index. - TOsrmNodeId GetNodeId(size_t segInd) const; + TOsrmNodeId GetNodeId(uint32_t segInd) const; size_t GetSegmentsCount() const { return static_cast(m_segments.size()); } //@} diff --git a/routing/osrm_data_facade.hpp b/routing/osrm_data_facade.hpp index 36da8bea41..c25b1cff2f 100644 --- a/routing/osrm_data_facade.hpp +++ b/routing/osrm_data_facade.hpp @@ -93,10 +93,10 @@ public: EdgeDataT res; res.shortcut = m_shortcuts[e]; - res.id = res.shortcut ? (node - bits::ZigZagDecode(m_edgeId[m_shortcuts.rank(e)])) : 0; + res.id = res.shortcut ? (node - static_cast(bits::ZigZagDecode(m_edgeId[m_shortcuts.rank(e)]))) : 0; res.backward = (m_matrix.select(e) % 2 == 1); res.forward = !res.backward; - res.distance = m_edgeData[e]; + res.distance = static_cast(m_edgeData[e]); return res; } @@ -117,13 +117,13 @@ public: EdgeID BeginEdges(const NodeID n) const override { uint64_t idx = 2 * n * (uint64_t)GetNumberOfNodes(); - return n == 0 ? 0 : m_matrix.rank(min(idx, m_matrix.size())); + return n == 0 ? 0 : static_cast(m_matrix.rank(min(idx, m_matrix.size()))); } EdgeID EndEdges(const NodeID n) const override { uint64_t const idx = 2 * (n + 1) * (uint64_t)GetNumberOfNodes(); - return m_matrix.rank(min(idx, m_matrix.size())); + return static_cast(m_matrix.rank(min(idx, m_matrix.size()))); } EdgeRange GetAdjacentEdgeRange(const NodeID node) const override diff --git a/routing/osrm_router.cpp b/routing/osrm_router.cpp index e741254b41..37b9fb03a7 100644 --- a/routing/osrm_router.cpp +++ b/routing/osrm_router.cpp @@ -95,7 +95,7 @@ public: { res.m_dist = d; res.m_fid = featureId; - res.m_segIdx = i - 1; + res.m_segIdx = static_cast(i - 1); res.m_point = pt; } } @@ -159,8 +159,8 @@ public: auto const range = m_mapping.GetSegmentsRange(nodeId); OsrmMappingTypes::FtSeg s, cSeg; - int si = forward ? range.second - 1 : range.first; - int ei = forward ? range.first - 1 : range.second; + uint32_t si = forward ? range.second - 1 : range.first; + uint32_t ei = forward ? range.first - 1 : range.second; int di = forward ? -1 : 1; for (int i = si; i != ei; i += di) @@ -372,7 +372,7 @@ bool OsrmRouter::FindRouteFromCases(TFeatureGraphNodeVec const & source, return false; } -void FindGraphNodeOffsets(size_t const nodeId, m2::PointD const & point, +void FindGraphNodeOffsets(uint32_t const nodeId, m2::PointD const & point, Index const * pIndex, TRoutingMappingPtr & mapping, FeatureGraphNode & graphNode) { @@ -419,7 +419,7 @@ void CalculatePhantomNodeForCross(TRoutingMappingPtr & mapping, FeatureGraphNode if (graphNode.segment.IsValid()) return; - size_t nodeId; + uint32_t nodeId; if (forward) nodeId = graphNode.node.forward_node_id; else @@ -497,7 +497,7 @@ OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(TCheckedPath const & vector mwmPoints; MakeTurnAnnotation(routingResult, mwmMapping, delegate, mwmPoints, mwmTurnsDir, mwmTimes); // Connect annotated route. - const uint32_t pSize = Points.size(); + const uint32_t pSize = static_cast(Points.size()); for (auto turn : mwmTurnsDir) { if (turn.m_index == 0) @@ -712,7 +712,7 @@ OsrmRouter::ResultCode OsrmRouter::MakeTurnAnnotation( if (j > 0 && !points.empty()) { turns::TurnItem t; - t.m_index = points.size() - 1; + t.m_index = static_cast(points.size() - 1); turns::TurnInfo turnInfo(*mapping, segment[j - 1].node, segment[j].node); turns::GetTurnDirection(*m_pIndex, turnInfo, t); @@ -827,7 +827,7 @@ OsrmRouter::ResultCode OsrmRouter::MakeTurnAnnotation( if (routingResult.targetEdge.segment.IsValid()) { turnsDir.push_back( - turns::TurnItem(points.size() - 1, turns::TurnDirection::ReachedYourDestination)); + turns::TurnItem(static_cast(points.size() - 1), turns::TurnDirection::ReachedYourDestination)); } turns::FixupTurns(points, turnsDir);