51 #ifdef CHECK_MEMORY_LEAKS
53 #endif // CHECK_MEMORY_LEAKS
66 if (!oc.
isSet(
"output-file")) {
70 device.
writeXMLHeader(
"net",
NWFrame::MAJOR_VERSION +
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/net_file.xsd\"");
81 bool origNames = oc.
getBool(
"output.original-names");
82 if (!oc.
getBool(
"no-internal-links")) {
84 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
93 bool noNames = !oc.
getBool(
"output.street-names");
94 for (std::map<std::string, NBEdge*>::const_iterator i = ec.
begin(); i != ec.
end(); ++i) {
95 writeEdge(device, *(*i).second, noNames, origNames);
103 std::set<NBNode*> roundaboutNodes;
104 const bool checkLaneFoesAll = oc.
getBool(
"check-lane-foes.all");
105 const bool checkLaneFoesRoundabout = !checkLaneFoesAll && oc.
getBool(
"check-lane-foes.roundabout");
106 if (checkLaneFoesRoundabout) {
108 for (std::vector<EdgeVector>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
109 for (EdgeVector::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
110 roundaboutNodes.insert((*j)->getToNode());
114 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
115 const bool checkLaneFoes = checkLaneFoesAll || (checkLaneFoesRoundabout && roundaboutNodes.count((*i).second) > 0);
119 const bool includeInternal = !oc.
getBool(
"no-internal-links");
120 if (includeInternal) {
123 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
132 unsigned int numConnections = 0;
133 for (std::map<std::string, NBEdge*>::const_iterator it_edge = ec.
begin(); it_edge != ec.
end(); it_edge++) {
134 NBEdge* from = it_edge->second;
136 const std::vector<NBEdge::Connection> connections = from->
getConnections();
137 numConnections += (
unsigned int)connections.size();
138 for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
142 if (numConnections > 0) {
145 if (includeInternal) {
148 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
155 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
156 NBNode* node = (*i).second;
158 const std::vector<NBNode::Crossing>& crossings = node->
getCrossings();
159 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
163 const std::vector<NBNode::WalkingArea>& WalkingAreas = node->
getWalkingAreas();
164 for (std::vector<NBNode::WalkingArea>::const_iterator it = WalkingAreas.begin(); it != WalkingAreas.end(); it++) {
165 if ((*it).nextCrossing !=
"") {
173 if ((*it).tlID !=
"") {
183 for (std::vector<std::string>::const_iterator it_sw = (*it).nextSidewalks.begin(); it_sw != (*it).nextSidewalks.end(); ++it_sw) {
186 for (std::vector<std::string>::const_iterator it_sw = (*it).prevSidewalks.begin(); it_sw != (*it).prevSidewalks.end(); ++it_sw) {
193 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
200 std::vector<std::vector<std::string> > edgeIDs;
201 for (std::vector<EdgeVector>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
202 std::vector<std::string> tEdgeIDs;
203 for (EdgeVector::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
204 tEdgeIDs.push_back((*j)->getID());
206 std::sort(tEdgeIDs.begin(), tEdgeIDs.end());
207 edgeIDs.push_back(tEdgeIDs);
209 std::sort(edgeIDs.begin(), edgeIDs.end());
211 for (std::vector<std::vector<std::string> >::const_iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
214 if (roundabouts.size() != 0) {
219 for (std::map<std::string, NBDistrict*>::const_iterator i = dc.
begin(); i != dc.
end(); i++) {
222 if (dc.
size() != 0) {
233 for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
234 const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
235 if (elv.size() > 0) {
236 bool haveVia =
false;
238 std::string internalEdgeID =
"";
240 std::map<NBEdge*, SUMOReal> lengthSum;
241 std::map<NBEdge*, int> numLanes;
242 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
244 numLanes[(*k).toEdge] += 1;
247 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
248 if ((*k).toEdge == 0) {
252 if (toEdge != (*k).toEdge) {
253 internalEdgeID = (*k).id;
258 toEdge = (*k).toEdge;
266 const NBEdge::Lane& successor = (*k).toEdge->getLanes()[(*k).toLane];
267 const SUMOReal length = lengthSum[toEdge] / numLanes[toEdge];
271 writeLane(into, internalEdgeID, (*k).getInternalLaneID(), (*k).vmax,
274 length, (*k).internalLaneIndex, origNames);
275 haveVia = haveVia || (*k).haveVia;
281 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
285 if ((*k).toEdge == 0) {
289 const NBEdge::Lane& successor = (*k).toEdge->getLanes()[(*k).toLane];
303 const std::vector<NBNode::Crossing>& crossings = n.
getCrossings();
304 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
314 const std::vector<NBNode::WalkingArea>& WalkingAreas = n.
getWalkingAreas();
315 for (std::vector<NBNode::WalkingArea>::const_iterator it = WalkingAreas.begin(); it != WalkingAreas.end(); it++) {
355 const std::vector<NBEdge::Lane>& lanes = e.
getLanes();
368 for (
unsigned int i = 0; i < (
unsigned int) lanes.size(); i++) {
372 length, i, origNames);
383 const std::string& origID,
SUMOReal length,
unsigned int index,
bool origNames) {
394 }
else if (speed < 0) {
398 length = length - endOffset;
410 if (origNames && origID !=
"") {
429 std::string incLanes;
431 for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
432 unsigned int noLanes = (*i)->getNumLanes();
433 for (
unsigned int j = 0; j < noLanes; j++) {
434 incLanes += (*i)->getLaneID(j);
435 if (i != incoming.end() - 1 || j < noLanes - 1) {
440 const std::vector<NBNode::Crossing>& crossings = n.
getCrossings();
441 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
442 incLanes +=
' ' + (*it).prevWalkingArea +
"_0";
446 std::string intLanes;
449 for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
450 const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
451 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
452 if ((*k).toEdge == 0) {
459 intLanes += (*k).getInternalLaneID();
461 intLanes += (*k).viaID +
"_0";
467 for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) {
468 intLanes +=
' ' + (*it).id +
"_0";
488 std::vector<std::string> internalLaneIDs;
489 for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
490 const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
491 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
492 if ((*k).toEdge != 0) {
493 internalLaneIDs.push_back((*k).getInternalLaneID());
497 const std::vector<NBNode::Crossing>& crossings = n.
getCrossings();
498 for (std::vector<NBNode::Crossing>::const_iterator it_c = crossings.begin(); it_c != crossings.end(); ++it_c) {
499 internalLaneIDs.push_back((*it_c).id +
"_0");
502 for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
503 const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
504 for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
505 if ((*k).toEdge == 0 || !(*k).haveVia) {
512 std::string incLanes = (*k).getInternalLaneID();
513 if ((*k).foeIncomingLanes.length() != 0) {
514 incLanes +=
" " + (*k).foeIncomingLanes;
517 const std::vector<unsigned int>& foes = (*k).foeInternalLinks;
518 std::vector<std::string> foeIDs;
519 for (std::vector<unsigned int>::const_iterator it = foes.begin(); it != foes.end(); ++it) {
520 foeIDs.push_back(internalLaneIDs[*it]);
543 if (style !=
PLAIN) {
544 if (includeInternal) {
571 for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
573 const std::vector<NBEdge::Connection>& connections = from->
getConnections();
574 for (std::vector<NBEdge::Connection>::const_iterator j = connections.begin(); j != connections.end(); ++j) {
594 const std::string& from,
const std::string& to,
595 int fromLane,
int toLane,
const std::string& via) {
613 std::vector<std::string> nodeIDs;
614 for (std::vector<std::string>::const_iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
617 std::sort(nodeIDs.begin(), nodeIDs.end());
639 for (i = 0; i < sources.size(); i++) {
646 for (i = 0; i < sinks.size(); i++) {
659 if (time == std::floor(time)) {
669 for (NBConnectionProhibits::const_iterator j = prohibitions.begin(); j != prohibitions.end(); j++) {
672 for (NBConnectionVector::const_iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
691 std::vector<NBTrafficLightLogic*> logics = tllCont.
getComputed();
692 for (std::vector<NBTrafficLightLogic*>::iterator it = logics.begin(); it != logics.end(); it++) {
699 const std::map<std::string, std::string>& params = (*it)->getMap();
700 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
707 const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases = (*it)->getPhases();
708 for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator j = phases.begin(); j != phases.end(); ++j) {
716 if (logics.size() > 0) {
743 if (permissions ==
SVCAll) {
745 }
else if (permissions == 0) {
749 size_t num_allowed = 0;
751 if ((mask & permissions) == mask) {
766 if (preferred ==
SVCAll || preferred == 0) {