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) {
67 for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
68 (*k)->setTurningDestination(0);
70 std::vector<Combination> combinations;
71 for (std::vector<NBEdge*>::const_iterator j = outgoing.begin(); j != outgoing.end(); ++j) {
73 for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
77 if (signedAngle > 0 && signedAngle < 177 && e->getGeometry().back().distanceTo2D(outedge->
getGeometry().front()) <
POSITION_EPS) {
104 combinations.push_back(c);
109 std::set<NBEdge*> seen;
110 for (std::vector<Combination>::const_iterator j = combinations.begin(); j != combinations.end(); ++j) {
111 if (seen.find((*j).from) != seen.end() || seen.find((*j).to) != seen.end()) {
113 if ((*j).angle > 360 && warn) {
114 WRITE_WARNING(
"Ambiguity in turnarounds computation at junction '" + node->
getID() +
"'.");
120 seen.insert((*j).from);
121 seen.insert((*j).to);
123 bool onlyPossible = (*j).from->getConnections().size() != 0 && !(*j).from->isConnectedTo((*j).to);
125 (*j).from->setTurningDestination((*j).to, onlyPossible);
135 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
136 NBNode*
const n = i->second;
143 std::vector<NBNode::Crossing>& crossings = n->
myCrossings;
151 std::vector<NBEdge*>::iterator j;
152 for (j = allEdges.begin(); j != allEdges.end() - 1 && j != allEdges.end(); ++j) {
153 swapWhenReversed(n, j, j + 1);
155 if (allEdges.size() > 1 && j != allEdges.end()) {
156 swapWhenReversed(n, allEdges.end() - 1, allEdges.begin());
159 NBEdge* firstOfAll = allEdges.front();
160 NBEdge* firstOfIncoming = incoming.size() > 0 ? incoming.front() : 0;
161 NBEdge* firstOfOutgoing = outgoing.size() > 0 ? outgoing.front() : 0;
167 rotate(allEdges.begin(), std::find(allEdges.begin(), allEdges.end(), firstOfAll), allEdges.end());
168 if (firstOfIncoming != 0) {
169 rotate(incoming.begin(), std::find(incoming.begin(), incoming.end(), firstOfIncoming), incoming.end());
171 if (firstOfOutgoing != 0) {
172 rotate(outgoing.begin(), std::find(outgoing.begin(), outgoing.end(), firstOfOutgoing), outgoing.end());
177 if (incoming.size() == outgoing.size() && incoming.front() == allEdges.front()) {
178 std::vector<NBEdge*>::const_iterator in, out;
179 std::vector<NBEdge*> allTmp;
180 for (in = incoming.begin(), out = outgoing.begin(); in != incoming.end(); ++in, ++out) {
181 if ((*in)->isTurningDirectionAt(*out)) {
182 allTmp.push_back(*in);
183 allTmp.push_back(*out);
188 if (allTmp.size() == allEdges.size()) {
209 const std::vector<NBEdge*>::iterator& i1,
210 const std::vector<NBEdge*>::iterator& i2) {
228 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
235 bool waterway =
true;
236 for (EdgeVector::const_iterator i = n->
getEdges().begin(); i != n->
getEdges().end(); ++i) {
260 for (EdgeVector::const_iterator j = i + 1; j != n->
myIncomingEdges.end(); j++) {
269 const int p1 = (*i)->getPriority();
270 const int p2 = (*j)->getPriority();
288 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
300 setPriorityJunctionPriorities(*n);
318 NBEdge* best = incoming[0];
319 while (incoming.size() > 0 && samePriority(best, incoming[0])) {
320 bestIncoming.push_back(*incoming.begin());
321 incoming.erase(incoming.begin());
324 assert(outgoing.size() != 0);
328 while (outgoing.size() > 0 && samePriority(best, outgoing[0])) {
329 bestOutgoing.push_back(*outgoing.begin());
330 outgoing.erase(outgoing.begin());
333 const bool mainDirectionExplicit = (
335 && (incoming.size() == 0 || bestIncoming[0]->getPriority() > incoming[0]->getPriority())
337 && (outgoing.size() == 0 || bestOutgoing[0]->getPriority() > outgoing[0]->getPriority())
338 && !bestIncoming[0]->isTurningDirectionAt(bestOutgoing[0]));
342 EdgeVector::iterator i;
343 std::map<NBEdge*, NBEdge*> counterIncomingEdges;
344 std::map<NBEdge*, NBEdge*> counterOutgoingEdges;
347 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
349 counterIncomingEdges[*i] = *incoming.begin();
351 counterOutgoingEdges[*i] = *outgoing.begin();
355 if (bestIncoming.size() == 1) {
357 NBEdge* best1 = extractAndMarkFirst(n, bestIncoming);
358 if (!mainDirectionExplicit && counterIncomingEdges.find(best1) != counterIncomingEdges.end()) {
362 NBEdge* s = counterIncomingEdges.find(best1)->second;
367 assert(bestOutgoing.size() != 0);
371 best1 = extractAndMarkFirst(n, bestOutgoing);
372 if (!mainDirectionExplicit && counterOutgoingEdges.find(best1) != counterOutgoingEdges.end()) {
373 NBEdge* s = counterOutgoingEdges.find(best1)->second;
388 bool hadBest =
false;
389 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
390 EdgeVector::iterator j;
396 for (j = i + 1; j != bestIncoming.end(); ++j) {
403 if (!hadBest || angle > bestAngle) {
413 if (bestOutgoing.size() != 0) {
414 extractAndMarkFirst(n, bestOutgoing);
418 if (bestOutgoing.size() != 0) {
419 extractAndMarkFirst(n, bestOutgoing);
453 myOrdering = ordering;
456 rotate(myOrdering.begin(), std::find(myOrdering.begin(), myOrdering.end(), ordering.front()), myOrdering.end());
std::vector< Crossing > myCrossings
Vector of crossings.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
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...
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
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)
int getPriority() const
Returns the priority of the edge.
The representation of a single edge during network building.
Class to sort edges by their angle in relation to the given edge.
const std::string & getID() const
Returns the id.
static void sortNodesEdges(NBNodeCont &nc, bool useNodeShape=false)
Sorts a node's edges clockwise regarding driving direction.
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.
EdgeVector myAllEdges
Vector of incoming and outgoing edges.
static void swapWhenReversed(const NBNode *const n, const std::vector< NBEdge *>::iterator &i1, const std::vector< NBEdge *>::iterator &i2)
Assures correct order for same-angle opposite-direction edges.
int getNumLanes() const
Returns the number of lanes.
static void computeEdgePriorities(NBNodeCont &nc)
Computes edge priorities within a node.
bool isWaterway(SVCPermissions permissions)
Returns whether an edge with the given permission is a waterway edge.
const EdgeVector & getEdges() const
Returns all edges which participate in this node.
SUMOReal getAngleAtNode(const NBNode *const node) const
Returns the angle of the edge's geometry at the given node.
crossing_by_junction_angle_sorter(const NBNode *node, const EdgeVector &ordering)
EdgeVector myIncomingEdges
Vector of incoming edges.
static void computeTurnDirectionsForNode(NBNode *node, bool warn)
Computes turnaround destinations for all incoming edges of the given nodes (if any) ...
static bool samePriority(const NBEdge *const e1, const NBEdge *const e2)
Returns whether both edges have the same priority.
const PositionVector & getShape() const
retrieve the junction shape
const PositionVector & getGeometry() const
Returns the geometry of the edge.
EdgeVector myOutgoingEdges
Vector of outgoing edges.
SUMOReal area() const
Returns the area (0 for non-closed)
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
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 getSpeed() const
Returns the speed allowed on this edge.
bool isTurningDirectionAt(const NBEdge *const edge) const
Returns whether the given edge is the opposite direction to this edge.
Represents a single node (junction) during network building.
static void computeTurnDirections(NBNodeCont &nc, bool warn=true)
Computes turnaround destinations for all edges (if exist)
static NBEdge * extractAndMarkFirst(NBNode &n, std::vector< NBEdge *> &s, int prio=1)
Sets the priorites in case of a priority junction.
NBEdge * getOppositeIncoming(NBEdge *e) const
Sorts "Combination"s by decreasing angle.
static void setPriorityJunctionPriorities(NBNode &n)
Sets the priorites in case of a priority junction.
NBNode * getFromNode() const
Returns the origin node of the edge.
Container for nodes during the netbuilding process.
NBNode * getToNode() const
Returns the destination node of the edge.
bool isSimpleContinuation(bool checkLaneNumbers=true) const