53 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
63 for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
64 (*k)->setTurningDestination(0);
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) {
78 double angle = fabs(signedAngle);
100 combinations.push_back(c);
105 std::set<NBEdge*> seen;
106 for (std::vector<Combination>::const_iterator j = combinations.begin(); j != combinations.end(); ++j) {
107 if (seen.find((*j).from) != seen.end() || seen.find((*j).to) != seen.end()) {
109 if ((*j).angle > 360 && warn) {
110 WRITE_WARNING(
"Ambiguity in turnarounds computation at junction '" + node->
getID() +
"'.");
116 seen.insert((*j).from);
117 seen.insert((*j).to);
119 bool onlyPossible = (*j).from->getConnections().size() != 0 && !(*j).from->isConnectedTo((*j).to);
121 (*j).from->setTurningDestination((*j).to, onlyPossible);
131 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
132 i->second->sortEdges(useNodeShape);
139 const std::vector<NBEdge*>::iterator& i1,
140 const std::vector<NBEdge*>::iterator& i2) {
158 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
165 bool waterway =
true;
166 for (EdgeVector::const_iterator i = n->
getEdges().begin(); i != n->
getEdges().end(); ++i) {
190 for (EdgeVector::const_iterator j = i + 1; j != n->
myIncomingEdges.end(); j++) {
197 const double s1 = (*i)->getSpeed() * (double) 3.6;
198 const double s2 = (*j)->getSpeed() * (double) 3.6;
199 const int p1 = (*i)->getPriority();
200 const int p2 = (*j)->getPriority();
201 if (fabs(s1 - s2) > (
double) 9.5 ||
MAX2(s1, s2) >= (
double) 49. || p1 != p2) {
219 bool waterway =
true;
220 for (EdgeVector::const_iterator i = node->
getEdges().begin(); i != node->
getEdges().end(); ++i) {
241 for (EdgeVector::const_iterator j = i + 1; j != node->
myIncomingEdges.end(); j++) {
248 const double s1 = (*i)->getSpeed() * (double) 3.6;
249 const double s2 = (*j)->getSpeed() * (double) 3.6;
250 const int p1 = (*i)->getPriority();
251 const int p2 = (*j)->getPriority();
252 if (fabs(s1 - s2) > (
double) 9.5 ||
MAX2(s1, s2) >= (
double) 49. || p1 != p2) {
267 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
279 setPriorityJunctionPriorities(*n);
296 setPriorityJunctionPriorities(*node);
313 NBEdge* best = incoming[0];
314 while (incoming.size() > 0 && samePriority(best, incoming[0])) {
315 bestIncoming.push_back(*incoming.begin());
316 incoming.erase(incoming.begin());
319 assert(outgoing.size() != 0);
323 while (outgoing.size() > 0 && samePriority(best, outgoing[0])) {
324 bestOutgoing.push_back(*outgoing.begin());
325 outgoing.erase(outgoing.begin());
328 const bool mainDirectionExplicit = (
330 && (incoming.size() == 0 || bestIncoming[0]->getPriority() > incoming[0]->getPriority())
332 && (outgoing.size() == 0 || bestOutgoing[0]->getPriority() > outgoing[0]->getPriority())
333 && !bestIncoming[0]->isTurningDirectionAt(bestOutgoing[0]));
337 EdgeVector::iterator i;
338 std::map<NBEdge*, NBEdge*> counterIncomingEdges;
339 std::map<NBEdge*, NBEdge*> counterOutgoingEdges;
342 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
344 counterIncomingEdges[*i] = *incoming.begin();
346 counterOutgoingEdges[*i] = *outgoing.begin();
350 if (bestIncoming.size() == 1) {
352 NBEdge* best1 = extractAndMarkFirst(n, bestIncoming);
353 if (!mainDirectionExplicit && counterIncomingEdges.find(best1) != counterIncomingEdges.end()) {
357 NBEdge* s = counterIncomingEdges.find(best1)->second;
362 assert(bestOutgoing.size() != 0);
366 best1 = extractAndMarkFirst(n, bestOutgoing);
367 if (!mainDirectionExplicit && counterOutgoingEdges.find(best1) != counterOutgoingEdges.end()) {
368 NBEdge* s = counterOutgoingEdges.find(best1)->second;
380 double bestAngle = 0;
383 bool hadBest =
false;
384 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
385 EdgeVector::iterator j;
391 for (j = i + 1; j != bestIncoming.end(); ++j) {
398 if (!hadBest || angle > bestAngle) {
408 if (bestOutgoing.size() != 0) {
409 extractAndMarkFirst(n, bestOutgoing);
413 if (bestOutgoing.size() != 0) {
414 extractAndMarkFirst(n, bestOutgoing);
448 myOrdering = ordering;
451 rotate(myOrdering.begin(), std::find(myOrdering.begin(), myOrdering.end(), ordering.front()), myOrdering.end());
static double getMinAngleDiff(double angle1, double angle2)
Returns the minimum distance (clockwise/counter-clockwise) between both angles.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
static double normRelAngle(double angle1, double angle2)
ensure that reverse relAngles (>=179.999) always count as turnarounds (-180)
SumoXMLNodeType myType
The type of the junction.
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.
static void computeSingleNodeType(NBNode *node)
Computes a single node type.
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 (The edges which start at this node)
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 (Edges that start or end at this node) ...
double 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.
double getSpeed() const
Returns the speed allowed on this edge.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
EdgeVector myOutgoingEdges
Vector of outgoing edges.
static void computeEdgePrioritiesSingleNode(NBNode *node)
Computes edge priorities within a single node.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
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
container for (sorted) edges
void setJunctionPriority(const NBNode *const node, int prio)
Sets the junction priority of the edge.
SumoXMLNodeType getType() const
Returns the type of this node.
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
returns the opposite incoming edge of certain edge
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
check if node is a simple continuation