Minor code refactoring

This commit is contained in:
DennisOSRM 2013-02-27 19:47:04 +01:00
parent f9abfbf68a
commit bec4e4437d
3 changed files with 10 additions and 9 deletions

View File

@ -327,9 +327,9 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename, lua_State
}
TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w, unsigned& penalty, lua_State *myLuaState) const {
double angle = GetAngleBetweenTwoEdges(inputNodeInfoList[u], inputNodeInfoList[v], inputNodeInfoList[w]);
const double angle = GetAngleBetweenTwoEdges(inputNodeInfoList[u], inputNodeInfoList[v], inputNodeInfoList[w]);
if( speedProfile.has_turn_function ) {
if( speedProfile.has_turn_penalty_function ) {
try {
//call lua profile to compute turn penalty
penalty = luabind::call_function<int>( myLuaState, "turn_function", 180-angle );
@ -364,18 +364,19 @@ TurnInstruction EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID
if( 1 == (_nodeBasedGraph->EndEdges(v) - _nodeBasedGraph->BeginEdges(v)) ) {
//No turn possible.
return TurnInstructions.NoTurn;
} else {
return TurnInstructions.StayOnRoundAbout;
}
return TurnInstructions.StayOnRoundAbout;
}
//Does turn start or end on roundabout?
if(data1.roundabout || data2.roundabout) {
//We are entering the roundabout
if( (!data1.roundabout) && data2.roundabout)
if( (!data1.roundabout) && data2.roundabout) {
return TurnInstructions.EnterRoundAbout;
}
//We are leaving the roundabout
else if(data1.roundabout && (!data2.roundabout) )
if(data1.roundabout && (!data2.roundabout) ) {
return TurnInstructions.LeaveRoundAbout;
}
}
//If street names stay the same and if we are certain that it is not a roundabout, we skip it.

View File

@ -79,10 +79,10 @@ public:
};
struct SpeedProfileProperties{
SpeedProfileProperties() : trafficSignalPenalty(0), uTurnPenalty(0), has_turn_function(false) {}
SpeedProfileProperties() : trafficSignalPenalty(0), uTurnPenalty(0), has_turn_penalty_function(false) {}
int trafficSignalPenalty;
int uTurnPenalty;
bool has_turn_function;
bool has_turn_penalty_function;
} speedProfile;
private:

View File

@ -134,7 +134,7 @@ int main (int argc, char *argv[]) {
}
speedProfile.uTurnPenalty = 10*lua_tointeger(myLuaState, -1);
speedProfile.has_turn_function = lua_function_exists( myLuaState, "turn_function" );
speedProfile.has_turn_penalty_function = lua_function_exists( myLuaState, "turn_function" );
std::vector<ImportEdge> edgeList;
NodeID nodeBasedNodeNumber = readBinaryOSRMGraphFromStream(in, edgeList, bollardNodes, trafficLightNodes, &internalToExternalNodeMapping, inputRestrictions);