[pedestrian] Follow-up fixes to Dijksta.

This commit is contained in:
Yuri Gorshenin 2015-04-09 16:30:46 +03:00 committed by Alex Zolotarev
parent 7ee966562e
commit ff4962b17b
2 changed files with 14 additions and 13 deletions

View file

@ -40,6 +40,15 @@ void ReconstructPath(RoadPos const & v, map<RoadPos, RoadPos> const & parent,
}
}
struct Vertex
{
Vertex(RoadPos const & pos, double dist) : pos(pos), dist(dist) {}
bool operator<(Vertex const & v) const { return dist > v.dist; }
RoadPos pos;
double dist;
};
} // namespace
IRouter::ResultCode DijkstraRouter::CalculateRouteM2M(vector<RoadPos> const & startPos,
@ -48,10 +57,10 @@ IRouter::ResultCode DijkstraRouter::CalculateRouteM2M(vector<RoadPos> const & st
{
priority_queue<Vertex> queue;
// Upper bound on a distance from start positions to a position.
// Upper bound on the distance from start positions to current vertex.
map<RoadPos, double> dist;
// Parent in a search tree.
// Parent in the search tree.
map<RoadPos, RoadPos> parent;
vector<uint32_t> sortedStartFeatures(startPos.size());
@ -87,6 +96,9 @@ IRouter::ResultCode DijkstraRouter::CalculateRouteM2M(vector<RoadPos> const & st
RoadPos const & pos = turn.m_pos;
if (v.pos == pos)
continue;
// TODO (@gorshenin): distance must be measured in time units,
// so it possibly worth to divide distance by the pedestrian's
// speed.
double const d =
v.dist + MercatorBounds::DistanceOnEarth(v.pos.GetSegEndpoint(), pos.GetSegEndpoint());
auto it = dist.find(pos);

View file

@ -19,16 +19,5 @@ public:
// RoadGraphRouter overrides:
ResultCode CalculateRouteM2M(vector<RoadPos> const & startPos, vector<RoadPos> const & finalPos,
vector<RoadPos> & route) override;
private:
struct Vertex
{
Vertex(RoadPos const & pos, double dist) : pos(pos), dist(dist) {}
bool operator<(Vertex const & v) const { return dist > v.dist; }
RoadPos pos;
double dist;
};
};
} // namespace routing