 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
48 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
58 for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
59 (*k)->setTurningDestination(
nullptr);
61 std::vector<Combination> combinations;
63 for (std::vector<NBEdge*>::const_iterator j = outgoing.begin(); j != outgoing.end(); ++j) {
65 for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
69 if (signedAngle > 0 && signedAngle < 177 && e->getGeometry().back().distanceTo2D(outedge->
getGeometry().front()) <
POSITION_EPS) {
74 double angle = fabs(signedAngle);
103 combinations.push_back(c);
108 std::set<NBEdge*> seen;
110 for (std::vector<Combination>::const_iterator j = combinations.begin(); j != combinations.end(); ++j) {
112 if (seen.find((*j).from) != seen.end() || seen.find((*j).to) != seen.end()) {
114 if ((*j).angle > 360 && warn) {
122 seen.insert((*j).from);
123 seen.insert((*j).to);
125 bool onlyPossible = (*j).from->getConnections().size() != 0 && !(*j).from->isConnectedTo((*j).to);
127 (*j).from->setTurningDestination((*j).to, onlyPossible);
137 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
138 i->second->sortEdges(useNodeShape);
145 const std::vector<NBEdge*>::iterator& i1,
146 const std::vector<NBEdge*>::iterator& i2) {
166 const double rightBeforeLeftSpeed = oc.
getFloat(
"junctions.right-before-left.speed-threshold");
167 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
168 NBNode*
const n = (*i).second;
181 bool waterway =
true;
211 for (EdgeVector::const_iterator j = i + 1; j != n->
myIncomingEdges.end(); j++) {
218 const double s1 = (*i)->getSpeed();
219 const double s2 = (*j)->getSpeed();
220 const int p1 = (*i)->getPriority();
221 const int p2 = (*j)->getPriority();
222 if (fabs(s1 - s2) > (9.5 / 3.6) ||
MAX2(s1, s2) >= rightBeforeLeftSpeed || p1 != p2) {
237 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
242 int numNonRailway = 0;
243 int numNonRailwayNonPed = 0;
248 numNonRailwayNonPed++;
259 if (numNonRailway == 0 || numRailway == 0) {
262 }
else if (numNonRailwayNonPed > 2) {
264 WRITE_WARNINGF(
"Converting invalid rail_crossing to traffic_light at junction '%'.", n->
getID());
284 int numNonRailway = 0;
292 return numRailway > 0 && numNonRailway == 0;
300 for (
const auto& node : nc) {
302 for (
NBEdge*
const edge : node.second->myAllEdges) {
305 node.second->markBentPriority(
false);
307 if (node.second->myIncomingEdges.size() == 1 && node.second->myOutgoingEdges.size() == 1) {
314 e->setJunctionPriority(node.second, e->getPriority());
336 NBEdge* best = incoming[0];
337 while (incoming.size() > 0 &&
samePriority(best, incoming[0])) {
338 bestIncoming.push_back(*incoming.begin());
339 incoming.erase(incoming.begin());
342 assert(outgoing.size() != 0);
346 while (outgoing.size() > 0 &&
samePriority(best, outgoing[0])) {
347 bestOutgoing.push_back(*outgoing.begin());
348 outgoing.erase(outgoing.begin());
351 const bool mainDirectionExplicit = (
353 && (incoming.size() == 0 || bestIncoming[0]->getPriority() > incoming[0]->getPriority())
355 && (outgoing.size() == 0 || bestOutgoing[0]->getPriority() > outgoing[0]->getPriority())
356 && !bestIncoming[0]->isTurningDirectionAt(bestOutgoing[0]));
360 EdgeVector::iterator i;
361 std::map<NBEdge*, NBEdge*> counterIncomingEdges;
362 std::map<NBEdge*, NBEdge*> counterOutgoingEdges;
365 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
367 counterIncomingEdges[*i] = *incoming.begin();
369 counterOutgoingEdges[*i] = *outgoing.begin();
374 if (bestIncoming.size() == 1) {
377 if (!mainDirectionExplicit && counterIncomingEdges.find(best1) != counterIncomingEdges.end()) {
381 NBEdge* s = counterIncomingEdges.find(best1)->second;
383 if (minAngleDiff > 180 - 45
389 assert(bestOutgoing.size() != 0);
394 if (!mainDirectionExplicit && counterOutgoingEdges.find(bestOut) != counterOutgoingEdges.end()) {
395 NBEdge* s = counterOutgoingEdges.find(bestOut)->second;
408 double bestAngle = 0;
409 NBEdge* bestFirst =
nullptr;
410 NBEdge* bestSecond =
nullptr;
411 bool hadBest =
false;
412 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
413 EdgeVector::iterator j;
419 for (j = i + 1; j != bestIncoming.end(); ++j) {
426 if (!hadBest || angle > bestAngle) {
436 if (bestOutgoing.size() != 0) {
441 if (bestOutgoing.size() != 0) {
453 const double a2 = bestSecond ==
nullptr ? a1 : bestSecond->
getAngleAtNode(&n);
462 && (p1 & perm) == 0 && (p2 & perm) == 0) {
463 e->setJunctionPriority(&n, 1);
498 if (edges.size() < 2) {
501 int prio = edges[0] == excluded ? edges[1]->
getPriority() : edges[0]->getPriority();
502 for (
auto e : edges) {
static void validateRailCrossings(NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Checks rail_crossing for validity.
static NBEdge * extractAndMarkFirst(NBNode &n, std::vector< NBEdge * > &s, int prio=1)
Sets the priorites in case of a priority junction.
static bool samePriority(const NBEdge *const e1, const NBEdge *const e2)
Returns whether both edges have the same priority.
crossing_by_junction_angle_sorter(const NBNode *node, const EdgeVector &ordering)
A container for traffic light definitions and built programs.
SumoXMLNodeType myType
The type of the junction.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
static void setPriorityJunctionPriorities(NBNode &n)
Sets the priorites in case of a priority junction.
static void swapWhenReversed(const NBNode *const n, const std::vector< NBEdge * >::iterator &i1, const std::vector< NBEdge * >::iterator &i2)
Assures correct order for same-angle opposite-direction edges.
void setJunctionPriority(const NBNode *const node, int prio)
Sets the junction priority of the edge.
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
static double normRelAngle(double angle1, double angle2)
ensure that reverse relAngles (>=179.999) always count as turnarounds (-180)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
A traffic light logics which must be computed (only nodes/edges are given)
static void markBestParallel(const NBNode &n, NBEdge *bestFirst, NBEdge *bestSecond)
set priority for edges that are parallel to the best edges
static OptionsCont & getOptions()
Retrieves the options.
int getPriority() const
Returns the priority of the edge.
static void computeEdgePriorities(NBNodeCont &nc)
Computes edge priorities within a node.
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node's edges clockwise regarding driving direction.
#define WRITE_WARNINGF(...)
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Container for nodes during the netbuilding process.
Sorts "Combination"s by decreasing angle.
The representation of a single edge during network building.
static void computeTurnDirectionsForNode(NBNode *node, bool warn)
Computes turnaround destinations for all incoming edges of the given nodes (if any)
The link is a straight direction.
NBNode * getToNode() const
Returns the destination node of the edge.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
NBEdge * getOppositeIncoming(NBEdge *e) const
returns the opposite incoming edge of certain edge
Stores the information about the angle between an incoming ("from") and an outgoing ("to") edge.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
classes which drive on tracks
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
T get(const std::string &str) const
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
Removes the given traffic light from this node.
LinkDirection getDirection(const NBEdge *const incoming, const NBEdge *const outgoing, bool leftHand=false) const
Returns the representation of the described stream's direction.
int getNumLanes() const
Returns the number of lanes.
bool isInStringVector(const std::string &optionName, const std::string &itemName) const
Returns the named option is a list of string values containing the specified item.
A storage for options typed value containers)
const EdgeVector & getEdges() const
Returns all edges which participate in this node (Edges that start or end at this node)
EdgeVector myOutgoingEdges
Vector of outgoing edges.
EdgeVector getIncomingEdges() const
Returns the list of incoming edges unsorted.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
bool myTypeWasGuessed
whether the node type was guessed rather than loaded
static bool hasDifferentPriorities(const EdgeVector &edges, const NBEdge *excluded)
return whether the priorite attribute can be used to distinguish the edges
double getSpeed() const
Returns the speed allowed on this edge.
bool geometryLike() const
whether this is structurally similar to a geometry node
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
bool isSimpleContinuation(bool checkLaneNumbers=true, bool checkWidth=false) const
check if node is a simple continuation
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
static bool isRailwayNode(const NBNode *n)
whether the given node only has rail edges
EdgeVector myIncomingEdges
Vector of incoming edges.
Class to sort edges by their angle in relation to the given edge.
static void computeTurnDirections(NBNodeCont &nc, bool warn=true)
Computes turnaround destinations for all edges (if exist)
Represents a single node (junction) during network building.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
const std::string & getID() const
Returns the id.
double getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
static void computeNodeTypes(NBNodeCont &nc, NBTrafficLightLogicCont &tlc)
Computes node types.
NBNode * getFromNode() const
Returns the origin node of the edge.
bool isDistrict() const
check if node is a district
The base class for traffic light logic definitions.
void markBentPriority(bool isBent)
mark whether a priority road turns at this node
bool isNearDistrict() const
@chech if node is near district