parent
30d72543b9
commit
556e487a15
@ -61,9 +61,21 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg
|
|||||||
trafficSignalPenalty = 0;
|
trafficSignalPenalty = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if("uturnPenalty" == v.first) {
|
||||||
|
std::string value = v.second.get<std::string>("");
|
||||||
|
try {
|
||||||
|
uturnPenalty = 10*boost::lexical_cast<int>(v.second.get<std::string>(""));
|
||||||
|
} catch(boost::bad_lexical_cast &) {
|
||||||
|
uturnPenalty = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if("takeMinimumOfSpeeds" == v.first) {
|
||||||
|
std::string value = v.second.get<std::string>("");
|
||||||
|
takeMinimumOfSpeeds = (v.second.get<std::string>("") == "yes");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
INFO("traffic signal penalty: " << trafficSignalPenalty);
|
// INFO("traffic signal penalty: " << trafficSignalPenalty << ", U-Turn penalty: " << uturnPenalty << ", takeMinimumOfSpeeds=" << (takeMinimumOfSpeeds ? "yes" : "no"));
|
||||||
|
|
||||||
BOOST_FOREACH(NodeID id, bn)
|
BOOST_FOREACH(NodeID id, bn)
|
||||||
_barrierNodes[id] = true;
|
_barrierNodes[id] = true;
|
||||||
@ -221,12 +233,14 @@ void EdgeBasedGraphFactory::Run() {
|
|||||||
assert(edgeData2.edgeBasedNodeID < _nodeBasedGraph->GetNumberOfEdges());
|
assert(edgeData2.edgeBasedNodeID < _nodeBasedGraph->GetNumberOfEdges());
|
||||||
|
|
||||||
unsigned distance = edgeData1.distance;
|
unsigned distance = edgeData1.distance;
|
||||||
//distance += heightPenalty;
|
|
||||||
//distance += ComputeTurnPenalty(u, v, w);
|
|
||||||
if(_trafficLights.find(v) != _trafficLights.end()) {
|
if(_trafficLights.find(v) != _trafficLights.end()) {
|
||||||
distance += trafficSignalPenalty;
|
distance += trafficSignalPenalty;
|
||||||
}
|
}
|
||||||
short turnInstruction = AnalyzeTurn(u, v, w);
|
short turnInstruction = AnalyzeTurn(u, v, w);
|
||||||
|
if(turnInstruction == TurnInstructions.UTurn)
|
||||||
|
distance += uturnPenalty;
|
||||||
|
//distance += heightPenalty;
|
||||||
|
//distance += ComputeTurnPenalty(u, v, w);
|
||||||
assert(edgeData1.edgeBasedNodeID != edgeData2.edgeBasedNodeID);
|
assert(edgeData1.edgeBasedNodeID != edgeData2.edgeBasedNodeID);
|
||||||
EdgeBasedEdge newEdge(edgeData1.edgeBasedNodeID, edgeData2.edgeBasedNodeID, v, edgeData2.nameID, distance, true, false, turnInstruction);
|
EdgeBasedEdge newEdge(edgeData1.edgeBasedNodeID, edgeData2.edgeBasedNodeID, v, edgeData2.nameID, distance, true, false, turnInstruction);
|
||||||
edgeBasedEdges.push_back(newEdge);
|
edgeBasedEdges.push_back(newEdge);
|
||||||
|
@ -116,6 +116,8 @@ private:
|
|||||||
// SRTMLookup srtmLookup;
|
// SRTMLookup srtmLookup;
|
||||||
unsigned numberOfTurnRestrictions;
|
unsigned numberOfTurnRestrictions;
|
||||||
unsigned trafficSignalPenalty;
|
unsigned trafficSignalPenalty;
|
||||||
|
unsigned uturnPenalty;
|
||||||
|
bool takeMinimumOfSpeeds;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template< class InputEdgeT >
|
template< class InputEdgeT >
|
||||||
|
@ -176,14 +176,22 @@ public:
|
|||||||
|
|
||||||
//Is the highway tag listed as usable way?
|
//Is the highway tag listed as usable way?
|
||||||
if(("track" == highway && ("yes" == access || "yes" == accessTag)) || ("track" != highway && (0 < settings[highway] || "yes" == accessTag || "designated" == accessTag) )) {
|
if(("track" == highway && ("yes" == access || "yes" == accessTag)) || ("track" != highway && (0 < settings[highway] || "yes" == accessTag || "designated" == accessTag) )) {
|
||||||
if(!w.isDurationSet) {
|
if(!w.isDurationSet) {
|
||||||
if(0 < settings[highway]) {
|
if(0 < settings[highway]) {
|
||||||
if(0 < maxspeed)
|
if(0 < maxspeed)
|
||||||
w.speed = maxspeed;
|
if(settings.takeMinimumOfSpeeds)
|
||||||
|
w.speed = std::min(settings[highway], maxspeed);
|
||||||
|
else
|
||||||
|
w.speed = maxspeed;
|
||||||
else
|
else
|
||||||
w.speed = settings[highway];
|
w.speed = settings[highway];
|
||||||
} else {
|
} else {
|
||||||
w.speed = settings.defaultSpeed;
|
if(0 < maxspeed)
|
||||||
|
if(settings.takeMinimumOfSpeeds)
|
||||||
|
w.speed = std::min(settings.defaultSpeed, maxspeed);
|
||||||
|
else w.speed = maxspeed;
|
||||||
|
else
|
||||||
|
w.speed = settings.defaultSpeed;
|
||||||
highway = "default";
|
highway = "default";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,15 +210,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( settings.obeyOneways ) {
|
if( settings.obeyOneways ) {
|
||||||
if( onewayClass == "yes" || onewayClass == "1" || onewayClass == "true" ) {
|
if( onewayClass == "yes" || onewayClass == "1" || onewayClass == "true" ) {
|
||||||
w.direction = _Way::oneway;
|
w.direction = _Way::oneway;
|
||||||
} else if( onewayClass == "no" || onewayClass == "0" || onewayClass == "false" ) {
|
} else if( onewayClass == "no" || onewayClass == "0" || onewayClass == "false" ) {
|
||||||
w.direction = _Way::bidirectional;
|
|
||||||
} else if( onewayClass == "-1" ) {
|
|
||||||
w.direction = _Way::opposite;
|
|
||||||
} else if( oneway == "no" || oneway == "0" || oneway == "false" ) {
|
|
||||||
w.direction = _Way::bidirectional;
|
w.direction = _Way::bidirectional;
|
||||||
} else if( settings.accessTag == "bicycle" && (cycleway == "opposite" || cycleway == "opposite_track" || cycleway == "opposite_lane") ) {
|
} else if( onewayClass == "-1" ) {
|
||||||
|
w.direction = _Way::opposite;
|
||||||
|
} else if( oneway == "no" || oneway == "0" || oneway == "false" ) {
|
||||||
|
w.direction = _Way::bidirectional;
|
||||||
|
} else if( settings.accessTag == "bicycle" && (cycleway == "opposite" || cycleway == "opposite_track" || cycleway == "opposite_lane") ) {
|
||||||
w.direction = _Way::bidirectional;
|
w.direction = _Way::bidirectional;
|
||||||
} else if( oneway == "-1") {
|
} else if( oneway == "-1") {
|
||||||
w.direction = _Way::opposite;
|
w.direction = _Way::opposite;
|
||||||
|
@ -265,7 +265,7 @@ struct CmpWayByID : public std::binary_function<_WayIDStartAndEndEdge, _WayIDSta
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct Settings {
|
struct Settings {
|
||||||
Settings() : obeyBollards(true), obeyOneways(true), useRestrictions(true), accessTag("motorcar"), defaultSpeed(30), trafficLightPenalty(0), excludeFromGrid("ferry") {}
|
Settings() : obeyBollards(true), obeyOneways(true), useRestrictions(true), accessTag("motorcar"), defaultSpeed(30), takeMinimumOfSpeeds(false), excludeFromGrid("ferry") {}
|
||||||
StringToIntPairMap speedProfile;
|
StringToIntPairMap speedProfile;
|
||||||
int operator[](const std::string & param) const {
|
int operator[](const std::string & param) const {
|
||||||
if(speedProfile.find(param) == speedProfile.end())
|
if(speedProfile.find(param) == speedProfile.end())
|
||||||
@ -290,7 +290,7 @@ struct Settings {
|
|||||||
bool useRestrictions;
|
bool useRestrictions;
|
||||||
std::string accessTag;
|
std::string accessTag;
|
||||||
int defaultSpeed;
|
int defaultSpeed;
|
||||||
int trafficLightPenalty;
|
bool takeMinimumOfSpeeds;
|
||||||
std::string excludeFromGrid;
|
std::string excludeFromGrid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ struct TurnInstructionsClass {
|
|||||||
if (angle >= 292 && angle < 336) {
|
if (angle >= 292 && angle < 336) {
|
||||||
return TurnSharpLeft;
|
return TurnSharpLeft;
|
||||||
}
|
}
|
||||||
return 5;
|
return UTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool TurnIsNecessary ( const short turnInstruction ) {
|
static inline bool TurnIsNecessary ( const short turnInstruction ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user