forked from organicmaps/organicmaps-tmp
PR fixes.
This commit is contained in:
parent
bacec3e18d
commit
0eb7a19745
5 changed files with 27 additions and 26 deletions
|
@ -18,14 +18,14 @@ void OutgoingCrossNode::Save(Writer &w) const
|
|||
|
||||
}
|
||||
|
||||
uint32_t OutgoingCrossNode::Load(const Reader &r, size_t pos)
|
||||
size_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<decltype(m_nodeId) *>(&buff[0]);
|
||||
m_point = Int64ToPoint(*reinterpret_cast<uint64_t *>(&(buff[sizeof(m_nodeId)])), g_coordBits);
|
||||
m_outgoingIndex = *reinterpret_cast<decltype(m_outgoingIndex) *>(&(buff[sizeof(m_nodeId) + sizeof(uint64_t)]));
|
||||
return static_cast<uint32_t>(pos + sizeof(buff));
|
||||
return pos + sizeof(buff);
|
||||
}
|
||||
|
||||
void IngoingCrossNode::Save(Writer &w) const
|
||||
|
@ -37,27 +37,27 @@ void IngoingCrossNode::Save(Writer &w) const
|
|||
w.Write(buff, sizeof(buff));
|
||||
}
|
||||
|
||||
uint32_t IngoingCrossNode::Load(const Reader &r, size_t pos)
|
||||
size_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<decltype(m_nodeId) *>(&buff[0]);
|
||||
m_point = Int64ToPoint(*reinterpret_cast<uint64_t *>(&(buff[sizeof(m_nodeId)])), g_coordBits);
|
||||
return static_cast<uint32_t>(pos + sizeof(buff));
|
||||
return pos + sizeof(buff);
|
||||
}
|
||||
|
||||
uint32_t CrossRoutingContextReader::GetIndexInAdjMatrix(IngoingEdgeIteratorT ingoing, OutgoingEdgeIteratorT outgoing) const
|
||||
size_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 static_cast<uint32_t>(m_outgoingNodes.size() * ingoing_index + outgoing_index);
|
||||
return m_outgoingNodes.size() * ingoing_index + outgoing_index;
|
||||
}
|
||||
|
||||
void CrossRoutingContextReader::Load(Reader const & r)
|
||||
{
|
||||
uint32_t size, pos = 0;
|
||||
size_t size, pos = 0;
|
||||
r.Read(pos, &size, sizeof(size));
|
||||
pos += sizeof(size);
|
||||
m_ingoingNodes.resize(size);
|
||||
|
@ -155,12 +155,12 @@ void CrossRoutingContextWriter::Save(Writer & w) const
|
|||
}
|
||||
}
|
||||
|
||||
void CrossRoutingContextWriter::AddIngoingNode(uint32_t const nodeId, m2::PointD const & point)
|
||||
void CrossRoutingContextWriter::AddIngoingNode(WritedNodeID const nodeId, m2::PointD const & point)
|
||||
{
|
||||
m_ingoingNodes.push_back(IngoingCrossNode(nodeId, point));
|
||||
}
|
||||
|
||||
void CrossRoutingContextWriter::AddOutgoingNode(uint32_t const nodeId, string const & targetMwm,
|
||||
void CrossRoutingContextWriter::AddOutgoingNode(WritedNodeID const nodeId, string const & targetMwm,
|
||||
m2::PointD const & point)
|
||||
{
|
||||
auto it = find(m_neighborMwmList.begin(), m_neighborMwmList.end(), targetMwm);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace routing
|
||||
{
|
||||
using WritedNodeID = uint32_t;
|
||||
using WritedEdgeWeightT = uint32_t;
|
||||
static WritedEdgeWeightT const INVALID_CONTEXT_EDGE_WEIGHT = std::numeric_limits<WritedEdgeWeightT>::max();
|
||||
static WritedEdgeWeightT const INVALID_CONTEXT_EDGE_NODE_ID = std::numeric_limits<uint32_t>::max();
|
||||
|
@ -16,30 +17,30 @@ static WritedEdgeWeightT const INVALID_CONTEXT_EDGE_NODE_ID = std::numeric_limit
|
|||
struct IngoingCrossNode
|
||||
{
|
||||
m2::PointD m_point;
|
||||
uint32_t m_nodeId;
|
||||
WritedNodeID m_nodeId;
|
||||
|
||||
IngoingCrossNode() : m_point(m2::PointD::Zero()), m_nodeId(INVALID_CONTEXT_EDGE_NODE_ID) {}
|
||||
IngoingCrossNode(uint32_t nodeId, m2::PointD const & point) :m_point(point), m_nodeId(nodeId) {}
|
||||
IngoingCrossNode(WritedNodeID nodeId, m2::PointD const & point) :m_point(point), m_nodeId(nodeId) {}
|
||||
|
||||
void Save(Writer & w) const;
|
||||
|
||||
uint32_t Load(Reader const & r, size_t pos);
|
||||
size_t Load(Reader const & r, size_t pos);
|
||||
};
|
||||
|
||||
struct OutgoingCrossNode
|
||||
{
|
||||
m2::PointD m_point;
|
||||
uint32_t m_nodeId;
|
||||
WritedNodeID m_nodeId;
|
||||
unsigned char m_outgoingIndex;
|
||||
|
||||
OutgoingCrossNode() : m_point(m2::PointD::Zero()), m_nodeId(INVALID_CONTEXT_EDGE_NODE_ID), m_outgoingIndex(0) {}
|
||||
OutgoingCrossNode(uint32_t nodeId, size_t const index, m2::PointD const & point) : m_point(point),
|
||||
m_nodeId(nodeId),
|
||||
m_outgoingIndex(static_cast<unsigned char>(index)){}
|
||||
OutgoingCrossNode(WritedNodeID nodeId, size_t const index, m2::PointD const & point) : m_point(point),
|
||||
m_nodeId(nodeId),
|
||||
m_outgoingIndex(static_cast<unsigned char>(index)){}
|
||||
|
||||
void Save(Writer & w) const;
|
||||
|
||||
uint32_t Load(Reader const & r, size_t pos);
|
||||
size_t Load(Reader const & r, size_t pos);
|
||||
};
|
||||
|
||||
using IngoingEdgeIteratorT = vector<IngoingCrossNode>::const_iterator;
|
||||
|
@ -53,7 +54,7 @@ class CrossRoutingContextReader
|
|||
vector<string> m_neighborMwmList;
|
||||
unique_ptr<Reader> mp_reader = nullptr;
|
||||
|
||||
uint32_t GetIndexInAdjMatrix(IngoingEdgeIteratorT ingoing, OutgoingEdgeIteratorT outgoing) const;
|
||||
size_t GetIndexInAdjMatrix(IngoingEdgeIteratorT ingoing, OutgoingEdgeIteratorT outgoing) const;
|
||||
|
||||
public:
|
||||
void Load(Reader const & r);
|
||||
|
@ -81,9 +82,9 @@ class CrossRoutingContextWriter
|
|||
public:
|
||||
void Save(Writer & w) const;
|
||||
|
||||
void AddIngoingNode(uint32_t const nodeId, m2::PointD const & point);
|
||||
void AddIngoingNode(WritedNodeID const nodeId, m2::PointD const & point);
|
||||
|
||||
void AddOutgoingNode(uint32_t const nodeId, string const & targetMwm, m2::PointD const & point);
|
||||
void AddOutgoingNode(WritedNodeID const nodeId, string const & targetMwm, m2::PointD const & point);
|
||||
|
||||
void ReserveAdjacencyMatrix();
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ void OsrmFtSegMapping::GetSegmentByIndex(size_t idx, OsrmMappingTypes::FtSeg & s
|
|||
OsrmMappingTypes::FtSeg(m_segments[idx]).Swap(seg);
|
||||
}
|
||||
|
||||
pair<uint32_t, uint32_t> OsrmFtSegMapping::GetSegmentsRange(TOsrmNodeId nodeId) const
|
||||
pair<size_t, size_t> 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)
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
|
||||
template <class ToDo> void ForEachFtSeg(TOsrmNodeId nodeId, ToDo toDo) const
|
||||
{
|
||||
pair<uint32_t, uint32_t> r = GetSegmentsRange(nodeId);
|
||||
pair<size_t, size_t> r = GetSegmentsRange(nodeId);
|
||||
while (r.first != r.second)
|
||||
{
|
||||
OsrmMappingTypes::FtSeg s(m_segments[r.first]);
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
/// @name For unit test purpose only.
|
||||
//@{
|
||||
/// @return STL-like range [s, e) of segments indexies for passed node.
|
||||
pair<uint32_t, uint32_t> GetSegmentsRange(uint32_t nodeId) const;
|
||||
pair<size_t, size_t> GetSegmentsRange(TOsrmNodeId nodeId) const;
|
||||
/// @return Node id for segment's index.
|
||||
TOsrmNodeId GetNodeId(uint32_t segInd) const;
|
||||
|
||||
|
|
|
@ -159,11 +159,11 @@ public:
|
|||
auto const range = m_mapping.GetSegmentsRange(nodeId);
|
||||
OsrmMappingTypes::FtSeg s, cSeg;
|
||||
|
||||
uint32_t si = forward ? range.second - 1 : range.first;
|
||||
uint32_t ei = forward ? range.first - 1 : range.second;
|
||||
size_t si = forward ? range.second - 1 : range.first;
|
||||
size_t ei = forward ? range.first - 1 : range.second;
|
||||
int di = forward ? -1 : 1;
|
||||
|
||||
for (int i = si; i != ei; i += di)
|
||||
for (size_t i = si; i != ei; i += di)
|
||||
{
|
||||
m_mapping.GetSegmentByIndex(i, s);
|
||||
if (!s.IsValid())
|
||||
|
|
Loading…
Add table
Reference in a new issue