diff --git a/Contractor/EdgeBasedGraphFactory.cpp b/Contractor/EdgeBasedGraphFactory.cpp index 517e1337a..47b5376a9 100644 --- a/Contractor/EdgeBasedGraphFactory.cpp +++ b/Contractor/EdgeBasedGraphFactory.cpp @@ -58,8 +58,8 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vectorisBackward(); edge.data.edgeBasedNodeID = edges.size(); edges.push_back( edge ); - std::swap( edge.source, edge.target ); if( edge.data.backward ) { + std::swap( edge.source, edge.target ); edge.data.forward = i->isBackward(); edge.data.backward = i->isForward(); edge.data.edgeBasedNodeID = edges.size(); @@ -126,15 +126,25 @@ void EdgeBasedGraphFactory::Run() { ++secondRestrictionIterator; } while(u == secondRestrictionIterator->fromNode); } - + if(_nodeBasedGraph->EndEdges(v) == _nodeBasedGraph->BeginEdges(v) + 1 && _nodeBasedGraph->GetEdgeData(e1).type != 14 ) { + EdgeBasedNode currentNode; + currentNode.nameID = _nodeBasedGraph->GetEdgeData(e1).nameID; + currentNode.lat1 = inputNodeInfoList[u].lat; + currentNode.lon1 = inputNodeInfoList[u].lon; + currentNode.lat2 = inputNodeInfoList[v].lat; + currentNode.lon2 = inputNodeInfoList[v].lon; + currentNode.id = _nodeBasedGraph->GetEdgeData(e1).edgeBasedNodeID;; + currentNode.weight = _nodeBasedGraph->GetEdgeData(e1).distance; + edgeBasedNodes.push_back(currentNode); + } for(_NodeBasedDynamicGraph::EdgeIterator e2 = _nodeBasedGraph->BeginEdges(v); e2 < _nodeBasedGraph->EndEdges(v); ++e2) { _NodeBasedDynamicGraph::NodeIterator w = _nodeBasedGraph->GetTarget(e2); //if (u,v,w) is a forbidden turn, continue bool isTurnRestricted(false); if(isOnlyAllowed && w != onlyToNode) { -// INFO("skipped turn <" << u << "," << v << "," << w << ">, only allowing <" << u << "," << v << "," << onlyToNode << ">"); - continue; - } + // INFO("skipped turn <" << u << "," << v << "," << w << ">, only allowing <" << u << "," << v << "," << onlyToNode << ">"); + continue; + } if( u != w ) { //only add an edge if turn is not a U-turn if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) { @@ -151,7 +161,7 @@ void EdgeBasedGraphFactory::Run() { if( !isTurnRestricted || (isOnlyAllowed && w == onlyToNode) ) { //only add an edge if turn is not prohibited if(isOnlyAllowed && w == onlyToNode) { -// INFO("Adding 'only_*'-turn <" << u << "," << v << "," << w << ">"); + // INFO("Adding 'only_*'-turn <" << u << "," << v << "," << w << ">"); } else if(isOnlyAllowed && w != onlyToNode) { assert(false); } @@ -175,9 +185,10 @@ void EdgeBasedGraphFactory::Run() { //create edge-based graph edge EdgeBasedEdge newEdge(edgeBasedSource, edgeBasedTarget, v, nameID, distance, true, false, turnInstruction); edgeBasedEdges.push_back(newEdge); - EdgeBasedNode currentNode; - if(_nodeBasedGraph->GetEdgeData(e1).type != 14) { + if(_nodeBasedGraph->GetEdgeData(e1).type != 14 ) { + EdgeBasedNode currentNode; + currentNode.nameID = _nodeBasedGraph->GetEdgeData(e1).nameID; currentNode.lat1 = inputNodeInfoList[u].lat; currentNode.lon1 = inputNodeInfoList[u].lon; diff --git a/DataStructures/ExtractorCallBacks.h b/DataStructures/ExtractorCallBacks.h index 0face8d56..9d3c0eeb0 100644 --- a/DataStructures/ExtractorCallBacks.h +++ b/DataStructures/ExtractorCallBacks.h @@ -103,7 +103,7 @@ public: std::string route( w.keyVals.Find("route") ); double maxspeed( atoi(w.keyVals.Find("maxspeed").c_str()) ); std::string access( w.keyVals.Find("access") ); - std::string accessClass( w.keyVals.Find(settings.accessTag) ); + std::string accessTag( w.keyVals.Find(settings.accessTag) ); std::string man_made( w.keyVals.Find("man_made") ); std::string barrier( w.keyVals.Find("barrier") ); @@ -135,10 +135,11 @@ public: } } - if("yes" == accessClass || "designated" == accessClass) + if("yes" == accessTag || "designated" == accessTag) w.access = true; - else if("no" == accessClass) - w.access = false; + else if("no" == accessTag) { + return true; + } //Let's process oneway property, if speed profile obeys to it if(oneway != "no" && oneway != "false" && oneway != "0" && settings.obeyOneways) { diff --git a/DataStructures/ExtractorStructs.h b/DataStructures/ExtractorStructs.h index 0cbd7d7f4..864b05761 100644 --- a/DataStructures/ExtractorStructs.h +++ b/DataStructures/ExtractorStructs.h @@ -64,6 +64,13 @@ struct _Coordinate { bool isSet() const { return (INT_MIN != lat) && (INT_MIN != lon); } + inline bool isValid() const { + if(lat > 90*100000 || lat < -90*100000 || lon > 180*100000 || lon <-180*100000) { + return false; + } + return true; + } + }; inline ostream & operator<<(ostream & out, const _Coordinate & c){ diff --git a/DataStructures/GridEdge.h b/DataStructures/GridEdge.h index e1865f6a7..aeb0539fa 100644 --- a/DataStructures/GridEdge.h +++ b/DataStructures/GridEdge.h @@ -29,6 +29,12 @@ struct _GridEdge { int weight; _Coordinate startCoord; _Coordinate targetCoord; + bool operator< ( const _GridEdge& right) const { + return edgeBasedNode < right.edgeBasedNode; + } + bool operator== ( const _GridEdge& right) const { + return edgeBasedNode == right.edgeBasedNode; + } }; struct GridEntry { diff --git a/DataStructures/NNGrid.h b/DataStructures/NNGrid.h index fb79d3400..93cdfb4b2 100644 --- a/DataStructures/NNGrid.h +++ b/DataStructures/NNGrid.h @@ -315,7 +315,7 @@ public: std::swap(resultNode.weight1, resultNode.weight2); } } - if(tmpDist < dist) { + if(tmpDist < dist && !DoubleEpsilonCompare(dist, tmpDist)) { resultNode.Reset(); resultNode.edgeBasedNode = candidate.edgeBasedNode; resultNode.nodeBasedEdgeNameID = candidate.nameID; @@ -346,6 +346,7 @@ public: resultNode.weight2 *= (1-ratio); // INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2); } +// INFO("bidirected: " << (resultNode.isBidirected() ? "yes" : "no") << "\n--") return foundNode; }