#include <NBNode.h>
Definition at line 71 of file NBNode.h.
Public Types | |
| enum | BasicNodeType { NODETYPE_UNKNOWN, NODETYPE_TRAFFIC_LIGHT, NODETYPE_PRIORITY_JUNCTION, NODETYPE_RIGHT_BEFORE_LEFT, NODETYPE_DISTRICT, NODETYPE_NOJUNCTION, NODETYPE_DEAD_END } |
| Possible node types. More... | |
Public Member Functions | |
| void | addIncomingEdge (NBEdge *edge) |
| adds an incoming edge | |
| void | addOutgoingEdge (NBEdge *edge) |
| adds an outgoing edge | |
| void | addSortedLinkFoes (const NBConnection &mayDrive, const NBConnection &mustStop) |
| bool | checkIsRemovable () const |
| void | computeLanes2Lanes () |
| computes the connections of lanes to edges | |
| void | computeLogic (const NBEdgeCont &ec, NBJunctionLogicCont &jc, OptionsCont &oc) |
| computes the node's type, logic and traffic light | |
| void | computeNodeShape (bool leftHand) |
| unsigned int | countInternalLanes (bool includeSplits) |
| unsigned int | eraseDummies (NBDistrictCont &dc, NBEdgeCont &ec, NBTrafficLightLogicCont &tc) |
| bool | foes (const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const throw () |
| Returns the information whether the given flows cross. | |
| bool | forbids (const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const throw () |
| Returns the information whether "prohibited" flow must let "prohibitor" flow pass. | |
| NBEdge * | getConnectionTo (NBNode *n) const |
| std::string | getCrossingNames_dividedBySpace (NBEdge *fromE, unsigned int fromL, NBEdge *toE, unsigned int toL) |
| std::pair< SUMOReal, std::vector< unsigned int > > | getCrossingPosition (NBEdge *fromE, unsigned int fromL, NBEdge *toE, unsigned int toL) |
| std::string | getCrossingSourcesNames_dividedBySpace (NBEdge *fromE, unsigned int fromL, NBEdge *toE, unsigned int toL) |
| std::vector< std::pair< NBEdge *, NBEdge * > > | getEdgesToJoin () const |
| Position2D | getEmptyDir () const |
| Returns something like the most unused direction Should only be used to add source or sink nodes. | |
| std::string | getInternalLaneID (NBEdge *from, unsigned int fromlane, NBEdge *to, unsigned int tolane) const |
| SUMOReal | getMaxEdgeWidth () const |
| NBMMLDirection | getMMLDirection (const NBEdge *const incoming, const NBEdge *const outgoing) const throw () |
| Returns the MML-representation of the described stream's direction. | |
| NBEdge * | getOppositeIncoming (NBEdge *e) const |
| NBEdge * | getPossiblySplittedIncoming (const std::string &edgeid) |
| NBEdge * | getPossiblySplittedOutgoing (const std::string &edgeid) |
| const Position2DVector & | getShape () const |
| bool | hasIncoming (const NBEdge *const e) const throw () |
| Returns whether the given edge ends at this node. | |
| bool | hasOutgoing (const NBEdge *const e) const throw () |
| Returns whether the given edge starts at this node. | |
| void | invalidateIncomingConnections () |
| void | invalidateOutgoingConnections () |
| bool | isDistrict () const |
| bool | isLeftMover (const NBEdge *const from, const NBEdge *const to) const throw () |
| Computes whether the given connection is a left mover across the junction. | |
| bool | isNearDistrict () const |
| bool | mustBrake (const NBEdge *const from, const NBEdge *const to, int toLane) const throw () |
| Returns the information whether the described flow must let any other flow pass. | |
| NBNode (const std::string &id, const Position2D &position, NBDistrict *district) throw () | |
| Constructor. | |
| NBNode (const std::string &id, const Position2D &position, BasicNodeType type) throw () | |
| Constructor. | |
| NBNode (const std::string &id, const Position2D &position) throw () | |
| Constructor. | |
| void | reinit (const Position2D &position, BasicNodeType type) throw () |
| Resets initial values. | |
| void | removeDoubleEdges () |
| void | removeIncoming (NBEdge *edge) |
| void | removeOutgoing (NBEdge *edge) |
| void | replaceIncoming (const EdgeVector &which, NBEdge *by) |
| Replaces occurences of every edge from the given list within the list of incoming by the second Connections are remapped, too. | |
| void | replaceIncoming (NBEdge *which, NBEdge *by, unsigned int laneOff) |
| Replaces occurences of the first edge within the list of incoming by the second Connections are remapped, too. | |
| void | replaceOutgoing (const EdgeVector &which, NBEdge *by) |
| Replaces occurences of every edge from the given list within the list of outgoing by the second Connections are remapped, too. | |
| void | replaceOutgoing (NBEdge *which, NBEdge *by, unsigned int laneOff) |
| Replaces occurences of the first edge within the list of outgoing by the second Connections are remapped, too. | |
| void | sortNodesEdges (bool leftHand, const NBTypeCont &tc) |
| char | stateCode (NBEdge *incoming, NBEdge *outgoing, int fromLane, bool mayDefinitelyPass) const throw () |
| void | writeXML (OutputDevice &into) |
| prints the junction | |
| void | writeXMLInternalLinks (OutputDevice &into) |
| void | writeXMLInternalNodes (OutputDevice &into) |
| void | writeXMLInternalSuccInfos (OutputDevice &into) |
| ~NBNode () throw () | |
| Destructor. | |
Methods for dealing with assigned traffic lights | |
| void | addTrafficLight (NBTrafficLightDefinition *tld) throw () |
| Adds a traffic light to the list of traffic lights that control this node. | |
| const std::set < NBTrafficLightDefinition * > & | getControllingTLS () const throw () |
| Returns the traffic lights that were assigned to this node. | |
| bool | isJoinedTLSControlled () const throw () |
| Returns whether this node is controlled by a tls that spans over more than one node. | |
| bool | isTLControlled () const throw () |
| Returns whether this node is controlled by any tls. | |
| void | removeTrafficLights () throw () |
| Removes all references to traffic lights that control this tls. | |
Atomar getter methods | |
| const EdgeVector & | getEdges () const throw () |
| Returns all edges which participate in this node. | |
| const std::string & | getID () const throw () |
| Returns the id of the node. | |
| const EdgeVector & | getIncomingEdges () const throw () |
| Returns this node's incoming edges. | |
| const EdgeVector & | getOutgoingEdges () const throw () |
| Returns this node's outgoing edges. | |
| const Position2D & | getPosition () const throw () |
| Returns the position of this node. | |
| BasicNodeType | getType () const throw () |
| Returns the type of this node. | |
Private Member Functions | |
| void | buildBitfieldLogic () |
| build the logic using the NBRequest | |
| Position2DVector | computeInternalLaneShape (NBEdge *fromE, int fromL, NBEdge *toE, int toL) |
| BasicNodeType | computeType (const NBTypeCont &tc) const |
| NBEdge * | extractAndMarkFirst (std::vector< NBEdge * > &s) |
| std::vector< NBEdge * > * | getEdgesThatApproach (NBEdge *currentOutgoing) |
| bool | isSimpleContinuation () const |
| NBNode (const NBNode &s) | |
| invalidated copy constructor | |
| NBNode & | operator= (const NBNode &s) |
| invalidated assignment operator | |
| void | remapRemoved (NBTrafficLightLogicCont &tc, NBEdge *removed, const EdgeVector &incoming, const EdgeVector &outgoing) |
| void | replaceInConnectionProhibitions (NBEdge *which, NBEdge *by, unsigned int whichLaneOff, unsigned int byLaneOff) |
| void | reshiftPosition (SUMOReal xoff, SUMOReal yoff) |
| resets the position by the given amount | |
| void | setPriorities () |
| computes the priorities of participating edges within this junction | |
| void | setPriorityJunctionPriorities () |
| sets the priorites in case of a priority junction | |
| void | sortSmall () |
| bool | swapWhenReversed (bool leftHand, const std::vector< NBEdge * >::iterator &i1, const std::vector< NBEdge * >::iterator &i2) |
| void | writeinternal (EdgeVector *myIncomingEdges, OutputDevice &into, const std::string &id) |
Private Attributes | |
| std::vector< NBEdge * > | myAllEdges |
| Vector of incoming and outgoing edges. | |
| NBConnectionProhibits | myBlockedConnections |
| NBDistrict * | myDistrict |
| The district the node is the centre of. | |
| std::string | myID |
| The id of the node. | |
| std::vector< NBEdge * > * | myIncomingEdges |
| Vector of incoming edges. | |
| std::vector< NBEdge * > * | myOutgoingEdges |
| Vector of outgoing edges. | |
| Position2DVector | myPoly |
| the (outer) shape of the junction | |
| Position2D | myPosition |
| The position the node lies at. | |
| NBRequest * | myRequest |
| std::set < NBTrafficLightDefinition * > | myTrafficLights |
| BasicNodeType | myType |
| The type of the junction. | |
Friends | |
| class | NBNodeCont |
| class | NBNodeShapeComputer |
Data Structures | |
| class | ApproachingDivider |
| Computes lane-2-lane connections. More... | |
| class | nodes_by_id_sorter |
| Used for sorting the cells by the begin time they describe. More... | |
Possible node types.
Definition at line 117 of file NBNode.h.
00117 { 00119 NODETYPE_UNKNOWN, 00121 NODETYPE_TRAFFIC_LIGHT, 00123 NODETYPE_PRIORITY_JUNCTION, 00125 NODETYPE_RIGHT_BEFORE_LEFT, 00127 NODETYPE_DISTRICT, 00129 NODETYPE_NOJUNCTION, 00131 NODETYPE_DEAD_END 00132 };
| NBNode::NBNode | ( | const std::string & | id, | |
| const Position2D & | position | |||
| ) | throw () |
Constructor.
| [in] | id | The id of the node |
| [in] | position | The position of the node |
Definition at line 195 of file NBNode.cpp.
References myIncomingEdges, and myOutgoingEdges.
00196 : myID(StringUtils::convertUmlaute(id)), myPosition(position), 00197 myType(NODETYPE_UNKNOWN), myDistrict(0), myRequest(0) { 00198 myIncomingEdges = new EdgeVector(); 00199 myOutgoingEdges = new EdgeVector(); 00200 }
| NBNode::NBNode | ( | const std::string & | id, | |
| const Position2D & | position, | |||
| BasicNodeType | type | |||
| ) | throw () |
Constructor.
| [in] | id | The id of the node |
| [in] | position | The position of the node |
| [in] | type | The type of the node |
Definition at line 203 of file NBNode.cpp.
References myIncomingEdges, and myOutgoingEdges.
00205 : myID(StringUtils::convertUmlaute(id)), myPosition(position), 00206 myType(type), myDistrict(0), myRequest(0) { 00207 myIncomingEdges = new EdgeVector(); 00208 myOutgoingEdges = new EdgeVector(); 00209 }
| NBNode::NBNode | ( | const std::string & | id, | |
| const Position2D & | position, | |||
| NBDistrict * | district | |||
| ) | throw () |
Constructor.
| [in] | id | The id of the node |
| [in] | position | The position of the node |
| [in] | district | The district this district node represents |
Definition at line 212 of file NBNode.cpp.
References myIncomingEdges, and myOutgoingEdges.
00213 : myID(StringUtils::convertUmlaute(id)), myPosition(position), 00214 myType(NODETYPE_DISTRICT), myDistrict(district), myRequest(0) { 00215 myIncomingEdges = new EdgeVector(); 00216 myOutgoingEdges = new EdgeVector(); 00217 }
| NBNode::~NBNode | ( | ) | throw () |
Destructor.
Definition at line 220 of file NBNode.cpp.
References myIncomingEdges, myOutgoingEdges, and myRequest.
00220 { 00221 delete myIncomingEdges; 00222 delete myOutgoingEdges; 00223 delete myRequest; 00224 }
| NBNode::NBNode | ( | const NBNode & | s | ) | [private] |
invalidated copy constructor
| void NBNode::addIncomingEdge | ( | NBEdge * | edge | ) |
adds an incoming edge
Definition at line 271 of file NBNode.cpp.
References myAllEdges, and myIncomingEdges.
Referenced by NBNodeCont::guessRamps(), NBEdge::init(), and NBEdge::splitGeometry().
00271 { 00272 assert(edge!=0); 00273 if (find(myIncomingEdges->begin(), myIncomingEdges->end(), edge)==myIncomingEdges->end()) { 00274 myIncomingEdges->push_back(edge); 00275 myAllEdges.push_back(edge); 00276 } 00277 }
| void NBNode::addOutgoingEdge | ( | NBEdge * | edge | ) |
adds an outgoing edge
Definition at line 281 of file NBNode.cpp.
References myAllEdges, and myOutgoingEdges.
Referenced by NBEdge::init().
00281 { 00282 assert(edge!=0); 00283 if (find(myOutgoingEdges->begin(), myOutgoingEdges->end(), edge)==myOutgoingEdges->end()) { 00284 myOutgoingEdges->push_back(edge); 00285 myAllEdges.push_back(edge); 00286 } 00287 }
| void NBNode::addSortedLinkFoes | ( | const NBConnection & | mayDrive, | |
| const NBConnection & | mustStop | |||
| ) |
Definition at line 1485 of file NBNode.cpp.
References NBConnection::getFrom(), NBConnection::getTo(), myBlockedConnections, and WRITE_WARNING.
Referenced by NIVissimDisturbance::addToNode(), and NIXMLConnectionsHandler::myStartElement().
01486 { 01487 if (mayDrive.getFrom()==0 || 01488 mayDrive.getTo()==0 || 01489 mustStop.getFrom()==0 || 01490 mustStop.getTo()==0) { 01491 01492 WRITE_WARNING("Something went wrong during the building of a connection..."); 01493 return; // !!! mark to recompute connections 01494 } 01495 NBConnectionVector conn = myBlockedConnections[mustStop]; 01496 conn.push_back(mayDrive); 01497 myBlockedConnections[mustStop] = conn; 01498 }
| void NBNode::addTrafficLight | ( | NBTrafficLightDefinition * | tld | ) | throw () |
Adds a traffic light to the list of traffic lights that control this node.
| [in] | tld | The traffic light that controls this node |
Definition at line 241 of file NBNode.cpp.
References myTrafficLights.
Referenced by NBLoadedTLDef::addToSignalGroup().
00241 { 00242 myTrafficLights.insert(tld); 00243 }
| void NBNode::buildBitfieldLogic | ( | ) | [private] |
build the logic using the NBRequest
| bool NBNode::checkIsRemovable | ( | ) | const |
Definition at line 1866 of file NBNode.cpp.
References myIncomingEdges, myOutgoingEdges, myTrafficLights, and NBContHelper::nextCCW().
Referenced by getEdgesToJoin(), and NBNodeCont::removeUnwishedNodes().
01866 { 01867 // check whether this node is included in a traffic light 01868 if (myTrafficLights.size()!=0) { 01869 return false; 01870 } 01871 EdgeVector::const_iterator i; 01872 // one in, one out -> just a geometry ... 01873 if (myOutgoingEdges->size()==1&&myIncomingEdges->size()==1) { 01874 // ... if types match ... 01875 if (!(*myIncomingEdges)[0]->expandableBy((*myOutgoingEdges)[0])) { 01876 return false; 01877 } 01878 // 01879 return (*myIncomingEdges)[0]->getFromNode()!=(*myOutgoingEdges)[0]->getToNode(); 01880 } 01881 // two in, two out -> may be something else 01882 if (myOutgoingEdges->size()==2&&myIncomingEdges->size()==2) { 01883 // check whether the origin nodes of the incoming edges differ 01884 std::set<NBNode*> origSet; 01885 for (i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01886 origSet.insert((*i)->getFromNode()); 01887 } 01888 if (origSet.size()<2) { 01889 return false; 01890 } 01891 // check whether this node is an intermediate node of 01892 // a two-directional street 01893 for (i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01894 // try to find the opposite direction 01895 NBNode *origin = (*i)->getFromNode(); 01896 // find the back direction of the current edge 01897 EdgeVector::const_iterator j = 01898 find_if(myOutgoingEdges->begin(), myOutgoingEdges->end(), 01899 NBContHelper::edge_with_destination_finder(origin)); 01900 // check whether the back direction exists 01901 if (j!=myOutgoingEdges->end()) { 01902 // check whether the edge from the backdirection (must be 01903 // the counter-clockwise one) may be joined with the current 01904 NBContHelper::nextCCW(myOutgoingEdges, j); 01905 // check whether the types allow joining 01906 if (!(*i)->expandableBy(*j)) { 01907 return false; 01908 } 01909 } else { 01910 // ok, at least one outgoing edge is not an opposite 01911 // of an incoming one 01912 return false; 01913 } 01914 } 01915 return true; 01916 } 01917 // ok, a real node 01918 return false; 01919 }
| Position2DVector NBNode::computeInternalLaneShape | ( | NBEdge * | fromE, | |
| int | fromL, | |||
| NBEdge * | toE, | |||
| int | toL | |||
| ) | [private] |
Definition at line 648 of file NBNode.cpp.
References Position2D::almostSame(), Line2D::atan2DegreeAngle(), bezier(), Position2D::distanceTo(), Line2D::extrapolateFirstBy(), Line2D::extrapolateSecondBy(), Position2DVector::getBegin(), Position2DVector::getBegLine(), Position2DVector::getEnd(), Position2DVector::getEndLine(), getID(), NBEdge::getID(), NBEdge::getLaneShape(), GeomHelper::getMinAngleDiff(), NBEdge::getNoLanes(), Line2D::getPositionAtDistance(), NBEdge::getTurnDestination(), MsgHandler::getWarningInstance(), MsgHandler::inform(), Line2D::intersects(), Line2D::intersectsAt(), Line2D::length(), MAX2(), MIN2(), Line2D::p1(), Line2D::p2(), PI, Position2DVector::push_back(), Line2D::rotateAtP1(), Position2DVector::size(), Position2D::sub(), Line2D::sub(), SUMOReal, toString(), Position2D::x(), and Position2D::y().
Referenced by getCrossingNames_dividedBySpace(), getCrossingPosition(), getCrossingSourcesNames_dividedBySpace(), writeXMLInternalLinks(), and writeXMLInternalNodes().
00649 { 00650 if (fromL>=(int) fromE->getNoLanes()) { 00651 throw ProcessError("Connection '" + fromE->getID() + "_" + toString(fromL) + "->" + toE->getID() + "_" + toString(toL) + "' starts at a not existing lane."); 00652 } 00653 if (toL>=(int) toE->getNoLanes()) { 00654 throw ProcessError("Connection '" + fromE->getID() + "_" + toString(fromL) + "->" + toE->getID() + "_" + toString(toL) + "' yields in a not existing lane."); 00655 } 00656 bool noSpline = false; 00657 Position2DVector ret; 00658 Position2DVector init; 00659 Position2D beg = fromE->getLaneShape(fromL).getEnd(); 00660 Position2D end = toE->getLaneShape(toL).getBegin(); 00661 Position2D intersection; 00662 unsigned int noInitialPoints = 0; 00663 if (beg==end) { 00664 noSpline = true; 00665 } else { 00666 if (fromE->getTurnDestination()==toE) { 00667 // turnarounds: 00668 // - end of incoming lane 00669 // - position between incoming/outgoing end/begin shifted by the distace orthogonally 00670 // - begin of outgoing lane 00671 noInitialPoints = 3; 00672 init.push_back(beg); 00673 Line2D straightConn(fromE->getLaneShape(fromL)[-1],toE->getLaneShape(toL)[0]); 00674 Position2D straightCenter = straightConn.getPositionAtDistance((SUMOReal) straightConn.length() / (SUMOReal) 2.); 00675 Position2D center = straightCenter;//.add(straightCenter); 00676 Line2D cross(straightConn); 00677 cross.sub(cross.p1().x(), cross.p1().y()); 00678 cross.rotateAtP1(PI/2); 00679 center.sub(cross.p2()); 00680 init.push_back(center); 00681 init.push_back(end); 00682 } else { 00683 // 00684 SUMOReal angle1 = fromE->getLaneShape(fromL).getEndLine().atan2DegreeAngle(); 00685 SUMOReal angle2 = toE->getLaneShape(toL).getBegLine().atan2DegreeAngle(); 00686 SUMOReal angle = GeomHelper::getMinAngleDiff(angle1, angle2); 00687 if (angle<45) { 00688 // very low angle: almost straight 00689 noInitialPoints = 4; 00690 init.push_back(beg); 00691 Line2D begL = fromE->getLaneShape(fromL).getEndLine(); 00692 begL.extrapolateSecondBy(100); 00693 Line2D endL = toE->getLaneShape(toL).getBegLine(); 00694 endL.extrapolateFirstBy(100); 00695 SUMOReal distance = beg.distanceTo(end); 00696 if (distance>10) { 00697 { 00698 SUMOReal off1 = fromE->getLaneShape(fromL).getEndLine().length() + (SUMOReal) 5. * (SUMOReal) fromE->getNoLanes(); 00699 off1 = MIN2(off1, (SUMOReal)(fromE->getLaneShape(fromL).getEndLine().length()+distance/2.)); 00700 Position2D tmp = begL.getPositionAtDistance(off1); 00701 init.push_back(tmp); 00702 } 00703 { 00704 SUMOReal off1 = (SUMOReal) 100. - (SUMOReal) 5. * (SUMOReal) toE->getNoLanes(); 00705 off1 = MAX2(off1, (SUMOReal)(100.-distance/2.)); 00706 Position2D tmp = endL.getPositionAtDistance(off1); 00707 init.push_back(tmp); 00708 } 00709 } else { 00710 noSpline = true; 00711 } 00712 init.push_back(end); 00713 } else { 00714 // turning 00715 // - end of incoming lane 00716 // - intersection of the extrapolated lanes 00717 // - begin of outgoing lane 00718 // attention: if there is no intersection, use a straight line 00719 noInitialPoints = 3; 00720 init.push_back(beg); 00721 Line2D begL = fromE->getLaneShape(fromL).getEndLine(); 00722 Line2D endL = toE->getLaneShape(toL).getBegLine(); 00723 bool check = !begL.p1().almostSame(begL.p2()) && !endL.p1().almostSame(endL.p2()); 00724 if (check) { 00725 begL.extrapolateSecondBy(100); 00726 endL.extrapolateFirstBy(100); 00727 } else { 00728 MsgHandler::getWarningInstance()->inform("Could not use edge geometry for internal lane, node '" + getID() + "'."); 00729 } 00730 if (!check||!begL.intersects(endL)) { 00731 noSpline = true; 00732 } else { 00733 init.push_back(begL.intersectsAt(endL)); 00734 } 00735 init.push_back(end); 00736 } 00737 } 00738 } 00739 // 00740 if (noSpline) { 00741 ret.push_back(fromE->getLaneShape(fromL).getEnd()); 00742 ret.push_back(toE->getLaneShape(toL).getBegin()); 00743 return ret; 00744 } 00745 00746 SUMOReal *def = new SUMOReal[1+noInitialPoints*3]; 00747 for (int i=0; i<(int) init.size(); ++i) { 00748 // starts at index 1 00749 def[i*3+1] = init[i].x(); 00750 def[i*3+2] = 0; 00751 def[i*3+3] = init[i].y(); 00752 } 00753 SUMOReal ret_buf[NO_INTERNAL_POINTS*3+1]; 00754 bezier(noInitialPoints, def, NO_INTERNAL_POINTS, ret_buf); 00755 delete[] def; 00756 Position2D prev; 00757 00758 for (int i=0; i<(int) NO_INTERNAL_POINTS; i++) { 00759 Position2D current(ret_buf[i*3+1], ret_buf[i*3+3]); 00760 if (prev!=current) { 00761 ret.push_back(current); 00762 } 00763 prev = current; 00764 } 00765 return ret; 00766 }
| void NBNode::computeLanes2Lanes | ( | ) |
computes the connections of lanes to edges
Definition at line 1207 of file NBNode.cpp.
References NBEdge::addLane2LaneConnections(), Bresenham::compute(), NBEdge::getAngle(), GeomHelper::getCCWAngleDiff(), GeomHelper::getCWAngleDiff(), getEdgesThatApproach(), NBEdge::getNoLanes(), NBEdge::getTurnDestination(), NBEdge::L2L_COMPUTED, NBEdge::L2L_VALIDATED, NBEdge::LANES2EDGES, myIncomingEdges, myOutgoingEdges, NBEdge::setConnection(), and SUMOReal.
01207 { 01208 // special case a): 01209 // one in, one out, the outgoing has one lane more 01210 if (myIncomingEdges->size()==1&&myOutgoingEdges->size()==1 01211 &&(*myIncomingEdges)[0]->getNoLanes()==(*myOutgoingEdges)[0]->getNoLanes()-1 01212 &&(*myIncomingEdges)[0]!=(*myOutgoingEdges)[0] 01213 &&(*myIncomingEdges)[0]->isConnectedTo((*myOutgoingEdges)[0])) { 01214 01215 NBEdge *incoming = (*myIncomingEdges)[0]; 01216 NBEdge *outgoing = (*myOutgoingEdges)[0]; 01217 // check if it's not the turnaround 01218 if (incoming->getTurnDestination()==outgoing) { 01219 // will be added later or not... 01220 return; 01221 } 01222 for (int i=0; i<(int) incoming->getNoLanes(); ++i) { 01223 incoming->setConnection(i, outgoing, i+1, NBEdge::L2L_COMPUTED); 01224 } 01225 incoming->setConnection(0, outgoing, 0, NBEdge::L2L_COMPUTED); 01226 return; 01227 } 01228 // special case b): 01229 // two in, one out, the outgoing has the same number of lanes as the sum of the incoming 01230 // and a high speed, too 01231 // --> highway on-ramp 01232 bool check = false; 01233 if (myIncomingEdges->size()==2&&myOutgoingEdges->size()==1) { 01234 check = (*myIncomingEdges)[0]->getNoLanes()+(*myIncomingEdges)[1]->getNoLanes()==(*myOutgoingEdges)[0]->getNoLanes(); 01235 check &= ((*myIncomingEdges)[0]->getStep() <= NBEdge::LANES2EDGES); 01236 check &= ((*myIncomingEdges)[1]->getStep() <= NBEdge::LANES2EDGES); 01237 } 01238 if (check 01239 &&(*myIncomingEdges)[0]!=(*myOutgoingEdges)[0] 01240 &&(*myIncomingEdges)[0]->isConnectedTo((*myOutgoingEdges)[0])) { 01241 NBEdge *inc1 = (*myIncomingEdges)[0]; 01242 NBEdge *inc2 = (*myIncomingEdges)[1]; 01243 // for internal: check which one is the rightmost 01244 SUMOReal a1 = inc1->getAngle(*this); 01245 SUMOReal a2 = inc2->getAngle(*this); 01246 SUMOReal ccw = GeomHelper::getCCWAngleDiff(a1, a2); 01247 SUMOReal cw = GeomHelper::getCWAngleDiff(a1, a2); 01248 if (ccw<cw) { 01249 std::swap(inc1, inc2); 01250 } 01251 // 01252 inc1->addLane2LaneConnections(0, (*myOutgoingEdges)[0], 0, inc1->getNoLanes(), NBEdge::L2L_VALIDATED, true, true); 01253 inc2->addLane2LaneConnections(0, (*myOutgoingEdges)[0], inc1->getNoLanes(), inc2->getNoLanes(), NBEdge::L2L_VALIDATED, true, true); 01254 return; 01255 } 01256 01257 // go through this node's outgoing edges 01258 // for every outgoing edge, compute the distribution of the node's 01259 // incoming edges on this edge when approaching this edge 01260 // the incoming edges' steps will then also be marked as LANE2LANE_RECHECK... 01261 std::vector<NBEdge*>::reverse_iterator i; 01262 for (i=myOutgoingEdges->rbegin(); i!=myOutgoingEdges->rend(); i++) { 01263 NBEdge *currentOutgoing = *i; 01264 // get the information about edges that do approach this edge 01265 std::vector<NBEdge*> *approaching = getEdgesThatApproach(currentOutgoing); 01266 if (approaching->size()!=0) { 01267 ApproachingDivider divider(approaching, currentOutgoing); 01268 Bresenham::compute(÷r, (SUMOReal) approaching->size(), 01269 (SUMOReal) currentOutgoing->getNoLanes()); 01270 } 01271 delete approaching; 01272 } 01273 // ... but we may have the case that there are no outgoing edges 01274 // In this case, we have to mark the incoming edges as being in state 01275 // LANE2LANE( not RECHECK) by hand 01276 if (myOutgoingEdges->size()==0) { 01277 for (i=myIncomingEdges->rbegin(); i!=myIncomingEdges->rend(); i++) { 01278 (*i)->markAsInLane2LaneState(); 01279 } 01280 } 01281 }
| void NBNode::computeLogic | ( | const NBEdgeCont & | ec, | |
| NBJunctionLogicCont & | jc, | |||
| OptionsCont & | oc | |||
| ) |
computes the node's type, logic and traffic light
Definition at line 1106 of file NBNode.cpp.
References NBRequest::buildBitfieldLogic(), OptionsCont::getBool(), getID(), OptionsCont::getOptions(), NBRequest::getSizes(), MsgHandler::getWarningInstance(), MsgHandler::inform(), isDistrict(), OptionsCont::isInStringVector(), NBEdgeCont::isLeftHanded(), isNearDistrict(), myAllEdges, myBlockedConnections, myID, myIncomingEdges, myOutgoingEdges, myRequest, myType, NODETYPE_DISTRICT, and NODETYPE_NOJUNCTION.
01107 { 01108 if (myIncomingEdges->size()==0||myOutgoingEdges->size()==0) { 01109 // no logic if nothing happens here 01110 myType = NODETYPE_NOJUNCTION; 01111 return; 01112 } 01113 // check whether the node was set to be unregulated by the user 01114 if (OptionsCont::getOptions().getBool("keep-unregulated") 01115 || 01116 OptionsCont::getOptions().isInStringVector("keep-unregulated.nodes", getID()) 01117 || 01118 (OptionsCont::getOptions().getBool("keep-unregulated.district-nodes")&&(isNearDistrict()||isDistrict()))) { 01119 01120 myType = NODETYPE_NOJUNCTION; 01121 return; 01122 } 01123 // compute the logic if necessary or split the junction 01124 if (myType!=NODETYPE_NOJUNCTION&&myType!=NODETYPE_DISTRICT) { 01125 // build the request 01126 myRequest = new NBRequest(ec, this, 01127 static_cast<const EdgeVector * const>(&myAllEdges), 01128 static_cast<const EdgeVector * const>(myIncomingEdges), 01129 static_cast<const EdgeVector * const>(myOutgoingEdges), 01130 myBlockedConnections); 01131 // check whether it is not too large 01132 if (myRequest->getSizes().second>=64) { 01133 // yep -> make it untcontrolled, warn 01134 MsgHandler::getWarningInstance()->inform("Junction '" + getID() + "' is too complicated (#links>64); will be set to unregulated."); 01135 delete myRequest; 01136 myRequest = 0; 01137 myType = NODETYPE_NOJUNCTION; 01138 } else { 01139 myRequest->buildBitfieldLogic(ec.isLeftHanded(), jc, myID); 01140 } 01141 } 01142 }
| void NBNode::computeNodeShape | ( | bool | leftHand | ) |
Definition at line 1193 of file NBNode.cpp.
References NBNodeShapeComputer::compute(), getID(), MsgHandler::getWarningInstance(), MsgHandler::inform(), myIncomingEdges, myOutgoingEdges, and myPoly.
01193 { 01194 if (myIncomingEdges->size()==0&&myOutgoingEdges->size()==0) { 01195 return; 01196 } 01197 try { 01198 NBNodeShapeComputer computer(*this); 01199 myPoly = computer.compute(leftHand); 01200 } catch (InvalidArgument &) { 01201 MsgHandler::getWarningInstance()->inform("For node '" + getID() + "': could not compute shape."); 01202 } 01203 }
| NBNode::BasicNodeType NBNode::computeType | ( | const NBTypeCont & | tc | ) | const [private] |
Definition at line 333 of file NBNode.cpp.
References NBTypeCont::getJunctionType(), getOppositeIncoming(), isSimpleContinuation(), myIncomingEdges, myType, NODETYPE_NOJUNCTION, NODETYPE_PRIORITY_JUNCTION, NODETYPE_RIGHT_BEFORE_LEFT, and NODETYPE_UNKNOWN.
Referenced by sortNodesEdges().
00333 { 00334 // the type may already be set from the data 00335 if (myType!=NODETYPE_UNKNOWN) { 00336 return myType; 00337 } 00338 // check whether the junction is not a real junction 00339 if (myIncomingEdges->size()==1) { 00340 return NODETYPE_PRIORITY_JUNCTION; 00341 } 00342 if (isSimpleContinuation()) { 00343 return NODETYPE_PRIORITY_JUNCTION; 00344 } 00345 // choose the uppermost type as default 00346 BasicNodeType type = NODETYPE_RIGHT_BEFORE_LEFT; 00347 // determine the type 00348 for (std::vector<NBEdge*>::const_iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 00349 for (std::vector<NBEdge*>::const_iterator j=i+1; j!=myIncomingEdges->end(); j++) { 00350 bool isOpposite = false; 00351 if (getOppositeIncoming(*j)==*i&&myIncomingEdges->size()>2) { 00352 isOpposite = true; 00353 } 00354 00355 // This usage of defaults is not very well, still we do not have any 00356 // methods for the conversion of foreign, sometimes not supplied 00357 // road types into an own format 00358 BasicNodeType tmptype = type; 00359 if (!isOpposite) { 00360 tmptype = tc.getJunctionType((*i)->getSpeed(), (*j)->getSpeed()); 00361 if (tmptype<type&&tmptype!=NODETYPE_UNKNOWN&&tmptype!=NODETYPE_NOJUNCTION) { 00362 type = tmptype; 00363 } 00364 } 00365 } 00366 } 00367 return type; 00368 }
| unsigned int NBNode::countInternalLanes | ( | bool | includeSplits | ) |
Definition at line 526 of file NBNode.cpp.
References getCrossingPosition(), and myIncomingEdges.
Referenced by writeinternal(), writeXMLInternalLinks(), writeXMLInternalNodes(), and writeXMLInternalSuccInfos().
00526 { 00527 unsigned int lno = 0; 00528 EdgeVector::iterator i; 00529 for (i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 00530 unsigned int noLanesEdge = (*i)->getNoLanes(); 00531 for (unsigned int j=0; j<noLanesEdge; j++) { 00532 std::vector<NBEdge::Connection> elv = (*i)->getConnectionsFromLane(j); 00533 for (std::vector<NBEdge::Connection>::iterator k=elv.begin(); k!=elv.end(); ++k) { 00534 if ((*k).toEdge==0) { 00535 continue; 00536 } 00537 lno++; 00538 // add internal splits if any 00539 if (includeSplits) { 00540 std::pair<SUMOReal, std::vector<unsigned int> > cross = getCrossingPosition(*i, j, (*k).toEdge, (*k).toLane); 00541 if (cross.first>=0) { 00542 lno++; 00543 } 00544 } 00545 } 00546 } 00547 } 00548 return lno; 00549 }
| unsigned int NBNode::eraseDummies | ( | NBDistrictCont & | dc, | |
| NBEdgeCont & | ec, | |||
| NBTrafficLightLogicCont & | tc | |||
| ) |
Definition at line 1528 of file NBNode.cpp.
References NBEdgeCont::erase(), NBEdge::getID(), NBEdge::isConnectedTo(), myIncomingEdges, myOutgoingEdges, NBEdge::remapConnections(), remapRemoved(), and WRITE_WARNING.
01528 { 01529 unsigned int ret = 0; 01530 if (myOutgoingEdges==0||myIncomingEdges==0) { 01531 return ret; 01532 } 01533 unsigned int pos = 0; 01534 EdgeVector::const_iterator j=myIncomingEdges->begin(); 01535 while (j!=myIncomingEdges->end()) { 01536 // skip edges which are only incoming and not outgoing 01537 if (find(myOutgoingEdges->begin(), myOutgoingEdges->end(), *j)==myOutgoingEdges->end()) { 01538 j++; 01539 pos++; 01540 continue; 01541 } 01542 // an edge with both its origin and destination being the current 01543 // node should be removed 01544 NBEdge *dummy = *j; 01545 WRITE_WARNING(" Removing dummy edge '" + dummy->getID() + "'"); 01546 // get the list of incoming edges connected to the dummy 01547 EdgeVector incomingConnected; 01548 EdgeVector::const_iterator i; 01549 for (i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01550 if ((*i)->isConnectedTo(dummy)&&*i!=dummy) { 01551 incomingConnected.push_back(*i); 01552 } 01553 } 01554 // get the list of outgoing edges connected to the dummy 01555 EdgeVector outgoingConnected; 01556 for (i=myOutgoingEdges->begin(); i!=myOutgoingEdges->end(); i++) { 01557 if (dummy->isConnectedTo(*i)&&*i!=dummy) { 01558 outgoingConnected.push_back(*i); 01559 } 01560 } 01561 // let the dummy remap its connections 01562 dummy->remapConnections(incomingConnected); 01563 remapRemoved(tc, dummy, incomingConnected, outgoingConnected); 01564 // delete the dummy 01565 ec.erase(dc, dummy); 01566 j = myIncomingEdges->begin() + pos; 01567 ret++; 01568 } 01569 return ret; 01570 }
removes the first edge from the list, marks it as higher priorised and returns it
Definition at line 514 of file NBNode.cpp.
References NBEdge::setJunctionPriority().
Referenced by setPriorityJunctionPriorities().
00514 { 00515 if (s.size()==0) { 00516 return 0; 00517 } 00518 NBEdge *ret = s.front(); 00519 s.erase(s.begin()); 00520 ret->setJunctionPriority(this, 1); 00521 return ret; 00522 }
| bool NBNode::foes | ( | const NBEdge *const | from1, | |
| const NBEdge *const | to1, | |||
| const NBEdge *const | from2, | |||
| const NBEdge *const | to2 | |||
| ) | const throw () |
Returns the information whether the given flows cross.
| [in] | from1 | The starting edge of the first stream |
| [in] | to1 | The ending edge of the first stream |
| [in] | from2 | The starting edge of the second stream |
| [in] | to2 | The ending edge of the second stream |
Definition at line 1716 of file NBNode.cpp.
References NBRequest::foes(), and myRequest.
Referenced by NBTrafficLightDefinition::forbids().
| bool NBNode::forbids | ( | const NBEdge *const | possProhibitorFrom, | |
| const NBEdge *const | possProhibitorTo, | |||
| const NBEdge *const | possProhibitedFrom, | |||
| const NBEdge *const | possProhibitedTo, | |||
| bool | regardNonSignalisedLowerPriority | |||
| ) | const throw () |
Returns the information whether "prohibited" flow must let "prohibitor" flow pass.
| [in] | possProhibitedFrom | The maybe prohibited connection's begin |
| [in] | possProhibitedTo | The maybe prohibited connection's end |
| [in] | possProhibitorFrom | The maybe prohibiting connection's begin |
| [in] | possProhibitorTo | The maybe prohibiting connection's end |
| [in] | regardNonSignalisedLowerPriority | Whether the right of way rules without traffic lights shall be regarded |
Definition at line 1706 of file NBNode.cpp.
References NBRequest::forbids(), and myRequest.
Referenced by NBTrafficLightDefinition::forbids(), getCrossingNames_dividedBySpace(), getCrossingPosition(), and getCrossingSourcesNames_dividedBySpace().
01708 { 01709 return myRequest!=0&&myRequest->forbids(possProhibitorFrom, possProhibitorTo, 01710 possProhibitedFrom, possProhibitedTo, 01711 regardNonSignalisedLowerPriority); 01712 }
Definition at line 1990 of file NBNode.cpp.
References myOutgoingEdges.
Referenced by NBEdgeCont::guessRoundabouts(), NIImporter_VISUM::parse_EdgePolys(), NIImporter_VISUM::parse_Turns(), and NGNet::toNB().
01990 { 01991 std::vector<NBEdge*>::iterator i; 01992 for (i=myOutgoingEdges->begin(); i!=myOutgoingEdges->end(); i++) { 01993 if ((*i)->getToNode()==n) { 01994 return (*i); 01995 } 01996 } 01997 return 0; 01998 }
| const std::set<NBTrafficLightDefinition*>& NBNode::getControllingTLS | ( | ) | const throw () [inline] |
Returns the traffic lights that were assigned to this node.
Definition at line 255 of file NBNode.h.
References myTrafficLights.
Referenced by NBNodeCont::guessTLs(), NIXMLNodesHandler::myStartElement(), and NBNodeCont::savePlain().
00255 { 00256 return myTrafficLights; 00257 }
| std::string NBNode::getCrossingNames_dividedBySpace | ( | NBEdge * | fromE, | |
| unsigned int | fromL, | |||
| NBEdge * | toE, | |||
| unsigned int | toL | |||
| ) |
Definition at line 820 of file NBNode.cpp.
References computeInternalLaneShape(), forbids(), getMMLDirection(), getOppositeIncoming(), NBEdge::getToNode(), MMLDIR_LEFT, MMLDIR_PARTLEFT, MMLDIR_TURN, myID, myIncomingEdges, and toString().
Referenced by writeXMLInternalNodes().
00821 { 00822 std::string ret; 00823 NBMMLDirection dir = getMMLDirection(fromE, toE); 00824 switch (dir) { 00825 case MMLDIR_LEFT: 00826 case MMLDIR_PARTLEFT: 00827 case MMLDIR_TURN: { 00828 Position2DVector thisShape = computeInternalLaneShape(fromE, fromL, toE, toL); 00829 unsigned int index = 0; 00830 for (EdgeVector::iterator i2=myIncomingEdges->begin(); i2!=myIncomingEdges->end(); i2++) { 00831 unsigned int noLanesEdge = (*i2)->getNoLanes(); 00832 for (unsigned int j2=0; j2<noLanesEdge; j2++) { 00833 std::vector<NBEdge::Connection> elv = (*i2)->getConnectionsFromLane(j2); 00834 for (std::vector<NBEdge::Connection>::iterator k2=elv.begin(); k2!=elv.end(); k2++) { 00835 if ((*k2).toEdge==0) { 00836 continue; 00837 } 00838 NBEdge *e = fromE->getToNode()->getOppositeIncoming(fromE); 00839 if (e!=*i2) { 00840 index++; 00841 continue; 00842 } 00843 NBMMLDirection dir2 = getMMLDirection(*i2, (*k2).toEdge); 00844 bool left = dir2==MMLDIR_LEFT || dir2==MMLDIR_PARTLEFT || dir2==MMLDIR_TURN; 00845 left = false; 00846 if (!left&&fromE!=(*i2)&&forbids(*i2, (*k2).toEdge, fromE, toE, true)) { 00847 if (ret.length()!=0) { 00848 ret += " "; 00849 } 00850 ret += (":" + myID + "_" + toString(index) + "_0"); 00851 } 00852 index++; 00853 } 00854 } 00855 } 00856 } 00857 break; 00858 default: 00859 break; 00860 } 00861 return ret; 00862 }
| std::pair< SUMOReal, std::vector< unsigned int > > NBNode::getCrossingPosition | ( | NBEdge * | fromE, | |
| unsigned int | fromL, | |||
| NBEdge * | toE, | |||
| unsigned int | toL | |||
| ) |
Definition at line 770 of file NBNode.cpp.
References computeInternalLaneShape(), forbids(), getMMLDirection(), Position2DVector::intersects(), Position2DVector::intersectsAtLengths(), Position2DVector::length(), MMLDIR_LEFT, MMLDIR_PARTLEFT, MMLDIR_TURN, myIncomingEdges, POSITION_EPS, and SUMOReal.
Referenced by countInternalLanes(), writeinternal(), NBRequest::writeLaneResponse(), NBEdge::writeSingleSucceeding(), writeXMLInternalLinks(), writeXMLInternalNodes(), and writeXMLInternalSuccInfos().
00770 { 00771 std::pair<SUMOReal, std::vector<unsigned int> > ret(-1, std::vector<unsigned int>()); 00772 NBMMLDirection dir = getMMLDirection(fromE, toE); 00773 switch (dir) { 00774 case MMLDIR_LEFT: 00775 case MMLDIR_PARTLEFT: 00776 case MMLDIR_TURN: { 00777 Position2DVector thisShape = computeInternalLaneShape(fromE, fromL, toE, toL); 00778 unsigned int index = 0; 00779 for (EdgeVector::iterator i2=myIncomingEdges->begin(); i2!=myIncomingEdges->end(); i2++) { 00780 unsigned int noLanesEdge = (*i2)->getNoLanes(); 00781 for (unsigned int j2=0; j2<noLanesEdge; j2++) { 00782 std::vector<NBEdge::Connection> elv = (*i2)->getConnectionsFromLane(j2); 00783 for (std::vector<NBEdge::Connection>::iterator k2=elv.begin(); k2!=elv.end(); k2++) { 00784 if ((*k2).toEdge==0) { 00785 continue; 00786 } 00787 if (fromE!=(*i2)&&forbids(*i2, (*k2).toEdge, fromE, toE, true)) { 00788 // compute the crossing point 00789 ret.second.push_back(index); 00790 Position2DVector otherShape = computeInternalLaneShape(*i2, j2, (*k2).toEdge, (*k2).toLane); 00791 if (thisShape.intersects(otherShape)) { 00792 DoubleVector dv = thisShape.intersectsAtLengths(otherShape); 00793 SUMOReal minDV = dv[0]; 00794 if (minDV<thisShape.length()-.1&&minDV>.1) { // !!!? 00795 assert(minDV>=0); 00796 if (ret.first<0||ret.first>minDV) { 00797 ret.first = minDV; 00798 } 00799 } 00800 } 00801 } 00802 index++; 00803 } 00804 } 00805 } 00806 if (dir==MMLDIR_TURN&&ret.first<0&&ret.second.size()!=0) { 00807 // let turnarounds wait at the begin if no other crossing point was found 00808 ret.first = (SUMOReal) POSITION_EPS; 00809 } 00810 } 00811 break; 00812 default: 00813 break; 00814 } 00815 return ret; 00816 }
| std::string NBNode::getCrossingSourcesNames_dividedBySpace | ( | NBEdge * | fromE, | |
| unsigned int | fromL, | |||
| NBEdge * | toE, | |||
| unsigned int | toL | |||
| ) |
Definition at line 866 of file NBNode.cpp.
References computeInternalLaneShape(), forbids(), getMMLDirection(), getOppositeIncoming(), NBEdge::getToNode(), MMLDIR_LEFT, MMLDIR_PARTLEFT, MMLDIR_TURN, myIncomingEdges, and toString().
Referenced by writeXMLInternalNodes().
00867 { 00868 std::string ret; 00869 std::vector<std::string> tmp; 00870 NBMMLDirection dir = getMMLDirection(fromE, toE); 00871 switch (dir) { 00872 case MMLDIR_LEFT: 00873 case MMLDIR_PARTLEFT: 00874 case MMLDIR_TURN: { 00875 Position2DVector thisShape = computeInternalLaneShape(fromE, fromL, toE, toL); 00876 unsigned int index = 0; 00877 for (EdgeVector::iterator i2=myIncomingEdges->begin(); i2!=myIncomingEdges->end(); i2++) { 00878 unsigned int noLanesEdge = (*i2)->getNoLanes(); 00879 for (unsigned int j2=0; j2<noLanesEdge; j2++) { 00880 std::vector<NBEdge::Connection> elv = (*i2)->getConnectionsFromLane(j2); 00881 for (std::vector<NBEdge::Connection>::iterator k2=elv.begin(); k2!=elv.end(); k2++) { 00882 if ((*k2).toEdge==0) { 00883 continue; 00884 } 00885 NBEdge *e = fromE->getToNode()->getOppositeIncoming(fromE); 00886 if (e!=*i2) { 00887 index++; 00888 continue; 00889 } 00890 NBMMLDirection dir2 = getMMLDirection(*i2, (*k2).toEdge); 00891 bool left = dir2==MMLDIR_LEFT || dir2==MMLDIR_PARTLEFT || dir2==MMLDIR_TURN; 00892 left = false; 00893 if (!left&&fromE!=(*i2)&&forbids(*i2, (*k2).toEdge, fromE, toE, true)) { 00894 std::string nid = (*i2)->getID() + "_" + toString(j2); 00895 if (find(tmp.begin(), tmp.end(), nid)==tmp.end()) { 00896 tmp.push_back(nid); 00897 } 00898 } 00899 index++; 00900 } 00901 } 00902 } 00903 } 00904 break; 00905 default: 00906 break; 00907 } 00908 for (std::vector<std::string>::iterator i=tmp.begin(); i!=tmp.end(); ++i) { 00909 if (ret.length()>0) { 00910 ret = ret + " "; 00911 } 00912 ret = ret + *i; 00913 } 00914 return ret; 00915 }
| const EdgeVector& NBNode::getEdges | ( | ) | const throw () [inline] |
Returns all edges which participate in this node.
Definition at line 208 of file NBNode.h.
References myAllEdges.
Referenced by NBNodeCont::generateNodeClusters(), and NBEdgeCont::guessRoundabouts().
00208 { 00209 return myAllEdges; 00210 }
returns a list of edges which are connected to the given outgoing edge
Definition at line 1285 of file NBNode.cpp.
References myAllEdges, and NBContHelper::nextCW().
Referenced by computeLanes2Lanes().
01285 { 01286 // get the position of the node to get the approaching nodes of 01287 std::vector<NBEdge*>::const_iterator i = find(myAllEdges.begin(), 01288 myAllEdges.end(), currentOutgoing); 01289 // get the first possible approaching edge 01290 NBContHelper::nextCW(&myAllEdges, i); 01291 // go through the list of edges clockwise and add the edges 01292 std::vector<NBEdge*> *approaching = new std::vector<NBEdge*>(); 01293 for (; *i!=currentOutgoing;) { 01294 // check only incoming edges 01295 if ((*i)->getToNode()==this&&(*i)->getTurnDestination()!=currentOutgoing) { 01296 std::vector<int> connLanes = (*i)->getConnectionLanes(currentOutgoing); 01297 if (connLanes.size()!=0) { 01298 approaching->push_back(*i); 01299 } 01300 } 01301 NBContHelper::nextCW(&myAllEdges, i); 01302 } 01303 return approaching; 01304 }
Definition at line 1923 of file NBNode.cpp.
References checkIsRemovable(), myIncomingEdges, myOutgoingEdges, and NBContHelper::nextCCW().
Referenced by NBNodeCont::removeUnwishedNodes().
01923 { 01924 assert(checkIsRemovable()); 01925 std::vector<std::pair<NBEdge*, NBEdge*> > ret; 01926 // one in, one out-case 01927 if (myOutgoingEdges->size()==1&&myIncomingEdges->size()==1) { 01928 ret.push_back( 01929 std::pair<NBEdge*, NBEdge*>( 01930 (*myIncomingEdges)[0], (*myOutgoingEdges)[0])); 01931 return ret; 01932 } 01933 // two in, two out-case 01934 for (EdgeVector::const_iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01935 NBNode *origin = (*i)->getFromNode(); 01936 EdgeVector::const_iterator j = 01937 find_if(myOutgoingEdges->begin(), myOutgoingEdges->end(), 01938 NBContHelper::edge_with_destination_finder(origin)); 01939 NBContHelper::nextCCW(myOutgoingEdges, j); 01940 ret.push_back(std::pair<NBEdge*, NBEdge*>(*i, *j)); 01941 } 01942 return ret; 01943 }
| Position2D NBNode::getEmptyDir | ( | ) | const |
Returns something like the most unused direction Should only be used to add source or sink nodes.
Definition at line 1604 of file NBNode.cpp.
References Position2D::add(), getPosition(), Position2D::mul(), myIncomingEdges, myOutgoingEdges, myPosition, Position2D::norm(), Position2D::sub(), SUMOReal, Position2D::x(), and Position2D::y().
01604 { 01605 Position2D pos(0, 0); 01606 EdgeVector::const_iterator i; 01607 for (i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01608 NBNode *conn = (*i)->getFromNode(); 01609 Position2D toAdd = conn->getPosition(); 01610 toAdd.sub(myPosition); 01611 toAdd.mul((SUMOReal) 1.0/sqrt(toAdd.x()*toAdd.x()+toAdd.y()*toAdd.y())); 01612 pos.add(toAdd); 01613 } 01614 for (i=myOutgoingEdges->begin(); i!=myOutgoingEdges->end(); i++) { 01615 NBNode *conn = (*i)->getToNode(); 01616 Position2D toAdd = conn->getPosition(); 01617 toAdd.sub(myPosition); 01618 toAdd.mul((SUMOReal) 1.0/sqrt(toAdd.x()*toAdd.x()+toAdd.y()*toAdd.y())); 01619 pos.add(toAdd); 01620 } 01621 pos.mul((SUMOReal) -1.0/(myIncomingEdges->size()+myOutgoingEdges->size())); 01622 if (pos.x()==0&&pos.y()==0) { 01623 pos = Position2D(1, 0); 01624 } 01625 pos.norm(); 01626 return pos; 01627 }
| const std::string& NBNode::getID | ( | ) | const throw () [inline] |
Returns the id of the node.
Definition at line 176 of file NBNode.h.
References myID.
Referenced by NIVisumTL::build(), NIVissimEdge::buildNBEdge(), NBNodeShapeComputer::compute(), computeInternalLaneShape(), computeLogic(), computeNodeShape(), NBNodeShapeComputer::computeNodeShapeByCrosses(), NBNode::nodes_by_id_sorter::operator()(), NBNetBuilder::by_id_sorter::operator()(), NIImporter_VISUM::parse_EdgePolys(), NIImporter_VISUM::parse_Lanes(), NIImporter_VISUM::parse_Turns(), NBNodeCont::savePlain(), NBEdgeCont::savePlain(), NBNodeCont::setAsTLControlled(), NIXMLEdgesHandler::setNodes(), NBEdge::writeSucceeding(), and NBEdge::writeXMLStep1().
00176 { 00177 return myID; 00178 }
| const EdgeVector& NBNode::getIncomingEdges | ( | ) | const throw () [inline] |
Returns this node's incoming edges.
Definition at line 192 of file NBNode.h.
References myIncomingEdges.
Referenced by NBNodeCont::buildOffRamp(), NBNodeCont::buildOnRamp(), NBNodeShapeComputer::compute(), NBEdge::decLaneNo(), NIImporter_VISUM::getNamedEdgeContinuating(), NBNodeCont::guessRamps(), NBNodeCont::guessTLs(), NBEdge::incLaneNo(), isNearDistrict(), NBNodeCont::mayNeedOffRamp(), NBNodeCont::mayNeedOnRamp(), NBContHelper::node_with_incoming_finder::operator()(), NIImporter_VISUM::parse_Lanes(), NBNodeCont::removeIsolatedRoads(), NBNodeCont::removeUnwishedNodes(), NBEdgeCont::retrievePossiblySplitted(), and NGNet::toNB().
00192 { 00193 return *myIncomingEdges; 00194 }
| std::string NBNode::getInternalLaneID | ( | NBEdge * | from, | |
| unsigned int | fromlane, | |||
| NBEdge * | to, | |||
| unsigned int | tolane | |||
| ) | const |
Definition at line 1952 of file NBNode.cpp.
References myID, myIncomingEdges, and toString().
Referenced by NBEdge::writeSingleSucceeding().
01953 { 01954 unsigned int l = 0; 01955 for (EdgeVector::const_iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01956 unsigned int noLanesEdge = (*i)->getNoLanes(); 01957 for (unsigned int j=0; j<noLanesEdge; j++) { 01958 std::vector<NBEdge::Connection> elv = (*i)->getConnectionsFromLane(j); 01959 for (std::vector<NBEdge::Connection>::iterator k=elv.begin(); k!=elv.end(); ++k) { 01960 if ((*k).toEdge==0) { 01961 continue; 01962 } 01963 if ((from==*i)&&(j==fromlane)&&((*k).toEdge==to)&&((*k).toLane==tolane)) { 01964 return ":" + myID + "_" + toString(l); 01965 } 01966 l++; 01967 } 01968 } 01969 } 01970 throw 1; 01971 }
| SUMOReal NBNode::getMaxEdgeWidth | ( | ) | const |
Definition at line 1975 of file NBNode.cpp.
References myAllEdges, and SUMOReal.
01975 { 01976 EdgeVector::const_iterator i=myAllEdges.begin(); 01977 assert(i!=myAllEdges.end()); 01978 SUMOReal ret = (*i)->width(); 01979 ++i; 01980 for (; i!=myAllEdges.end(); i++) { 01981 ret = ret > (*i)->width() 01982 ? ret 01983 : (*i)->width(); 01984 } 01985 return ret; 01986 }
| NBMMLDirection NBNode::getMMLDirection | ( | const NBEdge *const | incoming, | |
| const NBEdge *const | outgoing | |||
| ) | const throw () |
Returns the MML-representation of the described stream's direction.
| [in] | incoming | The edge the stream starts at |
| [in] | outgoing | The edge the stream ends at |
Definition at line 1804 of file NBNode.cpp.
References abs, MMLDIR_LEFT, MMLDIR_NODIR, MMLDIR_PARTLEFT, MMLDIR_PARTRIGHT, MMLDIR_RIGHT, MMLDIR_STRAIGHT, MMLDIR_TURN, myAllEdges, NBContHelper::nextCCW(), NBContHelper::nextCW(), NBHelpers::normRelAngle(), and SUMOReal.
Referenced by getCrossingNames_dividedBySpace(), getCrossingPosition(), getCrossingSourcesNames_dividedBySpace(), NBEdge::MainDirections::MainDirections(), and NBEdge::writeSingleSucceeding().
01804 { 01805 // ok, no connection at all -> dead end 01806 if (outgoing==0) { 01807 return MMLDIR_NODIR; 01808 } 01809 // turning direction 01810 if (incoming->isTurningDirectionAt(this, outgoing)) { 01811 return MMLDIR_TURN; 01812 } 01813 // get the angle between incoming/outgoing at the junction 01814 SUMOReal angle = 01815 NBHelpers::normRelAngle(incoming->getAngle(*this), outgoing->getAngle(*this)); 01816 // ok, should be a straight connection 01817 if (abs((int) angle)+1<45) { 01818 return MMLDIR_STRAIGHT; 01819 } 01820 01821 // check for left and right, first 01822 if (angle>0) { 01823 // check whether any other edge goes further to the right 01824 EdgeVector::const_iterator i = 01825 find(myAllEdges.begin(), myAllEdges.end(), outgoing); 01826 NBContHelper::nextCW(&myAllEdges, i); 01827 while ((*i)!=incoming) { 01828 if ((*i)->getFromNode()==this) { 01829 return MMLDIR_PARTRIGHT; 01830 } 01831 NBContHelper::nextCW(&myAllEdges, i); 01832 } 01833 return MMLDIR_RIGHT; 01834 } 01835 // check whether any other edge goes further to the left 01836 EdgeVector::const_iterator i = 01837 find(myAllEdges.begin(), myAllEdges.end(), outgoing); 01838 NBContHelper::nextCCW(&myAllEdges, i); 01839 while ((*i)!=incoming) { 01840 if ((*i)->getFromNode()==this&&!incoming->isTurningDirectionAt(this, *i)) { 01841 return MMLDIR_PARTLEFT; 01842 } 01843 NBContHelper::nextCCW(&myAllEdges, i); 01844 } 01845 return MMLDIR_LEFT; 01846 }
Definition at line 1470 of file NBNode.cpp.
References NBEdge::getToNode(), and myIncomingEdges.
Referenced by computeType(), getCrossingNames_dividedBySpace(), and getCrossingSourcesNames_dividedBySpace().
01470 { 01471 EdgeVector edges(*myIncomingEdges); 01472 if (find(edges.begin(), edges.end(), e)!=edges.end()) { 01473 edges.erase(find(edges.begin(), edges.end(), e)); 01474 } 01475 if (e->getToNode()==this) { 01476 sort(edges.begin(), edges.end(), NBContHelper::edge_opposite_direction_sorter(e)); 01477 } else { 01478 sort(edges.begin(), edges.end(), NBContHelper::edge_similar_direction_sorter(e)); 01479 } 01480 return edges[0]; 01481 }
| const EdgeVector& NBNode::getOutgoingEdges | ( | ) | const throw () [inline] |
Returns this node's outgoing edges.
Definition at line 200 of file NBNode.h.
References myOutgoingEdges.
Referenced by NBNodeCont::buildOffRamp(), NBNodeCont::buildOnRamp(), NBNodeShapeComputer::compute(), NBEdge::computeEdge2Edges(), NBEdge::computeTurningDirections(), NBEdge::decLaneNo(), NBEdge::getConnectedSorted(), NIImporter_VISUM::getNamedEdgeContinuating(), NBNodeCont::guessRamps(), isNearDistrict(), NBEdge::markAsInLane2LaneState(), NBNodeCont::mayNeedOffRamp(), NBNodeCont::mayNeedOnRamp(), NBContHelper::node_with_outgoing_finder::operator()(), NIImporter_VISUM::parse_Lanes(), NIXMLConnectionsHandler::parseLaneBound(), NBNodeCont::removeIsolatedRoads(), NBNodeCont::removeUnwishedNodes(), and NBEdgeCont::retrievePossiblySplitted().
00200 { 00201 return *myOutgoingEdges; 00202 }
| const Position2D& NBNode::getPosition | ( | ) | const throw () [inline] |
Returns the position of this node.
Definition at line 184 of file NBNode.h.
References myPosition.
Referenced by NIVissimEdge::buildNBEdge(), NBNodeCont::buildOffRamp(), NBNodeCont::buildOnRamp(), NBNodeShapeComputer::computeNodeShapeByCrosses(), NBHelpers::distance(), NBNodeCont::generateNodeClusters(), getEmptyDir(), NBNodeCont::guessRamps(), NBEdge::init(), NIXMLNodesHandler::myStartElement(), NIVissimEdge::remapOneOfNodes(), NIImporter_DlrNavteq::TrafficlightsHandler::report(), NIImporter_DlrNavteq::EdgesHandler::report(), NBNodeCont::retrieve(), NBNodeCont::savePlain(), sortNodesEdges(), and NBEdge::splitGeometry().
00184 { 00185 return myPosition; 00186 }
| NBEdge * NBNode::getPossiblySplittedIncoming | ( | const std::string & | edgeid | ) |
Definition at line 1502 of file NBNode.cpp.
References myIncomingEdges, and size.
Referenced by NIVissimDisturbance::getConnection().
01502 { 01503 unsigned int size = (unsigned int) edgeid.length(); 01504 for (EdgeVector::iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01505 std::string id = (*i)->getID(); 01506 if (id.substr(0, size)==edgeid) { 01507 return *i; 01508 } 01509 } 01510 return 0; 01511 }
| NBEdge * NBNode::getPossiblySplittedOutgoing | ( | const std::string & | edgeid | ) |
Definition at line 1515 of file NBNode.cpp.
References myOutgoingEdges, and size.
Referenced by NIVissimDisturbance::getConnection().
01515 { 01516 unsigned int size = (unsigned int) edgeid.length(); 01517 for (EdgeVector::iterator i=myOutgoingEdges->begin(); i!=myOutgoingEdges->end(); i++) { 01518 std::string id = (*i)->getID(); 01519 if (id.substr(0, size)==edgeid) { 01520 return *i; 01521 } 01522 } 01523 return 0; 01524 }
| const Position2DVector & NBNode::getShape | ( | ) | const |
Definition at line 1947 of file NBNode.cpp.
References myPoly.
Referenced by NBEdge::computeEdgeShape().
01947 { 01948 return myPoly; 01949 }
| BasicNodeType NBNode::getType | ( | ) | const throw () [inline] |
Returns the type of this node.
Definition at line 217 of file NBNode.h.
References myType.
Referenced by NIXMLNodesHandler::myStartElement(), NIImporter_DlrNavteq::TrafficlightsHandler::report(), and NBRequest::setBlocking().
00217 { 00218 return myType; 00219 }
Returns whether the given edge ends at this node.
| [in] | e | The edge |
Definition at line 1458 of file NBNode.cpp.
References myIncomingEdges.
Referenced by NIImporter_OpenDrive::addE2EConnectionsSecure(), NBNodeShapeComputer::computeContinuationNodeShape(), NBNodeShapeComputer::computeUniqueDirectionList(), NBNodeCont::generateNodeClusters(), NIImporter_OpenDrive::getIncomingDirectionalEdge(), NBNodeShapeComputer::joinSameDirectionEdges(), NIImporter_VISUM::parse_Lanes(), NIImporter_VISUM::parse_LanesConnections(), and NIImporter_VISUM::parse_TurnsToSignalGroups().
01458 { 01459 return find(myIncomingEdges->begin(), myIncomingEdges->end(), e)!=myIncomingEdges->end(); 01460 }
Returns whether the given edge starts at this node.
| [in] | e | The edge |
Definition at line 1464 of file NBNode.cpp.
References myOutgoingEdges.
Referenced by NIImporter_OpenDrive::addE2EConnectionsSecure(), NBNodeShapeComputer::computeContinuationNodeShape(), NIImporter_OpenDrive::getOutgoingDirectionalEdge(), NIImporter_VISUM::parse_Lanes(), NIImporter_VISUM::parse_LanesConnections(), and NIImporter_VISUM::parse_TurnsToSignalGroups().
01464 { 01465 return find(myOutgoingEdges->begin(), myOutgoingEdges->end(), e)!=myOutgoingEdges->end(); 01466 }
| void NBNode::invalidateIncomingConnections | ( | ) |
Definition at line 1632 of file NBNode.cpp.
References myIncomingEdges.
Referenced by NIVissimDistrictConnection::dict_BuildDistricts().
01632 { 01633 for (EdgeVector::const_iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01634 (*i)->invalidateConnections(); 01635 } 01636 }
| void NBNode::invalidateOutgoingConnections | ( | ) |
Definition at line 1640 of file NBNode.cpp.
References myOutgoingEdges.
Referenced by NIVissimDistrictConnection::dict_BuildDistricts().
01640 { 01641 for (EdgeVector::const_iterator i=myOutgoingEdges->begin(); i!=myOutgoingEdges->end(); i++) { 01642 (*i)->invalidateConnections(); 01643 } 01644 }
| bool NBNode::isDistrict | ( | ) | const |
Definition at line 2033 of file NBNode.cpp.
References myType, and NODETYPE_DISTRICT.
Referenced by computeLogic(), and isNearDistrict().
02033 { 02034 return myType==NODETYPE_DISTRICT; 02035 }
| bool NBNode::isJoinedTLSControlled | ( | ) | const throw () |
Returns whether this node is controlled by a tls that spans over more than one node.
Definition at line 256 of file NBNode.cpp.
References isTLControlled(), and myTrafficLights.
00256 { 00257 if (!isTLControlled()) { 00258 return false; 00259 } 00260 for (std::set<NBTrafficLightDefinition*>::const_iterator i=myTrafficLights.begin(); i!=myTrafficLights.end(); ++i) { 00261 if ((*i)->getID().find("joined")==0) { 00262 return true; 00263 } 00264 } 00265 return false; 00266 }
Computes whether the given connection is a left mover across the junction.
It is assumed, that it is a left-mover if the clockwise angle is lower than the counter-clockwise angle.
| [in] | from | The incoming edge (the begin of the connection) |
| [in] | from | The outgoing edge (the end of the connection) |
Definition at line 1693 of file NBNode.cpp.
References GeomHelper::getCCWAngleDiff(), GeomHelper::getCWAngleDiff(), myIncomingEdges, and SUMOReal.
01693 { 01694 // when the junction has only one incoming edge, there are no 01695 // problems caused by left blockings 01696 if (myIncomingEdges->size()==1) { 01697 return false; 01698 } 01699 SUMOReal ccw = GeomHelper::getCCWAngleDiff(from->getAngle(*this), to->getAngle(*this)); 01700 SUMOReal cw = GeomHelper::getCWAngleDiff(from->getAngle(*this), to->getAngle(*this)); 01701 return cw<ccw; 01702 }
| bool NBNode::isNearDistrict | ( | ) | const |
Definition at line 2002 of file NBNode.cpp.
References NBEdge::getFromNode(), getIncomingEdges(), getOutgoingEdges(), NBEdge::getToNode(), and isDistrict().
Referenced by computeLogic(), and NBNodeCont::guessTLs().
02002 { 02003 if (isDistrict()) { 02004 return false; 02005 } 02006 EdgeVector edges; 02007 copy(getIncomingEdges().begin(), getIncomingEdges().end(), 02008 back_inserter(edges)); 02009 copy(getOutgoingEdges().begin(), getOutgoingEdges().end(), 02010 back_inserter(edges)); 02011 for (EdgeVector::const_iterator j=edges.begin(); j!=edges.end(); ++j) { 02012 NBEdge *t = *j; 02013 NBNode *other = 0; 02014 if (t->getToNode()==this) { 02015 other = t->getFromNode(); 02016 } else { 02017 other = t->getToNode(); 02018 } 02019 EdgeVector edges2; 02020 copy(other->getIncomingEdges().begin(), other->getIncomingEdges().end(), back_inserter(edges2)); 02021 copy(other->getOutgoingEdges().begin(), other->getOutgoingEdges().end(), back_inserter(edges2)); 02022 for (EdgeVector::const_iterator k=edges2.begin(); k!=edges2.end(); ++k) { 02023 if ((*k)->getFromNode()->isDistrict()||(*k)->getToNode()->isDistrict()) { 02024 return true; 02025 } 02026 } 02027 } 02028 return false; 02029 }
| bool NBNode::isSimpleContinuation | ( | ) | const [private] |
Definition at line 372 of file NBNode.cpp.
References NBEdge::getNoLanes(), myIncomingEdges, myOutgoingEdges, and NBContHelper::nextCW().
Referenced by NBNodeShapeComputer::compute(), and computeType().
00372 { 00373 // one in, one out->continuation 00374 if (myIncomingEdges->size()==1&&myOutgoingEdges->size()==1) { 00375 // both must have the same number of lanes 00376 return (*(myIncomingEdges->begin()))->getNoLanes()==(*(myOutgoingEdges->begin()))->getNoLanes(); 00377 } 00378 // two in and two out and both in reverse direction 00379 if (myIncomingEdges->size()==2&&myOutgoingEdges->size()==2) { 00380 for (EdgeVector::const_iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 00381 NBEdge *in = *i; 00382 EdgeVector::const_iterator opposite = find_if(myOutgoingEdges->begin(), myOutgoingEdges->end(), NBContHelper::opposite_finder(in, this)); 00383 // must have an opposite edge 00384 if (opposite==myOutgoingEdges->end()) { 00385 return false; 00386 } 00387 // both must have the same number of lanes 00388 NBContHelper::nextCW(myOutgoingEdges, opposite); 00389 if (in->getNoLanes()!=(*opposite)->getNoLanes()) { 00390 return false; 00391 } 00392 } 00393 return true; 00394 } 00395 // nope 00396 return false; 00397 }
| bool NBNode::isTLControlled | ( | ) | const throw () [inline] |
Returns whether this node is controlled by any tls.
Definition at line 241 of file NBNode.h.
References myTrafficLights.
Referenced by NBEdge::appendTurnaround(), NBNodeCont::guessTLs(), isJoinedTLSControlled(), and NBNodeCont::savePlain().
00241 { 00242 return myTrafficLights.size()!=0; 00243 }
| bool NBNode::mustBrake | ( | const NBEdge *const | from, | |
| const NBEdge *const | to, | |||
| int | toLane | |||
| ) | const throw () |
Returns the information whether the described flow must let any other flow pass.
| [in] | from | The connection's start edge |
| [in] | to | The connection's end edge |
| [in] | toLane | The lane the connection ends at |
Definition at line 1648 of file NBNode.cpp.
References NBRequest::mustBrake(), myIncomingEdges, myRequest, and myTrafficLights.
Referenced by stateCode(), and NBEdge::writeSingleSucceeding().
01648 { 01649 // check whether it is participant to a traffic light 01650 // - controlled links are set by the traffic lights, not the normal 01651 // right-of-way rules 01652 // - uncontrolled participants (spip lanes etc.) should always break 01653 if (myTrafficLights.size()!=0) { 01654 // ok, we have a traffic light, return true by now, it will be later 01655 // controlled by the tls 01656 return true; 01657 } 01658 // unregulated->does not need to brake 01659 if (myRequest==0) { 01660 return false; 01661 } 01662 // vehicles which do not have a following lane must always decelerate to the end 01663 if (to==0) { 01664 return true; 01665 } 01666 // check whether any other connection on this node prohibits this connection 01667 bool try1 = myRequest->mustBrake(from, to); 01668 if (!try1||toLane==-1) { 01669 return try1; 01670 } 01671 if (from->getSpeed()<70./3.6) { 01672 return try1; 01673 } 01674 // on highways (on-ramps, in fact): 01675 // check whether any other connection uses the same destination edge 01676 for (EdgeVector::const_iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01677 if ((*i)==from) { 01678 continue; 01679 } 01680 const std::vector<NBEdge::Connection> &connections = (*i)->getConnections(); 01681 for (std::vector<NBEdge::Connection>::const_iterator j=connections.begin(); j!=connections.end(); ++j) { 01682 if ((*j).toEdge==to&&((*j).toLane<0||(*j).toLane==toLane)) { 01683 return true; 01684 } 01685 } 01686 } 01687 return false; 01688 }
| void NBNode::reinit | ( | const Position2D & | position, | |
| BasicNodeType | type | |||
| ) | throw () |
Resets initial values.
| [in] | position | The position of the node |
| [in] | type | The type of the node |
Definition at line 228 of file NBNode.cpp.
References myPosition, myType, NODETYPE_TRAFFIC_LIGHT, and removeTrafficLights().
Referenced by NIXMLNodesHandler::myStartElement(), and NIImporter_DlrNavteq::TrafficlightsHandler::report().
00228 { 00229 myPosition = position; 00230 // patch type 00231 myType = type; 00232 if (myType!=NODETYPE_TRAFFIC_LIGHT) { 00233 removeTrafficLights(); 00234 } 00235 }
| void NBNode::remapRemoved | ( | NBTrafficLightLogicCont & | tc, | |
| NBEdge * | removed, | |||
| const EdgeVector & | incoming, | |||
| const EdgeVector & | outgoing | |||
| ) | [private] |
Definition at line 1723 of file NBNode.cpp.
References NBConnection::getFrom(), NBConnection::getTo(), myBlockedConnections, and NBTrafficLightLogicCont::remapRemoved().
Referenced by eraseDummies().
01725 { 01726 assert(find(incoming.begin(), incoming.end(), removed)==incoming.end()); 01727 bool changed = true; 01728 while (changed) { 01729 changed = false; 01730 NBConnectionProhibits blockedConnectionsTmp = myBlockedConnections; 01731 NBConnectionProhibits blockedConnectionsNew; 01732 // remap in connections 01733 for (NBConnectionProhibits::iterator i=blockedConnectionsTmp.begin(); i!=blockedConnectionsTmp.end(); i++) { 01734 const NBConnection &blocker = (*i).first; 01735 const NBConnectionVector &blocked = (*i).second; 01736 // check the blocked connections first 01737 // check whether any of the blocked must be changed 01738 bool blockedChanged = false; 01739 NBConnectionVector newBlocked; 01740 NBConnectionVector::const_iterator j; 01741 for (j=blocked.begin(); j!=blocked.end(); j++) { 01742 const NBConnection &sblocked = *j; 01743 if (sblocked.getFrom()==removed||sblocked.getTo()==removed) { 01744 blockedChanged = true; 01745 } 01746 } 01747 // adapt changes if so 01748 for (j=blocked.begin(); blockedChanged&&j!=blocked.end(); j++) { 01749 const NBConnection &sblocked = *j; 01750 if (sblocked.getFrom()==removed&&sblocked.getTo()==removed) { 01751 /* for(EdgeVector::const_iterator k=incoming.begin(); k!=incoming.end(); k++) { 01752 !!! newBlocked.push_back(NBConnection(*k, *k)); 01753 }*/ 01754 } else if (sblocked.getFrom()==removed) { 01755 assert(sblocked.getTo()!=removed); 01756 for (EdgeVector::const_iterator k=incoming.begin(); k!=incoming.end(); k++) { 01757 newBlocked.push_back(NBConnection(*k, sblocked.getTo())); 01758 } 01759 } else if (sblocked.getTo()==removed) { 01760 assert(sblocked.getFrom()!=removed); 01761 for (EdgeVector::const_iterator k=outgoing.begin(); k!=outgoing.end(); k++) { 01762 newBlocked.push_back(NBConnection(sblocked.getFrom(), *k)); 01763 } 01764 } else { 01765 newBlocked.push_back(NBConnection(sblocked.getFrom(), sblocked.getTo())); 01766 } 01767 } 01768 if (blockedChanged) { 01769 blockedConnectionsNew[blocker] = newBlocked; 01770 changed = true; 01771 } 01772 // if the blocked were kept 01773 else { 01774 if (blocker.getFrom()==removed&&blocker.getTo()==removed) { 01775 changed = true; 01776 /* for(EdgeVector::const_iterator k=incoming.begin(); k!=incoming.end(); k++) { 01777 !!! blockedConnectionsNew[NBConnection(*k, *k)] = blocked; 01778 }*/ 01779 } else if (blocker.getFrom()==removed) { 01780 assert(blocker.getTo()!=removed); 01781 changed = true; 01782 for (EdgeVector::const_iterator k=incoming.begin(); k!=incoming.end(); k++) { 01783 blockedConnectionsNew[NBConnection(*k, blocker.getTo())] = blocked; 01784 } 01785 } else if (blocker.getTo()==removed) { 01786 assert(blocker.getFrom()!=removed); 01787 changed = true; 01788 for (EdgeVector::const_iterator k=outgoing.begin(); k!=outgoing.end(); k++) { 01789 blockedConnectionsNew[NBConnection(blocker.getFrom(), *k)] = blocked; 01790 } 01791 } else { 01792 blockedConnectionsNew[blocker] = blocked; 01793 } 01794 } 01795 } 01796 myBlockedConnections = blockedConnectionsNew; 01797 } 01798 // remap in traffic lights 01799 tc.remapRemoved(removed, incoming, outgoing); 01800 }
| void NBNode::removeDoubleEdges | ( | ) |
Definition at line 1419 of file NBNode.cpp.
References myAllEdges, myIncomingEdges, myOutgoingEdges, and size.
Referenced by replaceIncoming(), and replaceOutgoing().
01419 { 01420 unsigned int i, j; 01421 // check incoming 01422 for (i=0; myIncomingEdges->size()>0&&i<myIncomingEdges->size()-1; i++) { 01423 j = i + 1; 01424 while (j<myIncomingEdges->size()) { 01425 if ((*myIncomingEdges)[i]==(*myIncomingEdges)[j]) { 01426 myIncomingEdges->erase(myIncomingEdges->begin()+j); 01427 } else { 01428 j++; 01429 } 01430 } 01431 } 01432 // check outgoing 01433 for (i=0; myOutgoingEdges->size()>0&&i<myOutgoingEdges->size()-1; i++) { 01434 j = i + 1; 01435 while (j<myOutgoingEdges->size()) { 01436 if ((*myOutgoingEdges)[i]==(*myOutgoingEdges)[j]) { 01437 myOutgoingEdges->erase(myOutgoingEdges->begin()+j); 01438 } else { 01439 j++; 01440 } 01441 } 01442 } 01443 // check all 01444 for (i=0; myAllEdges.size()>0&&i<myAllEdges.size()-1; i++) { 01445 j = i + 1; 01446 while (j<myAllEdges.size()) { 01447 if (myAllEdges[i]==myAllEdges[j]) { 01448 myAllEdges.erase(myAllEdges.begin()+j); 01449 } else { 01450 j++; 01451 } 01452 } 01453 } 01454 }
| void NBNode::removeIncoming | ( | NBEdge * | edge | ) |
Definition at line 1588 of file NBNode.cpp.
References myAllEdges, and myIncomingEdges.
Referenced by NBNodeCont::guessRamps(), NBEdge::reinit(), NBEdgeCont::removeUnwishedEdges(), and NBEdge::splitGeometry().
01588 { 01589 EdgeVector::iterator i = find(myIncomingEdges->begin(), myIncomingEdges->end(), edge); 01590 if (i!=myIncomingEdges->end()) { 01591 myIncomingEdges->erase(i); 01592 i = find(myAllEdges.begin(), myAllEdges.end(), edge); 01593 myAllEdges.erase(i); 01594 for (i=myAllEdges.begin(); i!=myAllEdges.end(); ++i) { 01595 (*i)->removeFromConnections(edge); 01596 } 01597 } 01598 }
| void NBNode::removeOutgoing | ( | NBEdge * | edge | ) |
Definition at line 1574 of file NBNode.cpp.
References myAllEdges, and myOutgoingEdges.
Referenced by NBEdge::reinit(), and NBEdgeCont::removeUnwishedEdges().
01574 { 01575 EdgeVector::iterator i = find(myOutgoingEdges->begin(), myOutgoingEdges->end(), edge); 01576 if (i!=myOutgoingEdges->end()) { 01577 myOutgoingEdges->erase(i); 01578 i = find(myAllEdges.begin(), myAllEdges.end(), edge); 01579 myAllEdges.erase(i); 01580 for (i=myAllEdges.begin(); i!=myAllEdges.end(); ++i) { 01581 (*i)->removeFromConnections(edge); 01582 } 01583 } 01584 }
| void NBNode::removeTrafficLights | ( | ) | throw () |
Removes all references to traffic lights that control this tls.
Definition at line 247 of file NBNode.cpp.
References myTrafficLights.
Referenced by NBNodeCont::guessTLs(), NIXMLNodesHandler::myStartElement(), and reinit().
00247 { 00248 for (std::set<NBTrafficLightDefinition*>::const_iterator i=myTrafficLights.begin(); i!=myTrafficLights.end(); ++i) { 00249 (*i)->removeNode(this); 00250 } 00251 myTrafficLights.clear(); 00252 }
| void NBNode::replaceIncoming | ( | const EdgeVector & | which, | |
| NBEdge * | by | |||
| ) |
Replaces occurences of every edge from the given list within the list of incoming by the second Connections are remapped, too.
Definition at line 1365 of file NBNode.cpp.
References myDistrict, removeDoubleEdges(), and replaceIncoming().
01365 { 01366 // replace edges 01367 unsigned int laneOff = 0; 01368 for (EdgeVector::const_iterator i=which.begin(); i!=which.end(); i++) { 01369 replaceIncoming(*i, by, laneOff); 01370 laneOff += (*i)->getNoLanes(); 01371 } 01372 // removed SUMOReal occurences 01373 removeDoubleEdges(); 01374 // check whether this node belongs to a district and the edges 01375 // must here be also remapped 01376 if (myDistrict!=0) { 01377 myDistrict->replaceIncoming(which, by); 01378 } 01379 }
Replaces occurences of the first edge within the list of incoming by the second Connections are remapped, too.
Definition at line 1351 of file NBNode.cpp.
References myAllEdges, myIncomingEdges, and replaceInConnectionProhibitions().
Referenced by NBEdgeCont::joinSameNodeConnectingEdges(), NBNodeCont::removeUnwishedNodes(), and replaceIncoming().
01351 { 01352 // replace the edge in the list of incoming nodes 01353 std::vector<NBEdge*>::iterator i=find(myIncomingEdges->begin(), myIncomingEdges->end(), which); 01354 if (i!=myIncomingEdges->end()) { 01355 (*i) = by; 01356 i = find(myAllEdges.begin(), myAllEdges.end(), which); 01357 (*i) = by; 01358 } 01359 // replace within the connetion prohibition dependencies 01360 replaceInConnectionProhibitions(which, by, laneOff, 0); 01361 }
| void NBNode::replaceInConnectionProhibitions | ( | NBEdge * | which, | |
| NBEdge * | by, | |||
| unsigned int | whichLaneOff, | |||
| unsigned int | byLaneOff | |||
| ) | [private] |
Definition at line 1384 of file NBNode.cpp.
References myBlockedConnections, NBConnection::replaceFrom(), and NBConnection::replaceTo().
Referenced by replaceIncoming(), and replaceOutgoing().
01385 { 01386 // replace in keys 01387 NBConnectionProhibits::iterator j = myBlockedConnections.begin(); 01388 while (j!=myBlockedConnections.end()) { 01389 bool changed = false; 01390 NBConnection c = (*j).first; 01391 if (c.replaceFrom(which, whichLaneOff, by, byLaneOff)) { 01392 changed = true; 01393 } 01394 if (c.replaceTo(which, whichLaneOff, by, byLaneOff)) { 01395 changed = true; 01396 } 01397 if (changed) { 01398 myBlockedConnections[c] = (*j).second; 01399 myBlockedConnections.erase(j); 01400 j = myBlockedConnections.begin(); 01401 } else { 01402 j++; 01403 } 01404 } 01405 // replace in values 01406 for (j=myBlockedConnections.begin(); j!=myBlockedConnections.end(); j++) { 01407 NBConnectionVector &prohibiting = (*j).second; 01408 for (NBConnectionVector::iterator k=prohibiting.begin(); k!=prohibiting.end(); k++) { 01409 NBConnection &sprohibiting = *k; 01410 sprohibiting.replaceFrom(which, whichLaneOff, by, byLaneOff); 01411 sprohibiting.replaceTo(which, whichLaneOff, by, byLaneOff); 01412 } 01413 } 01414 }
| void NBNode::replaceOutgoing | ( | const EdgeVector & | which, | |
| NBEdge * | by | |||
| ) |
Replaces occurences of every edge from the given list within the list of outgoing by the second Connections are remapped, too.
Definition at line 1333 of file NBNode.cpp.
References myDistrict, removeDoubleEdges(), and replaceOutgoing().
01333 { 01334 // replace edges 01335 unsigned int laneOff = 0; 01336 for (EdgeVector::const_iterator i=which.begin(); i!=which.end(); i++) { 01337 replaceOutgoing(*i, by, laneOff); 01338 laneOff += (*i)->getNoLanes(); 01339 } 01340 // removed SUMOReal occurences 01341 removeDoubleEdges(); 01342 // check whether this node belongs to a district and the edges 01343 // must here be also remapped 01344 if (myDistrict!=0) { 01345 myDistrict->replaceOutgoing(which, by); 01346 } 01347 }
Replaces occurences of the first edge within the list of outgoing by the second Connections are remapped, too.
Definition at line 1315 of file NBNode.cpp.
References myAllEdges, myIncomingEdges, myOutgoingEdges, replaceInConnectionProhibitions(), and NBEdge::replaceInConnections().
Referenced by NBEdgeCont::joinSameNodeConnectingEdges(), and replaceOutgoing().
01315 { 01316 // replace the edge in the list of outgoing nodes 01317 std::vector<NBEdge*>::iterator i=find(myOutgoingEdges->begin(), myOutgoingEdges->end(), which); 01318 if (i!=myOutgoingEdges->end()) { 01319 (*i) = by; 01320 i = find(myAllEdges.begin(), myAllEdges.end(), which); 01321 (*i) = by; 01322 } 01323 // replace the edge in connections of incoming edges 01324 for (i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); ++i) { 01325 (*i)->replaceInConnections(which, by, laneOff); 01326 } 01327 // replace within the connetion prohibition dependencies 01328 replaceInConnectionProhibitions(which, by, 0, laneOff); 01329 }
| void NBNode::reshiftPosition | ( | SUMOReal | xoff, | |
| SUMOReal | yoff | |||
| ) | [private] |
resets the position by the given amount
Definition at line 1308 of file NBNode.cpp.
References myPoly, myPosition, Position2DVector::reshiftRotate(), and Position2D::reshiftRotate().
01308 { 01309 myPosition.reshiftRotate(xoff, yoff, 0); 01310 myPoly.reshiftRotate(xoff, yoff, 0); 01311 }
| void NBNode::setPriorities | ( | ) | [private] |
computes the priorities of participating edges within this junction
Definition at line 311 of file NBNode.cpp.
References myAllEdges, myIncomingEdges, myOutgoingEdges, myType, NODETYPE_RIGHT_BEFORE_LEFT, and setPriorityJunctionPriorities().
Referenced by sortNodesEdges().
00311 { 00312 // reset all priorities 00313 std::vector<NBEdge*>::iterator i; 00314 // check if the junction is not a real junction 00315 if (myIncomingEdges->size()==1&&myOutgoingEdges->size()==1) { 00316 for (i=myAllEdges.begin(); i!=myAllEdges.end(); i++) { 00317 (*i)->setJunctionPriority(this, 1); 00318 } 00319 return; 00320 } 00321 // preset all junction's edge priorities to zero 00322 for (i=myAllEdges.begin(); i!=myAllEdges.end(); i++) { 00323 (*i)->setJunctionPriority(this, 0); 00324 } 00325 // compute the priorities on junction when needed 00326 if (myType!=NODETYPE_RIGHT_BEFORE_LEFT) { 00327 setPriorityJunctionPriorities(); 00328 } 00329 }
| void NBNode::setPriorityJunctionPriorities | ( | ) | [private] |
sets the priorites in case of a priority junction
Definition at line 416 of file NBNode.cpp.
References extractAndMarkFirst(), NBEdge::getAngle(), GeomHelper::getMinAngleDiff(), myIncomingEdges, myOutgoingEdges, samePriority(), NBEdge::setJunctionPriority(), and SUMOReal.
Referenced by setPriorities().
00416 { 00417 if (myIncomingEdges->size()==0||myOutgoingEdges->size()==0) { 00418 return; 00419 } 00420 std::vector<NBEdge*> incoming(*myIncomingEdges); 00421 std::vector<NBEdge*> outgoing(*myOutgoingEdges); 00422 // what we do want to have is to extract the pair of roads that are 00423 // the major roads for this junction 00424 // let's get the list of incoming edges with the highest priority 00425 std::sort(incoming.begin(), incoming.end(), NBContHelper::edge_by_priority_sorter()); 00426 std::vector<NBEdge*> bestIncoming; 00427 NBEdge *best = incoming[0]; 00428 while (incoming.size()>0&&samePriority(best, incoming[0])) { 00429 bestIncoming.push_back(*incoming.begin()); 00430 incoming.erase(incoming.begin()); 00431 } 00432 // now, let's get the list of best outgoing 00433 assert(outgoing.size()!=0); 00434 sort(outgoing.begin(), outgoing.end(), NBContHelper::edge_by_priority_sorter()); 00435 std::vector<NBEdge*> bestOutgoing; 00436 best = outgoing[0]; 00437 while (outgoing.size()>0&&samePriority(best, outgoing[0])) {//->getPriority()==best->getPriority()) { 00438 bestOutgoing.push_back(*outgoing.begin()); 00439 outgoing.erase(outgoing.begin()); 00440 } 00441 // now, let's compute for each of the best incoming edges 00442 // the incoming which is most opposite 00443 // the outgoing which is most opposite 00444 std::vector<NBEdge*>::iterator i; 00445 std::map<NBEdge*, NBEdge*> counterIncomingEdges; 00446 std::map<NBEdge*, NBEdge*> counterOutgoingEdges; 00447 incoming = *myIncomingEdges; 00448 outgoing = *myOutgoingEdges; 00449 for (i=bestIncoming.begin(); i!=bestIncoming.end(); ++i) { 00450 std::sort(incoming.begin(), incoming.end(), NBContHelper::edge_opposite_direction_sorter(*i)); 00451 counterIncomingEdges[*i] = *incoming.begin(); 00452 std::sort(outgoing.begin(), outgoing.end(), NBContHelper::edge_opposite_direction_sorter(*i)); 00453 counterOutgoingEdges[*i] = *outgoing.begin(); 00454 } 00455 // ok, let's try 00456 // 1) there is one best incoming road 00457 if (bestIncoming.size()==1) { 00458 // let's mark this road as the best 00459 NBEdge *best1 = extractAndMarkFirst(bestIncoming); 00460 if (bestOutgoing.size()!=0) { 00461 // mark the best outgoing as the continuation 00462 sort(bestOutgoing.begin(), bestOutgoing.end(), NBContHelper::edge_similar_direction_sorter(best1)); 00463 extractAndMarkFirst(bestOutgoing); 00464 } 00465 return; 00466 } 00467 // 2b) there are more than one best incoming roads 00468 // and the same number of best outgoing roads 00469 00470 // ok, what we want to do in this case is to determine which incoming 00471 // has the best continuation... 00472 // This means, when several incoming roads have the same priority, 00473 // we want a (any) straight connection to be more priorised than a turning 00474 SUMOReal bestAngle = 0; 00475 NBEdge *bestFirst = 0; 00476 NBEdge *bestSecond = 0; 00477 bool hadBest = false; 00478 for (i=bestIncoming.begin(); i!=bestIncoming.end(); ++i) { 00479 std::vector<NBEdge*>::iterator j; 00480 NBEdge *t1 = *i; 00481 SUMOReal angle1 = t1->getAngle()+180; 00482 if (angle1>=360) { 00483 angle1 -= 360; 00484 } 00485 for (j=i+1; j!=bestIncoming.end(); ++j) { 00486 NBEdge *t2 = *j; 00487 SUMOReal angle2 = t2->getAngle()+180; 00488 if (angle2>=360) { 00489 angle2 -= 360; 00490 } 00491 SUMOReal angle = GeomHelper::getMinAngleDiff(angle1, angle2); 00492 if (!hadBest||angle>bestAngle) { 00493 bestAngle = angle; 00494 bestFirst = *i; 00495 bestSecond = *j; 00496 hadBest = true; 00497 } 00498 } 00499 } 00500 bestFirst->setJunctionPriority(this, 1); 00501 sort(bestOutgoing.begin(), bestOutgoing.end(), NBContHelper::edge_similar_direction_sorter(bestFirst)); 00502 if (bestOutgoing.size()!=0) { 00503 extractAndMarkFirst(bestOutgoing); 00504 } 00505 bestSecond->setJunctionPriority(this, 1); 00506 sort(bestOutgoing.begin(), bestOutgoing.end(), NBContHelper::edge_similar_direction_sorter(bestSecond)); 00507 if (bestOutgoing.size()!=0) { 00508 extractAndMarkFirst(bestOutgoing); 00509 } 00510 }
| void NBNode::sortNodesEdges | ( | bool | leftHand, | |
| const NBTypeCont & | tc | |||
| ) |
initialises the list of all edges and sorts all edges
Definition at line 1146 of file NBNode.cpp.
References computeType(), OutputDevice::getDeviceByOption(), OptionsCont::getOptions(), getPosition(), myAllEdges, myID, myIncomingEdges, myOutgoingEdges, myType, NODETYPE_DISTRICT, NODETYPE_NOJUNCTION, NODETYPE_PRIORITY_JUNCTION, NODETYPE_RIGHT_BEFORE_LEFT, NODETYPE_TRAFFIC_LIGHT, NODETYPE_UNKNOWN, setPriorities(), swapWhenReversed(), Position2D::x(), and Position2D::y().
01146 { 01147 // sort the edges 01148 sort(myAllEdges.begin(), myAllEdges.end(), NBContHelper::edge_by_junction_angle_sorter(this)); 01149 sort(myIncomingEdges->begin(), myIncomingEdges->end(), NBContHelper::edge_by_junction_angle_sorter(this)); 01150 sort(myOutgoingEdges->begin(), myOutgoingEdges->end(), NBContHelper::edge_by_junction_angle_sorter(this)); 01151 if (myAllEdges.size()==0) { 01152 return; 01153 } 01154 std::vector<NBEdge*>::iterator i; 01155 for (i=myAllEdges.begin(); i!=myAllEdges.end()-1&&i!=myAllEdges.end(); i++) { 01156 swapWhenReversed(leftHand ,i, i+1); 01157 } 01158 if (myAllEdges.size()>1 && i!=myAllEdges.end()) { 01159 swapWhenReversed(leftHand, myAllEdges.end()-1, myAllEdges.begin()); 01160 } 01161 if (myType==NODETYPE_UNKNOWN) { 01162 myType = computeType(tc); 01163 } 01164 setPriorities(); 01165 // write if wished 01166 if (OptionsCont::getOptions().isSet("node-type-output")) { 01167 std::string col; 01168 switch (myType) { 01169 case NODETYPE_NOJUNCTION: 01170 col = ".5,.5,.5"; 01171 break; 01172 case NODETYPE_PRIORITY_JUNCTION: 01173 col = "0,1,0"; 01174 break; 01175 case NODETYPE_RIGHT_BEFORE_LEFT: 01176 col = "0,0,1"; 01177 break; 01178 case NODETYPE_DISTRICT: 01179 col = "1,0,0"; 01180 break; 01181 case NODETYPE_TRAFFIC_LIGHT: 01182 col = "1,1,0"; 01183 break; 01184 } 01185 OutputDevice::getDeviceByOption("node-type-output") << " <poi id=\"type_" << myID 01186 << "\" type=\"node_type\" color=\"" << col << "\"" 01187 << " x=\"" << getPosition().x() << "\" y=\"" << getPosition().y() << "\"/>\n"; 01188 } 01189 }
| void NBNode::sortSmall | ( | ) | [private] |
sorts edges with same direction (other direction lanes) in a way that the outgoing lanes are "earlier" in the list
| char NBNode::stateCode | ( | NBEdge * | incoming, | |
| NBEdge * | outgoing, | |||
| int | fromLane, | |||
| bool | mayDefinitelyPass | |||
| ) | const throw () |
Definition at line 1850 of file NBNode.cpp.
References mustBrake(), myType, and NODETYPE_RIGHT_BEFORE_LEFT.
Referenced by NBEdge::writeSingleSucceeding().
01850 { 01851 if (outgoing==0) { 01852 return 'O'; // always off 01853 } 01854 if (myType==NODETYPE_RIGHT_BEFORE_LEFT) { 01855 return '='; // all the same 01856 } 01857 if ((!incoming->isInnerEdge()&&mustBrake(incoming, outgoing, fromlane)) && !mayDefinitelyPass) { 01858 return 'm'; // minor road 01859 } 01860 // traffic lights are not regardedm here 01861 return 'M'; 01862 }
| bool NBNode::swapWhenReversed | ( | bool | leftHand, | |
| const std::vector< NBEdge * >::iterator & | i1, | |||
| const std::vector< NBEdge * >::iterator & | i2 | |||
| ) | [private] |
used while fine sorting the incoming and outgoing edges, this method performs the swapping of two edges in the myAllEdges-list when the outgoing is in clockwise direction to the incoming
Definition at line 291 of file NBNode.cpp.
References NBEdge::getToNode(), and NBEdge::isTurningDirectionAt().
Referenced by sortNodesEdges().
00293 { 00294 NBEdge *e1 = *i1; 00295 NBEdge *e2 = *i2; 00296 if (leftHand) { 00297 if (e1->getToNode()==this && e1->isTurningDirectionAt(this, e2)) { 00298 std::swap(*i1, *i2); 00299 return true; 00300 } 00301 } else { 00302 if (e2->getToNode()==this && e2->isTurningDirectionAt(this, e1)) { 00303 std::swap(*i1, *i2); 00304 return true; 00305 } 00306 } 00307 return false; 00308 }
| void NBNode::writeinternal | ( | EdgeVector * | myIncomingEdges, | |
| OutputDevice & | into, | |||
| const std::string & | id | |||
| ) | [private] |
Definition at line 1025 of file NBNode.cpp.
References countInternalLanes(), and getCrossingPosition().
Referenced by writeXML().
01025 { 01026 unsigned int l = 0; 01027 unsigned int o = countInternalLanes(false); 01028 for (EdgeVector::iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01029 unsigned int noLanesEdge = (*i)->getNoLanes(); 01030 for (unsigned int j=0; j<noLanesEdge; j++) { 01031 std::vector<NBEdge::Connection> elv = (*i)->getConnectionsFromLane(j); 01032 for (std::vector<NBEdge::Connection>::iterator k=elv.begin(); k!=elv.end(); ++k) { 01033 if ((*k).toEdge==0) { 01034 continue; 01035 } 01036 if (l!=0) { 01037 into << ' '; 01038 } 01039 std::pair<SUMOReal, std::vector<unsigned int> > cross = getCrossingPosition(*i, j, (*k).toEdge, (*k).toLane); 01040 if (cross.first<=0) { 01041 into << ':' << id << '_' << l << "_0"; 01042 } else { 01043 into << ':' << id << '_' << o << "_0"; 01044 o++; 01045 } 01046 l++; 01047 } 01048 } 01049 } 01050 }
| void NBNode::writeXML | ( | OutputDevice & | into | ) |
prints the junction
Definition at line 1054 of file NBNode.cpp.
References OptionsCont::getBool(), OptionsCont::getOptions(), myID, myIncomingEdges, myOutgoingEdges, myPoly, myPosition, myType, NODETYPE_DISTRICT, NODETYPE_NOJUNCTION, NODETYPE_PRIORITY_JUNCTION, NODETYPE_RIGHT_BEFORE_LEFT, NODETYPE_TRAFFIC_LIGHT, toString(), writeinternal(), Position2D::x(), and Position2D::y().
01054 { 01055 // write the attributes 01056 into << " <junction id=\"" << myID << '\"'; 01057 if (myIncomingEdges->size()!=0&&myOutgoingEdges->size()!=0) { 01058 //into << " key=\"" << _key << '\"'; 01059 switch (myType) { 01060 case NODETYPE_NOJUNCTION: 01061 into << " type=\"" << "unregulated\""; 01062 break; 01063 case NODETYPE_PRIORITY_JUNCTION: 01064 case NODETYPE_TRAFFIC_LIGHT: 01065 into << " type=\"" << "priority\""; 01066 break; 01067 case NODETYPE_RIGHT_BEFORE_LEFT: 01068 into << " type=\"" << "right_before_left\""; 01069 break; 01070 case NODETYPE_DISTRICT: 01071 into << " type=\"" << "district\""; 01072 break; 01073 default: 01074 throw ProcessError("An unknown junction type occured (" + toString(myType) + ")"); 01075 } 01076 } else { 01077 into << " type=\"DEAD_END\""; 01078 } 01079 into << " x=\"" << myPosition.x() << "\" y=\"" << myPosition.y() << "\""; 01080 into << " incLanes=\""; 01081 // write the incoming lanes 01082 EdgeVector::iterator i; 01083 for (i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 01084 unsigned int noLanes = (*i)->getNoLanes(); 01085 std::string id = (*i)->getID(); 01086 for (unsigned int j=0; j<noLanes; j++) { 01087 into << id << '_' << j; 01088 if (i!=myIncomingEdges->end()-1 || j<noLanes-1) { 01089 into << ' '; 01090 } 01091 } 01092 } 01093 into << "\""; 01094 // write the internal lanes 01095 into << " intLanes=\""; 01096 if (!OptionsCont::getOptions().getBool("no-internal-links")) { 01097 writeinternal(myIncomingEdges, into, myID); 01098 } 01099 into << "\""; 01100 // close writing 01101 into << " shape=\"" << myPoly << "\"/>\n\n"; 01102 }
| void NBNode::writeXMLInternalLinks | ( | OutputDevice & | into | ) |
Definition at line 553 of file NBNode.cpp.
References computeInternalLaneShape(), countInternalLanes(), getCrossingPosition(), Position2DVector::length(), MAX2(), MIN2(), myID, myIncomingEdges, PI, Position2DVector::push_back(), Position2DVector::size(), Position2DVector::splitAt(), SUMOReal, and toString().
00553 { 00554 unsigned int noInternalNoSplits = countInternalLanes(false); 00555 if (noInternalNoSplits==0) { 00556 return; 00557 } 00558 std::string id = ":" + myID; 00559 unsigned int lno = 0; 00560 unsigned int splitNo = 0; 00561 EdgeVector::iterator i; 00562 for (i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 00563 unsigned int noLanesEdge = (*i)->getNoLanes(); 00564 for (unsigned int j=0; j<noLanesEdge; j++) { 00565 std::vector<NBEdge::Connection> elv = (*i)->getConnectionsFromLane(j); 00566 for (std::vector<NBEdge::Connection>::iterator k=elv.begin(); k!=elv.end(); ++k) { 00567 if ((*k).toEdge==0) { 00568 continue; 00569 } 00570 // compute the maximum speed allowed 00571 // see !!! for an explanation (with a_lat_mean ~0.3) 00572 SUMOReal vmax = (SUMOReal) 0.3 * (SUMOReal) 9.80778 * 00573 (*i)->getLaneShape(j).getEnd().distanceTo( 00574 (*k).toEdge->getLaneShape((*k).toLane).getBegin()) 00575 / (SUMOReal) 2.0 / (SUMOReal) PI; 00576 vmax = MIN2(vmax, (((*i)->getSpeed()+(*k).toEdge->getSpeed())/(SUMOReal) 2.0)); 00577 vmax = ((*i)->getSpeed()+(*k).toEdge->getSpeed())/(SUMOReal) 2.0; 00578 // 00579 std::string id = ":" + myID + "_" + toString(lno); 00580 Position2D end = (*k).toEdge->getLaneShape((*k).toLane).getBegin(); 00581 Position2D beg = (*i)->getLaneShape(j).getEnd(); 00582 00583 Position2DVector shape = computeInternalLaneShape(*i, j, (*k).toEdge, (*k).toLane); 00584 if (shape.size()==1) { 00585 shape.push_back(shape[0]); 00586 } 00587 SUMOReal length = MAX2(shape.length(), (SUMOReal) .1); 00588 00589 // get internal splits if any 00590 std::pair<SUMOReal, std::vector<unsigned int> > cross = getCrossingPosition(*i, j, (*k).toEdge, (*k).toLane); 00591 if (cross.first>=0) { 00592 std::pair<Position2DVector, Position2DVector> split; 00593 // as usual, a problem... 00594 // if the one edge starts exactly where the other one ends (think of a 00595 // turnaround edges lying over the other one) we have a shape with length=0 00596 if (shape.length()!=0) { 00597 split = shape.splitAt(cross.first); 00598 } else { 00599 split = std::pair<Position2DVector, Position2DVector>(shape, shape); 00600 } 00601 if (split.first.size()==1) { 00602 split.first.push_back(split.first[0]); 00603 } 00604 if (split.second.size()==1) { 00605 split.second.push_back(split.second[0]); 00606 } 00607 00608 into << " <edge id=\"" << id << "\" function=\"internal\">\n"; 00609 into << " <lanes>\n"; 00610 into << " <lane id=\"" << id << "_0\" depart=\"0\" " 00611 << "maxspeed=\"" << vmax << "\" length=\"" 00612 << toString<SUMOReal>(cross.first) << "\"" 00613 << " shape=\"" << split.first << "\"/>\n" 00614 << " </lanes>\n" 00615 << " </edge>\n\n"; 00616 lno++; 00617 00618 std::string id = ":" + myID + "_" + toString(splitNo+noInternalNoSplits); 00619 into << " <edge id=\"" << id 00620 << "\" function=\"internal\">\n"; 00621 into << " <lanes>\n"; 00622 into << " <lane id=\"" << id << "_0\" depart=\"0\" " 00623 << "maxspeed=\"" << vmax << "\" length=\"" 00624 << toString<SUMOReal>(length-cross.first) << "\"" 00625 << " shape=\"" << split.second << "\"/>\n" 00626 << " </lanes>\n" 00627 << " </edge>\n\n"; 00628 splitNo++; 00629 } else { 00630 into << " <edge id=\"" << id 00631 << "\" function=\"internal\">\n"; 00632 into << " <lanes>\n"; 00633 into << " <lane id=\"" << id << "_0\" depart=\"0\" " 00634 << "maxspeed=\"" << vmax << "\" length=\"" 00635 << toString<SUMOReal>(length) << "\"" 00636 << " shape=\"" << shape << "\"/>\n" 00637 << " </lanes>\n" 00638 << " </edge>\n\n"; 00639 lno++; 00640 } 00641 } 00642 } 00643 } 00644 }
| void NBNode::writeXMLInternalNodes | ( | OutputDevice & | into | ) |
Definition at line 978 of file NBNode.cpp.
References computeInternalLaneShape(), countInternalLanes(), getCrossingNames_dividedBySpace(), getCrossingPosition(), getCrossingSourcesNames_dividedBySpace(), myID, myIncomingEdges, Position2DVector::positionAtLengthPosition(), toString(), Position2D::x(), and Position2D::y().
00978 { 00979 unsigned int noInternalNoSplits = countInternalLanes(false); 00980 if (noInternalNoSplits==0) { 00981 return; 00982 } 00983 unsigned int lno = 0; 00984 unsigned int splitNo = 0; 00985 for (EdgeVector::iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 00986 unsigned int noLanesEdge = (*i)->getNoLanes(); 00987 for (unsigned int j=0; j<noLanesEdge; j++) { 00988 std::vector<NBEdge::Connection> elv = (*i)->getConnectionsFromLane(j); 00989 for (std::vector<NBEdge::Connection>::iterator k=elv.begin(); k!=elv.end(); ++k) { 00990 if ((*k).toEdge==0) { 00991 continue; 00992 } 00993 std::pair<SUMOReal, std::vector<unsigned int> > cross = getCrossingPosition(*i, j, (*k).toEdge, (*k).toLane); 00994 if (cross.first<=0) { 00995 lno++; 00996 continue; 00997 } 00998 // write the attributes 00999 std::string sid = ":" + myID + "_" + toString(splitNo+noInternalNoSplits) + "_0"; 01000 std::string iid = ":" + myID + "_" + toString(lno) + "_0"; 01001 Position2DVector shape = computeInternalLaneShape(*i, j, (*k).toEdge, (*k).toLane); 01002 Position2D pos = shape.positionAtLengthPosition(cross.first); 01003 into << " <junction id=\"" << sid << '\"'; 01004 into << " type=\"" << "internal\""; 01005 into << " x=\"" << pos.x() << "\" y=\"" << pos.y() << "\""; 01006 into << " incLanes=\""; 01007 std::string furtherIncoming = getCrossingSourcesNames_dividedBySpace(*i, j, (*k).toEdge, (*k).toLane); 01008 if (furtherIncoming.length()!=0) { 01009 into << iid << " " << furtherIncoming; 01010 } else { 01011 into << iid; 01012 } 01013 into << "\""; 01014 into << " intLanes=\"" << getCrossingNames_dividedBySpace(*i, j, (*k).toEdge, (*k).toLane) << "\""; 01015 into << " shape=\"\"/>\n\n"; 01016 splitNo++; 01017 lno++; 01018 } 01019 } 01020 } 01021 }
| void NBNode::writeXMLInternalSuccInfos | ( | OutputDevice & | into | ) |
Definition at line 919 of file NBNode.cpp.
References countInternalLanes(), getCrossingPosition(), myID, myIncomingEdges, and toString().
00919 { 00920 unsigned int noInternalNoSplits = countInternalLanes(false); 00921 if (noInternalNoSplits==0) { 00922 return; 00923 } 00924 unsigned int lno = 0; 00925 unsigned int splitNo = 0; 00926 for (EdgeVector::iterator i=myIncomingEdges->begin(); i!=myIncomingEdges->end(); i++) { 00927 unsigned int noLanesEdge = (*i)->getNoLanes(); 00928 for (unsigned int j=0; j<noLanesEdge; j++) { 00929 std::vector<NBEdge::Connection> elv = (*i)->getConnectionsFromLane(j); 00930 for (std::vector<NBEdge::Connection>::iterator k=elv.begin(); k!=elv.end(); ++k) { 00931 if ((*k).toEdge==0) { 00932 continue; 00933 } 00934 std::string id = ":" + myID + "_" + toString(lno); 00935 std::string sid = ":" + myID + "_" + toString(splitNo+noInternalNoSplits); 00936 std::pair<SUMOReal, std::vector<unsigned int> > cross = getCrossingPosition(*i, j, (*k).toEdge, (*k).toLane); 00937 00938 // get internal splits if any 00939 into << " <succ edge=\"" << id << "\" " 00940 << "lane=\"" << id << "_" 00941 << 0 << "\" junction=\"" << myID << "\">\n"; 00942 if (cross.first>=0) { 00943 into << " <succlane lane=\"" 00944 //<< sid << "_" << 0 () 00945 << (*k).toEdge->getID() << "_" << (*k).toLane << "\"" 00946 << " via=\"" << sid << "_" << 0 << "\"" 00947 << " tl=\"" << "" << "\" linkno=\"" 00948 << "" << "\" yield=\"1\" dir=\"s\" state=\"M\""; // !!! yield or not depends on whether it is tls controlled or not 00949 } else { 00950 into << " <succlane lane=\"" 00951 << (*k).toEdge->getID() << "_" << (*k).toLane 00952 << "\" tl=\"" << "" << "\" linkno=\"" 00953 << "" << "\" yield=\"0\" dir=\"s\" state=\"M\""; 00954 } 00955 into << "/>\n"; 00956 into << " </succ>\n"; 00957 00958 if (cross.first>=0) { 00959 into << " <succ edge=\"" << sid << "\" " 00960 << "lane=\"" << sid << "_" << 0 00961 << "\" junction=\"" << sid << "\">\n"; 00962 into << " <succlane lane=\"" 00963 << (*k).toEdge->getID() << "_" << (*k).toLane 00964 << "\" tl=\"" << "" << "\" linkno=\"" 00965 << "0" << "\" yield=\"0\" dir=\"s\" state=\"M\""; 00966 into << "/>\n"; 00967 into << " </succ>\n"; 00968 splitNo++; 00969 } 00970 lno++; 00971 } 00972 } 00973 } 00974 }
friend class NBNodeCont [friend] |
friend class NBNodeShapeComputer [friend] |
std::vector<NBEdge*> NBNode::myAllEdges [private] |
Vector of incoming and outgoing edges.
Definition at line 511 of file NBNode.h.
Referenced by addIncomingEdge(), addOutgoingEdge(), NBNodeShapeComputer::compute(), NBNodeShapeComputer::computeContinuationNodeShape(), computeLogic(), NBNodeShapeComputer::computeNodeShapeByCrosses(), NBNodeShapeComputer::computeUniqueDirectionList(), getEdges(), getEdgesThatApproach(), getMaxEdgeWidth(), getMMLDirection(), NBNodeShapeComputer::joinSameDirectionEdges(), removeDoubleEdges(), removeIncoming(), removeOutgoing(), replaceIncoming(), replaceOutgoing(), setPriorities(), and sortNodesEdges().
The container for connection block dependencies
Definition at line 517 of file NBNode.h.
Referenced by addSortedLinkFoes(), computeLogic(), remapRemoved(), and replaceInConnectionProhibitions().
NBDistrict* NBNode::myDistrict [private] |
The district the node is the centre of.
Definition at line 520 of file NBNode.h.
Referenced by replaceIncoming(), and replaceOutgoing().
std::string NBNode::myID [private] |
The id of the node.
Definition at line 499 of file NBNode.h.
Referenced by computeLogic(), getCrossingNames_dividedBySpace(), getID(), getInternalLaneID(), sortNodesEdges(), writeXML(), writeXMLInternalLinks(), writeXMLInternalNodes(), and writeXMLInternalSuccInfos().
std::vector<NBEdge*>* NBNode::myIncomingEdges [private] |
Vector of incoming edges.
Definition at line 505 of file NBNode.h.
Referenced by addIncomingEdge(), checkIsRemovable(), computeLanes2Lanes(), computeLogic(), computeNodeShape(), computeType(), countInternalLanes(), eraseDummies(), getCrossingNames_dividedBySpace(), getCrossingPosition(), getCrossingSourcesNames_dividedBySpace(), getEdgesToJoin(), getEmptyDir(), getIncomingEdges(), getInternalLaneID(), getOppositeIncoming(), getPossiblySplittedIncoming(), hasIncoming(), invalidateIncomingConnections(), isLeftMover(), isSimpleContinuation(), mustBrake(), NBNode(), removeDoubleEdges(), removeIncoming(), replaceIncoming(), replaceOutgoing(), setPriorities(), setPriorityJunctionPriorities(), sortNodesEdges(), writeXML(), writeXMLInternalLinks(), writeXMLInternalNodes(), writeXMLInternalSuccInfos(), and ~NBNode().
std::vector<NBEdge*>* NBNode::myOutgoingEdges [private] |
Vector of outgoing edges.
Definition at line 508 of file NBNode.h.
Referenced by addOutgoingEdge(), checkIsRemovable(), computeLanes2Lanes(), computeLogic(), computeNodeShape(), eraseDummies(), getConnectionTo(), getEdgesToJoin(), getEmptyDir(), getOutgoingEdges(), getPossiblySplittedOutgoing(), hasOutgoing(), invalidateOutgoingConnections(), isSimpleContinuation(), NBNode(), removeDoubleEdges(), removeOutgoing(), replaceOutgoing(), setPriorities(), setPriorityJunctionPriorities(), sortNodesEdges(), writeXML(), and ~NBNode().
Position2DVector NBNode::myPoly [private] |
the (outer) shape of the junction
Definition at line 523 of file NBNode.h.
Referenced by computeNodeShape(), getShape(), reshiftPosition(), and writeXML().
Position2D NBNode::myPosition [private] |
The position the node lies at.
Definition at line 502 of file NBNode.h.
Referenced by getEmptyDir(), getPosition(), reinit(), reshiftPosition(), and writeXML().
NBRequest* NBNode::myRequest [private] |
Definition at line 525 of file NBNode.h.
Referenced by computeLogic(), foes(), forbids(), mustBrake(), and ~NBNode().
std::set<NBTrafficLightDefinition*> NBNode::myTrafficLights [private] |
Definition at line 527 of file NBNode.h.
Referenced by addTrafficLight(), checkIsRemovable(), getControllingTLS(), isJoinedTLSControlled(), isTLControlled(), mustBrake(), and removeTrafficLights().
BasicNodeType NBNode::myType [private] |
The type of the junction.
Definition at line 514 of file NBNode.h.
Referenced by computeLogic(), computeType(), getType(), isDistrict(), reinit(), setPriorities(), sortNodesEdges(), stateCode(), and writeXML().
1.5.6