[routing][generator] Merge neighbor segments for the same osrm node.

This commit is contained in:
Denis Koronchik 2014-09-11 17:31:37 +03:00 committed by Alex Zolotarev
parent bd1e460ee6
commit 30c187cc90
2 changed files with 33 additions and 4 deletions

View file

@ -114,9 +114,6 @@ void GenerateNodesInfo(string const & mwmName, string const & osrmName)
if (indicies[0] != -1 && indicies[1] != -1)
{
found++;
//LOG(LINFO, ("i1: ", indicies[0], " i2: ", indicies[1], " wayId: ", seg.wayId));
//CHECK(indicies[0] != indicies[1], ());
/*bool canMerge = !vec.empty();
if (canMerge)
{
@ -141,7 +138,9 @@ void GenerateNodesInfo(string const & mwmName, string const & osrmName)
}
if (!canMerge)*/
vec.emplace_back(fID, indicies[0], indicies[1]);
OsrmFtSegMapping::FtSeg ftSeg(fID, indicies[0], indicies[1]);
if (vec.empty() || !vec.back().Merge(ftSeg))
vec.push_back(ftSeg);
}
else

View file

@ -37,6 +37,36 @@ public:
{
}
bool Merge(FtSeg const & other)
{
if (other.m_fid != m_fid)
return false;
if (other.m_pointEnd > other.m_pointStart)
{
if (m_pointStart >= other.m_pointEnd)
return false;
if (other.m_pointStart == m_pointEnd)
{
m_pointEnd = other.m_pointEnd;
return true;
}
}else
{
if (m_pointEnd >= other.m_pointStart)
return false;
if (other.m_pointEnd == m_pointStart)
{
m_pointStart = other.m_pointStart;
return true;
}
}
return false;
}
friend string DebugPrint(FtSeg const & seg)
{
stringstream ss;