Allowing U-Turn at the end of a dead-end street which is necessary for

via routes.
This commit is contained in:
DennisOSRM 2012-01-01 16:04:59 +01:00
parent 62aab1cec6
commit ee1b3afdcf
2 changed files with 7 additions and 2 deletions

View File

@ -159,6 +159,7 @@ void EdgeBasedGraphFactory::Run() {
edgeBasedNodes.push_back(currentNode); edgeBasedNodes.push_back(currentNode);
} }
for(_NodeBasedDynamicGraph::EdgeIterator e2 = _nodeBasedGraph->BeginEdges(v); e2 < _nodeBasedGraph->EndEdges(v); ++e2) { for(_NodeBasedDynamicGraph::EdgeIterator e2 = _nodeBasedGraph->BeginEdges(v); e2 < _nodeBasedGraph->EndEdges(v); ++e2) {
_NodeBasedDynamicGraph::NodeIterator w = _nodeBasedGraph->GetTarget(e2); _NodeBasedDynamicGraph::NodeIterator w = _nodeBasedGraph->GetTarget(e2);
//if (u,v,w) is a forbidden turn, continue //if (u,v,w) is a forbidden turn, continue
@ -169,7 +170,7 @@ void EdgeBasedGraphFactory::Run() {
} }
bool isTurnRestricted(false); bool isTurnRestricted(false);
if( u != w ) { //only add an edge if turn is not a U-turn if( u != w || 1 == _nodeBasedGraph->GetOutDegree(v)) { //only add an edge if turn is not a U-turn except it is the end of dead-end street.
if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) { if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) {
std::vector<_Restriction>::iterator secondRestrictionIterator = restrictionIterator; std::vector<_Restriction>::iterator secondRestrictionIterator = restrictionIterator;
do { do {
@ -245,6 +246,10 @@ void EdgeBasedGraphFactory::Run() {
} }
short EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w) const { short EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w) const {
if(u == w) {
return TurnInstructions.UTurn;
}
_NodeBasedDynamicGraph::EdgeIterator edge1 = _nodeBasedGraph->FindEdge(u, v); _NodeBasedDynamicGraph::EdgeIterator edge1 = _nodeBasedGraph->FindEdge(u, v);
_NodeBasedDynamicGraph::EdgeIterator edge2 = _nodeBasedGraph->FindEdge(v, w); _NodeBasedDynamicGraph::EdgeIterator edge2 = _nodeBasedGraph->FindEdge(v, w);

View File

@ -349,7 +349,7 @@ inline double ApproximateDistance( const int lat1, const int lon1, const int lat
assert(lat2 != INT_MIN); assert(lat2 != INT_MIN);
assert(lon2 != INT_MIN); assert(lon2 != INT_MIN);
static const double DEG_TO_RAD = 0.017453292519943295769236907684886; static const double DEG_TO_RAD = 0.017453292519943295769236907684886;
///Earth's quatratic mean radius for WGS-84 //Earth's quatratic mean radius for WGS-84
static const double EARTH_RADIUS_IN_METERS = 6372797.560856; static const double EARTH_RADIUS_IN_METERS = 6372797.560856;
double latitudeArc = ( lat1/100000. - lat2/100000. ) * DEG_TO_RAD; double latitudeArc = ( lat1/100000. - lat2/100000. ) * DEG_TO_RAD;
double longitudeArc = ( lon1/100000. - lon2/100000. ) * DEG_TO_RAD; double longitudeArc = ( lon1/100000. - lon2/100000. ) * DEG_TO_RAD;