Merge branch 'master' into rake

This commit is contained in:
Emil Tin 2011-12-05 23:12:23 +01:00
commit fb168536cb
5 changed files with 39 additions and 13 deletions

View File

@ -58,8 +58,8 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg
edge.data.backward = i->isBackward(); edge.data.backward = i->isBackward();
edge.data.edgeBasedNodeID = edges.size(); edge.data.edgeBasedNodeID = edges.size();
edges.push_back( edge ); edges.push_back( edge );
std::swap( edge.source, edge.target );
if( edge.data.backward ) { if( edge.data.backward ) {
std::swap( edge.source, edge.target );
edge.data.forward = i->isBackward(); edge.data.forward = i->isBackward();
edge.data.backward = i->isForward(); edge.data.backward = i->isForward();
edge.data.edgeBasedNodeID = edges.size(); edge.data.edgeBasedNodeID = edges.size();
@ -126,15 +126,25 @@ void EdgeBasedGraphFactory::Run() {
++secondRestrictionIterator; ++secondRestrictionIterator;
} while(u == secondRestrictionIterator->fromNode); } 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) { 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
bool isTurnRestricted(false); bool isTurnRestricted(false);
if(isOnlyAllowed && w != onlyToNode) { if(isOnlyAllowed && w != onlyToNode) {
// INFO("skipped turn <" << u << "," << v << "," << w << ">, only allowing <" << u << "," << v << "," << onlyToNode << ">"); // INFO("skipped turn <" << u << "," << v << "," << w << ">, only allowing <" << u << "," << v << "," << onlyToNode << ">");
continue; continue;
} }
if( u != w ) { //only add an edge if turn is not a U-turn if( u != w ) { //only add an edge if turn is not a U-turn
if(restrictionIterator != inputRestrictions.end() && u == restrictionIterator->fromNode) { 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( !isTurnRestricted || (isOnlyAllowed && w == onlyToNode) ) { //only add an edge if turn is not prohibited
if(isOnlyAllowed && w == onlyToNode) { if(isOnlyAllowed && w == onlyToNode) {
// INFO("Adding 'only_*'-turn <" << u << "," << v << "," << w << ">"); // INFO("Adding 'only_*'-turn <" << u << "," << v << "," << w << ">");
} else if(isOnlyAllowed && w != onlyToNode) { } else if(isOnlyAllowed && w != onlyToNode) {
assert(false); assert(false);
} }
@ -175,9 +185,10 @@ void EdgeBasedGraphFactory::Run() {
//create edge-based graph edge //create edge-based graph edge
EdgeBasedEdge newEdge(edgeBasedSource, edgeBasedTarget, v, nameID, distance, true, false, turnInstruction); EdgeBasedEdge newEdge(edgeBasedSource, edgeBasedTarget, v, nameID, distance, true, false, turnInstruction);
edgeBasedEdges.push_back(newEdge); 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.nameID = _nodeBasedGraph->GetEdgeData(e1).nameID;
currentNode.lat1 = inputNodeInfoList[u].lat; currentNode.lat1 = inputNodeInfoList[u].lat;
currentNode.lon1 = inputNodeInfoList[u].lon; currentNode.lon1 = inputNodeInfoList[u].lon;

View File

@ -103,7 +103,7 @@ public:
std::string route( w.keyVals.Find("route") ); std::string route( w.keyVals.Find("route") );
double maxspeed( atoi(w.keyVals.Find("maxspeed").c_str()) ); double maxspeed( atoi(w.keyVals.Find("maxspeed").c_str()) );
std::string access( w.keyVals.Find("access") ); 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 man_made( w.keyVals.Find("man_made") );
std::string barrier( w.keyVals.Find("barrier") ); 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; w.access = true;
else if("no" == accessClass) else if("no" == accessTag) {
w.access = false; return true;
}
//Let's process oneway property, if speed profile obeys to it //Let's process oneway property, if speed profile obeys to it
if(oneway != "no" && oneway != "false" && oneway != "0" && settings.obeyOneways) { if(oneway != "no" && oneway != "false" && oneway != "0" && settings.obeyOneways) {

View File

@ -64,6 +64,13 @@ struct _Coordinate {
bool isSet() const { bool isSet() const {
return (INT_MIN != lat) && (INT_MIN != lon); 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){ inline ostream & operator<<(ostream & out, const _Coordinate & c){

View File

@ -29,6 +29,12 @@ struct _GridEdge {
int weight; int weight;
_Coordinate startCoord; _Coordinate startCoord;
_Coordinate targetCoord; _Coordinate targetCoord;
bool operator< ( const _GridEdge& right) const {
return edgeBasedNode < right.edgeBasedNode;
}
bool operator== ( const _GridEdge& right) const {
return edgeBasedNode == right.edgeBasedNode;
}
}; };
struct GridEntry { struct GridEntry {

View File

@ -315,7 +315,7 @@ public:
std::swap(resultNode.weight1, resultNode.weight2); std::swap(resultNode.weight1, resultNode.weight2);
} }
} }
if(tmpDist < dist) { if(tmpDist < dist && !DoubleEpsilonCompare(dist, tmpDist)) {
resultNode.Reset(); resultNode.Reset();
resultNode.edgeBasedNode = candidate.edgeBasedNode; resultNode.edgeBasedNode = candidate.edgeBasedNode;
resultNode.nodeBasedEdgeNameID = candidate.nameID; resultNode.nodeBasedEdgeNameID = candidate.nameID;
@ -346,6 +346,7 @@ public:
resultNode.weight2 *= (1-ratio); resultNode.weight2 *= (1-ratio);
// INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2); // INFO("New weight1: " << resultNode.weight1 << ", new weight2: " << resultNode.weight2);
} }
// INFO("bidirected: " << (resultNode.isBidirected() ? "yes" : "no") << "\n--")
return foundNode; return foundNode;
} }