44 #ifdef CHECK_MEMORY_LEAKS
46 #endif // CHECK_MEMORY_LEAKS
57 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
66 std::vector<Combination> combinations;
67 for (std::vector<NBEdge*>::const_iterator j = outgoing.begin(); j != outgoing.end(); ++j) {
69 for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
73 if (signedAngle > 0 && signedAngle < 177 && e->getGeometry().back().distanceTo2D(outedge->
getGeometry().front()) <
POSITION_EPS) {
100 combinations.push_back(c);
105 std::set<NBEdge*> seen;
106 bool haveWarned =
false;
107 for (std::vector<Combination>::const_iterator j = combinations.begin(); j != combinations.end(); ++j) {
108 if (seen.find((*j).from) != seen.end() || seen.find((*j).to) != seen.end()) {
110 if ((*j).angle > 360 && !haveWarned) {
111 WRITE_WARNING(
"Ambiguity in turnarounds computation at node '" + node->
getID() +
"'.");
117 seen.insert((*j).from);
118 seen.insert((*j).to);
120 bool onlyPossible = (*j).from->getConnections().size() != 0 && !(*j).from->isConnectedTo((*j).to);
122 (*j).from->setTurningDestination((*j).to, onlyPossible);
132 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
138 EdgeVector& incoming = (*i).second->myIncomingEdges;
139 EdgeVector& outgoing = (*i).second->myOutgoingEdges;
140 std::vector<NBNode::Crossing>& crossings = (*i).second->myCrossings;
149 std::vector<NBEdge*>::iterator j;
150 for (j = allEdges.begin(); j != allEdges.end() - 1 && j != allEdges.end(); ++j) {
153 if (allEdges.size() > 1 && j != allEdges.end()) {
157 NBEdge* firstOfAll = allEdges.front();
158 NBEdge* firstOfIncoming = incoming.size() > 0 ? incoming.front() : 0;
159 NBEdge* firstOfOutgoing = outgoing.size() > 0 ? outgoing.front() : 0;
165 rotate(allEdges.begin(), std::find(allEdges.begin(), allEdges.end(), firstOfAll), allEdges.end());
166 if (firstOfIncoming != 0) {
167 rotate(incoming.begin(), std::find(incoming.begin(), incoming.end(), firstOfIncoming), incoming.end());
169 if (firstOfOutgoing != 0) {
170 rotate(outgoing.begin(), std::find(outgoing.begin(), outgoing.end(), firstOfOutgoing), outgoing.end());
191 const std::vector<NBEdge*>::iterator& i1,
192 const std::vector<NBEdge*>::iterator& i2) {
214 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
233 for (EdgeVector::const_iterator j = i + 1; j != n->
myIncomingEdges.end(); j++) {
242 const int p1 = (*i)->getPriority();
243 const int p2 = (*j)->getPriority();
261 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
265 (*j)->setJunctionPriority(n, 0);
291 NBEdge* best = incoming[0];
292 while (incoming.size() > 0 &&
samePriority(best, incoming[0])) {
293 bestIncoming.push_back(*incoming.begin());
294 incoming.erase(incoming.begin());
297 assert(outgoing.size() != 0);
301 while (outgoing.size() > 0 &&
samePriority(best, outgoing[0])) {
302 bestOutgoing.push_back(*outgoing.begin());
303 outgoing.erase(outgoing.begin());
306 const bool mainDirectionExplicit = (
308 && (incoming.size() == 0 || bestIncoming[0]->getPriority() > incoming[0]->getPriority())
310 && (outgoing.size() == 0 || bestOutgoing[0]->getPriority() > outgoing[0]->getPriority())
311 && !bestIncoming[0]->isTurningDirectionAt(bestOutgoing[0]));
315 EdgeVector::iterator i;
316 std::map<NBEdge*, NBEdge*> counterIncomingEdges;
317 std::map<NBEdge*, NBEdge*> counterOutgoingEdges;
320 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
322 counterIncomingEdges[*i] = *incoming.begin();
324 counterOutgoingEdges[*i] = *outgoing.begin();
328 if (bestIncoming.size() == 1) {
331 if (!mainDirectionExplicit && counterIncomingEdges.find(best1) != counterIncomingEdges.end()) {
335 NBEdge* s = counterIncomingEdges.find(best1)->second;
340 assert(bestOutgoing.size() != 0);
345 if (!mainDirectionExplicit && counterOutgoingEdges.find(best1) != counterOutgoingEdges.end()) {
346 NBEdge* s = counterOutgoingEdges.find(best1)->second;
361 bool hadBest =
false;
362 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
363 EdgeVector::iterator j;
369 for (j = i + 1; j != bestIncoming.end(); ++j) {
376 if (!hadBest || angle > bestAngle) {
386 if (bestOutgoing.size() != 0) {
391 if (bestOutgoing.size() != 0) {
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
Sorts incoming and outgoing edges clockwise around the given node.
Sorts crossings by minimum clockwise clockwise edge angle. Use the ordering found in myAllEdges of th...
NBEdge * getOppositeIncoming(NBEdge *e) const
SumoXMLNodeType myType
The type of the junction.
static SUMOReal normRelAngle(SUMOReal angle1, SUMOReal angle2)
ensure that reverse relAngles (>=179.999) always count as turnarounds (-180)
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) ...
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.
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 NBEdge * extractAndMarkFirst(NBNode &n, std::vector< NBEdge * > &s, int prio=1)
Sets the priorites in case of a priority junction.
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
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.
crossing_by_junction_angle_sorter(const NBNode *node, const EdgeVector &ordering)
const PositionVector & getShape() const
retrieve the junction shape
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
const PositionVector & getGeometry() const
Returns the geometry of the edge.
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.
Represents a single node (junction) during network building.
Sorts "Combination"s by decreasing angle.
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.
SUMOReal area() const
Returns the area (0 for non-closed)
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.
static void sortNodesEdges(NBNodeCont &nc, bool leftHand, bool useNodeShape=false)
Sorts a node's edges clockwise regarding driving direction.