Permalink
Browse files

mode for each direction of a way

  • Loading branch information...
1 parent 97f5107 commit 79a8360e6ae4e3c7abd2c14b13db30c5380f0c3a @emiltin emiltin committed Apr 1, 2013
@@ -76,8 +76,12 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg
edge.data.contraFlow = i->isContraFlow();
edge.data.mode = i->mode();
+ INFO("EdgeBasedGraphFactory constr, mode: " << (long)edge.data.mode );
+ //INFO("i forw: " << i->isForward() << ", i backw: " << i->isBackward() );
+ //INFO("edge.data forw: " << edge.data.forward << ", edge.data backw: " << edge.data.backward );
edges.push_back( edge );
if( edge.data.backward ) {
+ INFO("push backward xxxxx" );
std::swap( edge.source, edge.target );
edge.data.forward = i->isBackward();
edge.data.backward = i->isForward();
@@ -151,6 +155,7 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(
currentNode.weight = data.distance;
currentNode.mode = data.mode;
+ INFO( "InsertEdgeBasedNode, mode: " << (long)data.mode );
edgeBasedNodes.push_back(currentNode);
}
@@ -279,9 +284,8 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename, lua_State
}
unsigned penalty = 0;
bool contraflow;
- unsigned char mode;
- TurnInstruction turnInstruction = AnalyzeTurn(u, v, w, contraflow, mode, penalty, myLuaState);
+ TurnInstruction turnInstruction = AnalyzeTurn(u, v, w, contraflow, penalty, myLuaState);
if(turnInstruction == TurnInstructions.UTurn)
distance += speedProfile.uTurnPenalty;
// if(!edgeData1.isAccessRestricted && edgeData2.isAccessRestricted) {
@@ -290,6 +294,7 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename, lua_State
// }
distance += penalty;
+ unsigned char mode = _nodeBasedGraph->GetEdgeData(e1).mode;
//distance += heightPenalty;
//distance += ComputeTurnPenalty(u, v, w);
@@ -303,7 +308,7 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename, lua_State
original_edge_data_vector.clear();
}
- EdgeBasedEdge newEdge(edgeData1.edgeBasedNodeID, edgeData2.edgeBasedNodeID, edgeBasedEdges.size(), distance, true, false, mode );
+ EdgeBasedEdge newEdge(edgeData1.edgeBasedNodeID, edgeData2.edgeBasedNodeID, edgeBasedEdges.size(), distance, true, false );
edgeBasedEdges.push_back(newEdge);
} else {
++numberOfSkippedTurns;
@@ -333,7 +338,7 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename, lua_State
INFO("Generated " << edgeBasedNodes.size() << " edge based nodes");
}
-TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w, bool& contraflow, unsigned char& mode, unsigned& penalty, lua_State *myLuaState) const {
+TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w, bool& contraflow, unsigned& penalty, lua_State *myLuaState) const {
const double angle = GetAngleBetweenTwoEdges(inputNodeInfoList[u], inputNodeInfoList[v], inputNodeInfoList[w]);
if( speedProfile.has_turn_penalty_function ) {
@@ -360,8 +365,6 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID
contraflow = data2.contraFlow;
- mode = data1.mode;
-
//roundabouts need to be handled explicitely
if(data1.roundabout && data2.roundabout) {
//Is a turn possible? If yes, we stay on the roundabout!
@@ -150,7 +150,7 @@ class EdgeBasedGraphFactory : boost::noncopyable {
void GetEdgeBasedEdges( DeallocatingVector< EdgeBasedEdge >& edges );
void GetEdgeBasedNodes( DeallocatingVector< EdgeBasedNode> & nodes);
void GetOriginalEdgeData( std::vector< OriginalEdgeData> & originalEdgeData);
- TurnInstruction AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w, bool& contraflow, unsigned char& mode, unsigned& penalty, lua_State *myLuaState) const;
+ TurnInstruction AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w, bool& contraflow, unsigned& penalty, lua_State *myLuaState) const;
unsigned GetNumberOfNodes() const;
};
@@ -79,7 +79,7 @@ class DynamicGraph {
for ( NodeIterator node = 0; node < m_numNodes; ++node ) {
for ( EdgeIterator i = m_nodes[node].firstEdge, e = m_nodes[node].firstEdge + m_nodes[node].edges; i != e; ++i ) {
m_edges[i].target = graph[edge].target;
- m_edges[i].data = graph[edge].data;
+ m_edges[i].data = graph[edge].data;
GUARANTEE(graph[edge].data.distance > 0, "edge: " << edge << "(" << graph[edge].source << "," << graph[edge].target << ")=" << graph[edge].data.distance);
++edge;
}
@@ -102,8 +102,7 @@ class EdgeBasedEdge {
m_edgeID(myEdge.data.via),
m_weight(myEdge.data.distance),
m_forward(myEdge.data.forward),
- m_backward(myEdge.data.backward),
- m_mode(myEdge.data.mode)
+ m_backward(myEdge.data.backward)
{ }
/** Default constructor. target and weight are set to 0.*/
@@ -113,18 +112,16 @@ class EdgeBasedEdge {
m_edgeID(0),
m_weight(0),
m_forward(false),
- m_backward(false),
- m_mode(0)
+ m_backward(false)
{ }
- explicit EdgeBasedEdge(const NodeID s, const NodeID t, const NodeID v, const EdgeWeight w, const bool f, const bool b, unsigned char _mode) :
+ explicit EdgeBasedEdge(const NodeID s, const NodeID t, const NodeID v, const EdgeWeight w, const bool f, const bool b) :
m_source(s),
m_target(t),
m_edgeID(v),
m_weight(w),
m_forward(f),
- m_backward(b),
- m_mode(_mode)
+ m_backward(b)
{}
NodeID target() const {return m_target; }
@@ -133,7 +130,6 @@ class EdgeBasedEdge {
NodeID id() const { return m_edgeID; }
bool isBackward() const { return m_backward; }
bool isForward() const { return m_forward; }
- unsigned char mode() const { return m_mode; };
private:
NodeID m_source;
@@ -142,7 +138,6 @@ class EdgeBasedEdge {
EdgeWeight m_weight:30;
bool m_forward:1;
bool m_backward:1;
- unsigned char m_mode;
};
typedef NodeBasedEdge ImportEdge;
@@ -73,6 +73,7 @@ class NodeInformationHelpDesk : boost::noncopyable{
origEdgeData_nameID[i] = deserialized_originalEdgeData.nameID;
origEdgeData_turnInstruction[i] = deserialized_originalEdgeData.turnInstruction;
origEdgeData_mode[i] = deserialized_originalEdgeData.mode;
+ INFO( "info desk load, i: " << i << ", mode: " << (long)origEdgeData_mode[i] );
}
edgesInStream.close();
DEBUG("Loaded " << numberOfOrigEdges << " orig edges");
@@ -258,8 +258,6 @@ void ExtractionContainers::PrepareData(const std::string & outputFileName, const
fout.write((char*)&edgeIT->isAccessRestricted, sizeof(bool));
fout.write((char*)&edgeIT->isContraFlow, sizeof(bool));
fout.write((char*)&edgeIT->mode, sizeof(unsigned char));
-
- INFO( "writing edge, id: " << nodesIT->id << ", mode: " << (long)edgeIT->mode );
}
++usedEdgeCounter;
++edgeIT;
@@ -268,6 +266,8 @@ void ExtractionContainers::PrepareData(const std::string & outputFileName, const
std::cout << "ok, after " << get_timestamp() - time << "s" << std::endl;
std::cout << "[extractor] setting number of edges ... " << std::flush;
+ std::cout << "[extractor] number of edges: " << usedEdgeCounter << std::flush;
+
fout.seekp(positionInFile);
fout.write((char*)&usedEdgeCounter, sizeof(unsigned));
fout.close();
@@ -109,7 +109,7 @@ void ExtractorCallbacks::wayFunction(ExtractionWay &parsed_way) {
parsed_way.ignoreInGrid,
(0 < parsed_way.duration),
parsed_way.isAccessRestricted,
- parsed_way.mode
+ parsed_way.forward_mode
)
);
externalMemory->usedNodeIDs.push_back(parsed_way.path[n]);
@@ -134,7 +134,7 @@ void ExtractorCallbacks::wayFunction(ExtractionWay &parsed_way) {
(0 < parsed_way.duration),
parsed_way.isAccessRestricted,
(ExtractionWay::oneway == parsed_way.direction),
- parsed_way.mode
+ parsed_way.backward_mode
)
);
}
@@ -59,9 +59,10 @@ struct ExtractionWay {
roundabout = false;
isAccessRestricted = false;
ignoreInGrid = false;
- mode = 0;
+ forward_mode = 0;
+ backward_mode = 0;
}
-
+
enum Directions {
notSure = 0, oneway, bidirectional, opposite
};
@@ -77,7 +78,8 @@ struct ExtractionWay {
bool roundabout;
bool isAccessRestricted;
bool ignoreInGrid;
- unsigned char mode;
+ unsigned char forward_mode;
+ unsigned char backward_mode;
std::vector< NodeID > path;
HashTable<std::string, std::string> keyVals;
};
@@ -97,7 +99,7 @@ struct InternalExtractorEdge {
InternalExtractorEdge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar, unsigned char _mode): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar), isContraFlow(false), mode(_mode) {
assert(0 <= type);
}
- InternalExtractorEdge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar, bool icf, unsigned char _mode): start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar), isContraFlow(icf), mode(_mode) {
+ InternalExtractorEdge(NodeID s, NodeID t, short tp, short d, double sp, unsigned nid, bool isra, bool iing, bool ids, bool iar, bool icf, unsigned char _mode) : start(s), target(t), type(tp), direction(d), speed(sp), nameID(nid), isRoundabout(isra), ignoreInGrid(iing), isDurationSet(ids), isAccessRestricted(iar), isContraFlow(false), mode(_mode) {
assert(0 <= type);
}
NodeID start;
@@ -78,7 +78,8 @@ ScriptingEnvironment::ScriptingEnvironment(const char * fileName) {
.def_readwrite("ignore_in_grid", &ExtractionWay::ignoreInGrid)
.def_readwrite("tags", &ExtractionWay::keyVals)
.def_readwrite("direction", &ExtractionWay::direction)
- .def_readwrite("mode", &ExtractionWay::mode)
+ .def_readwrite("forward_mode", &ExtractionWay::forward_mode)
+ .def_readwrite("backward_mode", &ExtractionWay::backward_mode)
.enum_("constants")
[
luabind::value("notSure", 0),
@@ -156,13 +156,13 @@ class BasicRoutingInterface : boost::noncopyable{
unpackedPath[i].mode = unpackedPath[i+1].mode;
}
- //fetched an edge that has has our destination as source, then fetch the mode from that edge
- typename QueryDataT::Graph::EdgeIterator eit = _queryData.graph->EndEdges(edge.second);
+ //fetch first edge that has has our destination as source, then read the mode from that edge
+ typename QueryDataT::Graph::EdgeIterator eit = _queryData.graph->BeginEdges(edge.second);
const typename QueryDataT::Graph::EdgeData& ed = _queryData.graph->GetEdgeData(eit);
- unpackedPath[unpackedPath.size()-1].mode = _queryData.nodeHelpDesk->getModeFromEdgeID(ed.id);
+ unpackedPath[unpackedPath.size()-1].mode = _queryData.nodeHelpDesk->getModeFromEdgeID(ed.id);
for(unsigned i = 0; i<unpackedPath.size(); ++i) {
- INFO( "unpacking, id: " << (long)i << ", mode: " << (long)unpackedPath[i].mode );
+// INFO( "unpacking, id: " << (long)i << ", mode: " << (long)unpackedPath[i].mode );
}
}
View
@@ -155,6 +155,7 @@ NodeID readBinaryOSRMGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeL
EdgeT inputEdge(source, target, nameID, weight, forward, backward, type, isRoundabout, ignoreInGrid, isAccessRestricted, isContraFlow, mode );
edgeList.push_back(inputEdge);
+ INFO("graph load edge read xxx");
}
std::sort(edgeList.begin(), edgeList.end());
for(unsigned i = 1; i < edgeList.size(); ++i) {
View
@@ -255,6 +255,7 @@ int main (int argc, char *argv[]) {
ERR("Failed at edges of node " << node << " of " << numberOfNodes);
}
//Serialize edges
+ //INFO( "createHierachy write, i: " << usedEdgeCounter << ", mode: " << (long)currentEdge.data.mode );
edgeOutFile.write((char*) &currentEdge, sizeof(StaticGraph<EdgeData>::_StrEdge));
++edge;
++usedEdgeCounter;
@@ -4,8 +4,7 @@ Feature: Testbot - Mode flag
Background:
Given the profile "testbot"
- @xx
- Scenario: Bike - Mode
+ Scenario: Testbed - Modes
Given the node map
| a | b | | | |
| | c | d | e | f |
@@ -28,7 +27,7 @@ Feature: Testbot - Mode flag
| b | d | bc,cd | head,left,destination | 88,77 |
| a | f | ab,bc,cd,de,ef | head,right,left,straight,straight,destination | 77,88,77,77,77 |
- Scenario: Bike - Mode
+ Scenario: Testbed - Mode
Given the node map
| a | b | c | 0 |
@@ -41,3 +40,19 @@ Feature: Testbot - Mode flag
| from | to | route | turns | modes |
| a | c | ab,bc | head,straight,destination | 77,88 |
| c | a | bc,ab | head,straight,destination | 88,77 |
+
+ @xx
+ Scenario: Testbed - Modes in each direction
+ Given the node map
+ | a | b | c | d |
+
+ And the ways
+ | nodes | highway |
+ | ab | river |
+ | bc | river |
+ | cd | river |
+
+ When I route I should get
+ | from | to | route | modes |
+ | a | d | ab,bc,cd | 33,33,33 |
+ | d | a | cd,bc,ab | 44,44,44 |
View
@@ -64,12 +64,14 @@ function way_function (way)
local maxspeed_forward = tonumber(way.tags:Find( "maxspeed:forward"))
local maxspeed_backward = tonumber(way.tags:Find( "maxspeed:backward"))
- way.mode = 77
+ way.forward_mode = 77
+ way.backward_mode = 77
way.name = name
if route ~= nil and durationIsValid(duration) then
way.duration = math.max( 1, parseDuration(duration) )
- way.mode = 88
+ way.forward_mode = 88
+ way.backward_mode = 88
else
local speed_forw = speed_profile[highway] or speed_profile['default']
local speed_back = speed_forw
@@ -78,6 +80,8 @@ function way_function (way)
local temp_speed = speed_forw;
speed_forw = temp_speed*1.5
speed_back = temp_speed/1.5
+ way.forward_mode = 33
+ way.backward_mode = 44
end
if maxspeed_forward ~= nil and maxspeed_forward > 0 then

0 comments on commit 79a8360

Please sign in to comment.