49 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
59 for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
60 (*k)->setTurningDestination(
nullptr);
62 std::vector<Combination> combinations;
64 for (std::vector<NBEdge*>::const_iterator j = outgoing.begin(); j != outgoing.end(); ++j) {
66 for (std::vector<NBEdge*>::const_iterator k = incoming.begin(); k != incoming.end(); ++k) {
70 if (signedAngle > 0 && signedAngle < 177 && e->getGeometry().back().distanceTo2D(outedge->
getGeometry().front()) <
POSITION_EPS) {
75 double angle = fabs(signedAngle);
104 combinations.push_back(c);
109 std::set<NBEdge*> seen;
111 for (std::vector<Combination>::const_iterator j = combinations.begin(); j != combinations.end(); ++j) {
113 if (seen.find((*j).from) != seen.end() || seen.find((*j).to) != seen.end()) {
115 if ((*j).angle > 360 && warn) {
116 WRITE_WARNING(
"Ambiguity in turnarounds computation at junction '" + node->
getID() +
"'.");
123 seen.insert((*j).from);
124 seen.insert((*j).to);
126 bool onlyPossible = (*j).from->getConnections().size() != 0 && !(*j).from->isConnectedTo((*j).to);
128 (*j).from->setTurningDestination((*j).to, onlyPossible);
138 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
139 i->second->sortEdges(useNodeShape);
146 const std::vector<NBEdge*>::iterator& i1,
147 const std::vector<NBEdge*>::iterator& i2) {
167 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
175 bool waterway =
true;
176 for (EdgeVector::const_iterator i = n->
getEdges().begin(); i != n->
getEdges().end(); ++i) {
200 for (EdgeVector::const_iterator j = i + 1; j != n->
myIncomingEdges.end(); j++) {
207 const double s1 = (*i)->getSpeed();
208 const double s2 = (*j)->getSpeed();
209 const int p1 = (*i)->getPriority();
210 const int p2 = (*j)->getPriority();
211 if (fabs(s1 - s2) > (9.5 / 3.6) ||
MAX2(s1, s2) >= rightBeforeLeftSpeed || p1 != p2) {
226 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
231 int numNonRailway = 0;
232 int numNonRailwayNonPed = 0;
237 numNonRailwayNonPed++;
248 if (numNonRailway == 0 || numRailway == 0) {
251 }
else if (numNonRailwayNonPed > 2) {
253 WRITE_WARNING(
"Converting invalid rail_crossing to traffic_light at junction '" + n->
getID() +
"'");
273 int numNonRailway = 0;
281 return numRailway > 0 && numNonRailway == 0;
289 for (
const auto& node : nc) {
291 for (
NBEdge*
const edge : node.second->myAllEdges) {
294 node.second->markBentPriority(
false);
296 if (node.second->myIncomingEdges.size() == 1 && node.second->myOutgoingEdges.size() == 1) {
303 e->setJunctionPriority(node.second, e->getPriority());
325 NBEdge* best = incoming[0];
326 while (incoming.size() > 0 &&
samePriority(best, incoming[0])) {
327 bestIncoming.push_back(*incoming.begin());
328 incoming.erase(incoming.begin());
331 assert(outgoing.size() != 0);
335 while (outgoing.size() > 0 &&
samePriority(best, outgoing[0])) {
336 bestOutgoing.push_back(*outgoing.begin());
337 outgoing.erase(outgoing.begin());
340 const bool mainDirectionExplicit = (
342 && (incoming.size() == 0 || bestIncoming[0]->getPriority() > incoming[0]->getPriority())
344 && (outgoing.size() == 0 || bestOutgoing[0]->getPriority() > outgoing[0]->getPriority())
345 && !bestIncoming[0]->isTurningDirectionAt(bestOutgoing[0]));
349 EdgeVector::iterator i;
350 std::map<NBEdge*, NBEdge*> counterIncomingEdges;
351 std::map<NBEdge*, NBEdge*> counterOutgoingEdges;
354 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
356 counterIncomingEdges[*i] = *incoming.begin();
358 counterOutgoingEdges[*i] = *outgoing.begin();
363 if (bestIncoming.size() == 1) {
366 if (!mainDirectionExplicit && counterIncomingEdges.find(best1) != counterIncomingEdges.end()) {
370 NBEdge* s = counterIncomingEdges.find(best1)->second;
372 if (minAngleDiff > 180 - 45
378 assert(bestOutgoing.size() != 0);
383 if (!mainDirectionExplicit && counterOutgoingEdges.find(bestOut) != counterOutgoingEdges.end()) {
384 NBEdge* s = counterOutgoingEdges.find(bestOut)->second;
397 double bestAngle = 0;
398 NBEdge* bestFirst =
nullptr;
399 NBEdge* bestSecond =
nullptr;
400 bool hadBest =
false;
401 for (i = bestIncoming.begin(); i != bestIncoming.end(); ++i) {
402 EdgeVector::iterator j;
408 for (j = i + 1; j != bestIncoming.end(); ++j) {
415 if (!hadBest || angle > bestAngle) {
425 if (bestOutgoing.size() != 0) {
430 if (bestOutgoing.size() != 0) {
442 const double a2 = bestSecond ==
nullptr ? a1 : bestSecond->
getAngleAtNode(&n);
451 && (p1 & perm) == 0 && (p2 & perm) == 0) {
452 e->setJunctionPriority(&n, 1);
487 if (edges.size() < 2) {
490 int prio = edges[0] == excluded ? edges[1]->
getPriority() : edges[0]->getPriority();
491 for (
auto e : edges) {