42 #ifdef CHECK_MEMORY_LEAKS
44 #endif // CHECK_MEMORY_LEAKS
55 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
64 std::vector<Combination> combinations;
65 for (std::vector<NBEdge*>::const_iterator j = outgoing.begin(); j != outgoing.end(); ++j) {
67 for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
101 combinations.push_back(c);
106 std::set<NBEdge*> seen;
107 bool haveWarned =
false;
108 for (std::vector<Combination>::const_iterator j = combinations.begin(); j != combinations.end(); ++j) {
109 if (seen.find((*j).from) != seen.end() || seen.find((*j).to) != seen.end()) {
111 if ((*j).angle > 360 && !haveWarned) {
112 WRITE_WARNING(
"Ambiguity in turnarounds computation at node '" + node->
getID() +
"'.");
118 seen.insert((*j).from);
119 seen.insert((*j).to);
121 (*j).from->setTurningDestination((*j).to);
131 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
136 std::vector<NBEdge*>& allEdges = (*i).second->
myAllEdges;
137 std::vector<NBEdge*>& incoming = (*i).second->myIncomingEdges;
138 std::vector<NBEdge*>& outgoing = (*i).second->myOutgoingEdges;
143 std::vector<NBEdge*>::iterator j;
144 for (j = allEdges.begin(); j != allEdges.end() - 1 && j != allEdges.end(); ++j) {
147 if (allEdges.size() > 1 && j != allEdges.end()) {
156 const std::vector<NBEdge*>::iterator& i1,
157 const std::vector<NBEdge*>::iterator& i2) {
179 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
198 for (EdgeVector::const_iterator j = i + 1; j != n->
myIncomingEdges.end(); j++) {
207 const int p1 = (*i)->getPriority();
208 const int p2 = (*j)->getPriority();
226 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
230 (*j)->setJunctionPriority(n, 0);
256 NBEdge* best = incoming[0];
257 while (incoming.size() > 0 &&
samePriority(best, incoming[0])) {
258 bestIncoming.push_back(*incoming.begin());
259 incoming.erase(incoming.begin());
262 assert(outgoing.size() != 0);
266 while (outgoing.size() > 0 &&
samePriority(best, outgoing[0])) {
267 bestOutgoing.push_back(*outgoing.begin());
268 outgoing.erase(outgoing.begin());
273 EdgeVector::iterator i;
274 std::map<NBEdge*, NBEdge*> counterIncomingEdges;
275 std::map<NBEdge*, NBEdge*> counterOutgoingEdges;
278 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
280 counterIncomingEdges[*i] = *incoming.begin();
282 counterOutgoingEdges[*i] = *outgoing.begin();
286 if (bestIncoming.size() == 1) {
289 if (counterIncomingEdges.find(best1) != counterIncomingEdges.end()) {
293 NBEdge* s = counterIncomingEdges.find(best1)->second;
298 if (bestOutgoing.size() != 0) {
302 if (counterOutgoingEdges.find(best1) != counterOutgoingEdges.end()) {
303 NBEdge* s = counterOutgoingEdges.find(best1)->second;
319 bool hadBest =
false;
320 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
321 EdgeVector::iterator j;
327 for (j = i + 1; j != bestIncoming.end(); ++j) {
334 if (!hadBest || angle > bestAngle) {
344 if (bestOutgoing.size() != 0) {
349 if (bestOutgoing.size() != 0) {
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
Sorts incoming and outgoing edges clockwise around the given node.
NBEdge * getOppositeIncoming(NBEdge *e) const
SumoXMLNodeType myType
The type of the junction.
The representation of a single edge during network building.
Class to sort edges by their angle in relation to the given edge.
static void swapWhenReversed(const NBNode *const n, bool leftHand, const std::vector< NBEdge * >::iterator &i1, const std::vector< NBEdge * >::iterator &i2)
Assures correct order for same-angle opposite-direction edges.
static void computeTurnDirectionsForNode(NBNode *node)
Computes turnaround destinations for all incoming edges of the given nodes (if any) ...
bool isTurningDirectionAt(const NBNode *n, const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
Stores the information about the angle between an incoming ("from") and an outgoing ("to") edge...
#define WRITE_WARNING(msg)
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
const std::string & getID() const
Returns the id.
EdgeVector myAllEdges
Vector of incoming and outgoing edges.
bool isConnectedTo(NBEdge *e)
Returns the information whethe a connection to the given edge has been added (or computed) ...
int getPriority() const
Returns the priority of the edge.
bool isSimpleContinuation() const
static void computeEdgePriorities(NBNodeCont &nc)
Computes edge priorities within a node.
unsigned int getNumLanes() const
Returns the number of lanes.
static void computeTurnDirections(NBNodeCont &nc)
Computes turnaround destinations for all edges (if exist)
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
EdgeVector myIncomingEdges
Vector of incoming edges.
static bool samePriority(const NBEdge *const e1, const NBEdge *const e2)
Returns whether both edges have the same priority.
EdgeVector myOutgoingEdges
Vector of outgoing edges.
NBNode * getToNode() const
Returns the destination node of the edge.
static void computeNodeTypes(NBNodeCont &nc)
Computes node types.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
std::vector< NBEdge * > EdgeVector
static SUMOReal getMinAngleDiff(SUMOReal angle1, SUMOReal angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
void setJunctionPriority(const NBNode *const node, int prio)
Sets the junction priority of the edge.
SUMOReal getTotalAngle() const
get the angle as measure from the start to the end of this edge
Represents a single node (junction) during network building.
static NBEdge * extractAndMarkFirst(NBNode &n, std::vector< NBEdge * > &s)
Sets the priorites in case of a priority junction.
Sorts "Combination"s by decreasing angle.
static SUMOReal relAngle(SUMOReal angle1, SUMOReal angle2)
static void setPriorityJunctionPriorities(NBNode &n)
Sets the priorites in case of a priority junction.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Container for nodes during the netbuilding process.
static void sortNodesEdges(NBNodeCont &nc, bool leftHand)
Sorts a node's edges clockwise regarding driving direction.
const std::vector< Connection > & getConnections() const
Returns the connections.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
SUMOReal getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
NBNode * getFromNode() const
Returns the origin node of the edge.