SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NWWriter_SUMO.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Exporter writing networks using the SUMO format
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 #include <cmath>
33 #include <algorithm>
37 #include <utils/common/ToString.h>
40 #include <netbuild/NBEdge.h>
41 #include <netbuild/NBEdgeCont.h>
42 #include <netbuild/NBNode.h>
43 #include <netbuild/NBNodeCont.h>
44 #include <netbuild/NBNetBuilder.h>
46 #include <netbuild/NBDistrict.h>
47 #include "NWFrame.h"
48 #include "NWWriter_SUMO.h"
49 
50 #ifdef CHECK_MEMORY_LEAKS
51 #include <foreign/nvwa/debug_new.h>
52 #endif // CHECK_MEMORY_LEAKS
53 
54 
55 
56 // ===========================================================================
57 // method definitions
58 // ===========================================================================
59 // ---------------------------------------------------------------------------
60 // static methods
61 // ---------------------------------------------------------------------------
62 void
64  // check whether a sumo net-file shall be generated
65  if (!oc.isSet("output-file")) {
66  return;
67  }
68  OutputDevice& device = OutputDevice::getDevice(oc.getString("output-file"));
69  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\""); // street names may contain non-ascii chars
70  device.lf();
71  // get involved container
72  const NBNodeCont& nc = nb.getNodeCont();
73  const NBEdgeCont& ec = nb.getEdgeCont();
74  const NBDistrictCont& dc = nb.getDistrictCont();
75 
76  // write network offsets and projection
77  writeLocation(device);
78 
79  // write inner lanes
80  bool origNames = oc.getBool("output.original-names");
81  if (!oc.getBool("no-internal-links")) {
82  bool hadAny = false;
83  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
84  hadAny |= writeInternalEdges(device, *(*i).second, origNames);
85  }
86  if (hadAny) {
87  device.lf();
88  }
89  }
90 
91  // write edges with lanes and connected edges
92  bool noNames = !oc.getBool("output.street-names");
93  for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
94  writeEdge(device, *(*i).second, noNames, origNames);
95  }
96  device.lf();
97 
98  // write tls logics
99  writeTrafficLights(device, nb.getTLLogicCont());
100 
101  // write the nodes (junctions)
102  std::set<NBNode*> roundaboutNodes;
103  const bool checkLaneFoesAll = oc.getBool("check-lane-foes.all");
104  const bool checkLaneFoesRoundabout = !checkLaneFoesAll && oc.getBool("check-lane-foes.roundabout");
105  if (checkLaneFoesRoundabout) {
106  const std::vector<EdgeVector>& roundabouts = nb.getRoundabouts();
107  for (std::vector<EdgeVector>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
108  for (EdgeVector::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
109  roundaboutNodes.insert((*j)->getToNode());
110  }
111  }
112  }
113  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
114  const bool checkLaneFoes = checkLaneFoesAll || (checkLaneFoesRoundabout && roundaboutNodes.count((*i).second) > 0);
115  writeJunction(device, *(*i).second, checkLaneFoes);
116  }
117  device.lf();
118  const bool includeInternal = !oc.getBool("no-internal-links");
119  if (includeInternal) {
120  // ... internal nodes if not unwanted
121  bool hadAny = false;
122  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
123  hadAny |= writeInternalNodes(device, *(*i).second);
124  }
125  if (hadAny) {
126  device.lf();
127  }
128  }
129 
130  // write the successors of lanes
131  unsigned int numConnections = 0;
132  for (std::map<std::string, NBEdge*>::const_iterator it_edge = ec.begin(); it_edge != ec.end(); it_edge++) {
133  NBEdge* from = it_edge->second;
135  const std::vector<NBEdge::Connection> connections = from->getConnections();
136  numConnections += (unsigned int)connections.size();
137  for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
138  writeConnection(device, *from, *it_c, includeInternal);
139  }
140  }
141  if (numConnections > 0) {
142  device.lf();
143  }
144  if (includeInternal) {
145  // ... internal successors if not unwanted
146  bool hadAny = false;
147  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
148  hadAny |= writeInternalConnections(device, *(*i).second);
149  }
150  if (hadAny) {
151  device.lf();
152  }
153  }
154  // write loaded prohibitions
155  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
156  writeProhibitions(device, i->second->getProhibitions());
157  }
158 
159  // write roundabout information
160  const std::vector<EdgeVector>& roundabouts = nb.getRoundabouts();
161  // make output deterministic
162  std::vector<std::vector<std::string> > edgeIDs;
163  for (std::vector<EdgeVector>::const_iterator i = roundabouts.begin(); i != roundabouts.end(); ++i) {
164  std::vector<std::string> tEdgeIDs;
165  for (EdgeVector::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
166  tEdgeIDs.push_back((*j)->getID());
167  }
168  std::sort(tEdgeIDs.begin(), tEdgeIDs.end());
169  edgeIDs.push_back(tEdgeIDs);
170  }
171  std::sort(edgeIDs.begin(), edgeIDs.end());
172  // write
173  for (std::vector<std::vector<std::string> >::const_iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
174  writeRoundabout(device, *i, ec);
175  }
176  if (roundabouts.size() != 0) {
177  device.lf();
178  }
179 
180  // write the districts
181  for (std::map<std::string, NBDistrict*>::const_iterator i = dc.begin(); i != dc.end(); i++) {
182  writeDistrict(device, *(*i).second);
183  }
184  if (dc.size() != 0) {
185  device.lf();
186  }
187  device.close();
188 }
189 
190 
191 bool
192 NWWriter_SUMO::writeInternalEdges(OutputDevice& into, const NBNode& n, bool origNames) {
193  bool ret = false;
194  const EdgeVector& incoming = n.getIncomingEdges();
195  for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
196  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
197  if (elv.size() > 0) {
198  bool haveVia = false;
199  NBEdge* toEdge = 0;
200  std::string internalEdgeID = "";
201  // first pass: compute average lengths of non-via edges
202  std::map<NBEdge*, SUMOReal> lengthSum;
203  std::map<NBEdge*, int> numLanes;
204  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
205  lengthSum[(*k).toEdge] += MAX2((*k).shape.length(), (SUMOReal)POSITION_EPS);
206  numLanes[(*k).toEdge] += 1;
207  }
208  // second pass: write non-via edges
209  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
210  if ((*k).toEdge == 0) {
211  assert(false); // should never happen. tell me when it does
212  continue;
213  }
214  if (toEdge != (*k).toEdge) {
215  internalEdgeID = (*k).id;
216  if (toEdge != 0) {
217  // close the previous edge
218  into.closeTag();
219  }
220  toEdge = (*k).toEdge;
221  into.openTag(SUMO_TAG_EDGE);
222  into.writeAttr(SUMO_ATTR_ID, internalEdgeID);
224  // open a new edge
225  }
226  // to avoid changing to an internal lane which has a successor
227  // with the wrong permissions we need to inherit them from the successor
228  const NBEdge::Lane& successor = (*k).toEdge->getLanes()[(*k).toLane];
229  const SUMOReal length = lengthSum[toEdge] / numLanes[toEdge];
230  writeLane(into, internalEdgeID, (*k).getInternalLaneID(), (*k).vmax,
231  successor.permissions, successor.preferred,
232  NBEdge::UNSPECIFIED_OFFSET, NBEdge::UNSPECIFIED_WIDTH, (*k).shape, (*k).origID,
233  length, (*k).internalLaneIndex, origNames);
234  haveVia = haveVia || (*k).haveVia;
235  }
236  ret = true;
237  into.closeTag(); // close the last edge
238  // third pass: write via edges
239  if (haveVia) {
240  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
241  if (!(*k).haveVia) {
242  continue;
243  }
244  if ((*k).toEdge == 0) {
245  assert(false); // should never happen. tell me when it does
246  continue;
247  }
248  into.openTag(SUMO_TAG_EDGE);
249  into.writeAttr(SUMO_ATTR_ID, (*k).viaID);
251  writeLane(into, (*k).viaID, (*k).viaID + "_0", (*k).viaVmax, SVCFreeForAll, SVCFreeForAll,
252  NBEdge::UNSPECIFIED_OFFSET, NBEdge::UNSPECIFIED_WIDTH, (*k).viaShape, (*k).origID,
253  MAX2((*k).viaShape.length(), (SUMOReal)POSITION_EPS), // microsim needs positive length
254  0, origNames);
255  into.closeTag(); // close the last edge
256  }
257  }
258  }
259  }
260  return ret;
261 }
262 
263 
264 void
265 NWWriter_SUMO::writeEdge(OutputDevice& into, const NBEdge& e, bool noNames, bool origNames) {
266  // write the edge's begin
269  into.writeAttr(SUMO_ATTR_TO, e.getToNode()->getID());
270  if (!noNames && e.getStreetName() != "") {
272  }
274  if (e.getTypeName() != "") {
276  }
277  if (e.isMacroscopicConnector()) {
279  }
280  // write the spread type if not default ("right")
283  }
284  if (e.hasLoadedLength()) {
286  }
287  if (!e.hasDefaultGeometry()) {
289  }
290  // write the lanes
291  const std::vector<NBEdge::Lane>& lanes = e.getLanes();
292 
293  SUMOReal length = e.getLoadedLength();
294  if (OptionsCont::getOptions().getBool("no-internal-links") && !e.hasLoadedLength()) {
295  // use length to junction center even if a modified geometry was given
296  PositionVector geom = e.getGeometry();
299  length = geom.length();
300  }
301  if (length <= 0) {
302  length = (SUMOReal)POSITION_EPS;
303  }
304  for (unsigned int i = 0; i < (unsigned int) lanes.size(); i++) {
305  const NBEdge::Lane& l = lanes[i];
306  writeLane(into, e.getID(), e.getLaneID(i), l.speed,
307  l.permissions, l.preferred, l.offset, l.width, l.shape, l.origID,
308  length, i, origNames);
309  }
310  // close the edge
311  into.closeTag();
312 }
313 
314 
315 void
316 NWWriter_SUMO::writeLane(OutputDevice& into, const std::string& eID, const std::string& lID,
317  SUMOReal speed, SVCPermissions permissions, SVCPermissions preferred,
318  SUMOReal offset, SUMOReal width, const PositionVector& shape,
319  const std::string& origID, SUMOReal length, unsigned int index, bool origNames) {
320  // output the lane's attributes
322  // the first lane of an edge will be the depart lane
323  into.writeAttr(SUMO_ATTR_INDEX, index);
324  // write the list of allowed/disallowed vehicle classes
325  writePermissions(into, permissions);
326  writePreferences(into, preferred);
327  // some further information
328  if (speed == 0) {
329  WRITE_WARNING("Lane #" + toString(index) + " of edge '" + eID + "' has a maximum velocity of 0.");
330  } else if (speed < 0) {
331  throw ProcessError("Negative velocity (" + toString(speed) + " on edge '" + eID + "' lane#" + toString(index) + ".");
332  }
333  if (offset > 0) {
334  length = length - offset;
335  }
336  into.writeAttr(SUMO_ATTR_SPEED, speed);
337  into.writeAttr(SUMO_ATTR_LENGTH, length);
338  if (offset != NBEdge::UNSPECIFIED_OFFSET) {
339  into.writeAttr(SUMO_ATTR_ENDOFFSET, offset);
340  }
341  if (width != NBEdge::UNSPECIFIED_WIDTH) {
342  into.writeAttr(SUMO_ATTR_WIDTH, width);
343  }
344  into.writeAttr(SUMO_ATTR_SHAPE, offset > 0 ?
345  shape.getSubpart(0, shape.length() - offset) : shape);
346  if (origNames && origID != "") {
347  into.openTag(SUMO_TAG_PARAM);
348  into.writeAttr(SUMO_ATTR_KEY, "origId");
349  into.writeAttr(SUMO_ATTR_VALUE, origID);
350  into.closeTag();
351  into.closeTag();
352  } else {
353  into.closeTag();
354  }
355 }
356 
357 
358 void
359 NWWriter_SUMO::writeJunction(OutputDevice& into, const NBNode& n, const bool checkLaneFoes) {
360  // write the attributes
362  into.writeAttr(SUMO_ATTR_TYPE, n.getType());
364  // write the incoming lanes
365  std::string incLanes;
366  const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
367  for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
368  unsigned int noLanes = (*i)->getNumLanes();
369  for (unsigned int j = 0; j < noLanes; j++) {
370  incLanes += (*i)->getLaneID(j);
371  if (i != incoming.end() - 1 || j < noLanes - 1) {
372  incLanes += ' ';
373  }
374  }
375  }
376  into.writeAttr(SUMO_ATTR_INCLANES, incLanes);
377  // write the internal lanes
378  std::string intLanes;
379  if (!OptionsCont::getOptions().getBool("no-internal-links")) {
380  unsigned int l = 0;
381  for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
382  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
383  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
384  if ((*k).toEdge == 0) {
385  continue;
386  }
387  if (l != 0) {
388  intLanes += ' ';
389  }
390  if (!(*k).haveVia) {
391  intLanes += (*k).getInternalLaneID();
392  } else {
393  intLanes += (*k).viaID + "_0";
394  }
395  l++;
396  }
397  }
398  }
399  into.writeAttr(SUMO_ATTR_INTLANES, intLanes);
400  // close writing
402  if (n.getType() == NODETYPE_DEAD_END) {
403  into.closeTag();
404  } else {
405  // write right-of-way logics
406  n.writeLogic(into, checkLaneFoes);
407  into.closeTag();
408  }
409 }
410 
411 
412 bool
414  bool ret = false;
415  const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
416  // build the list of internal lane ids
417  std::vector<std::string> internalLaneIDs;
418  for (EdgeVector::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
419  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
420  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
421  if ((*k).toEdge != 0) {
422  internalLaneIDs.push_back((*k).getInternalLaneID());
423  }
424  }
425  }
426  // write the internal nodes
427  for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); i++) {
428  const std::vector<NBEdge::Connection>& elv = (*i)->getConnections();
429  for (std::vector<NBEdge::Connection>::const_iterator k = elv.begin(); k != elv.end(); ++k) {
430  if ((*k).toEdge == 0 || !(*k).haveVia) {
431  continue;
432  }
433  Position pos = (*k).shape[-1];
434  into.openTag(SUMO_TAG_JUNCTION).writeAttr(SUMO_ATTR_ID, (*k).viaID + "_0");
436  NWFrame::writePositionLong(pos, into);
437  std::string incLanes = (*k).getInternalLaneID();
438  if ((*k).foeIncomingLanes.length() != 0) {
439  incLanes += " " + (*k).foeIncomingLanes;
440  }
441  into.writeAttr(SUMO_ATTR_INCLANES, incLanes);
442  const std::vector<unsigned int>& foes = (*k).foeInternalLinks;
443  std::vector<std::string> foeIDs;
444  for (std::vector<unsigned int>::const_iterator it = foes.begin(); it != foes.end(); ++it) {
445  foeIDs.push_back(internalLaneIDs[*it]);
446  }
447  into.writeAttr(SUMO_ATTR_INTLANES, joinToString(foeIDs, " "));
448  into.closeTag();
449  ret = true;
450  }
451  }
452  return ret;
453 }
454 
455 
456 void
458  bool includeInternal, ConnectionStyle style) {
459  assert(c.toEdge != 0);
461  into.writeAttr(SUMO_ATTR_FROM, from.getID());
462  into.writeAttr(SUMO_ATTR_TO, c.toEdge->getID());
465  if (c.mayDefinitelyPass) {
467  }
468  if (style != PLAIN) {
469  if (includeInternal) {
471  }
472  // set information about the controlling tl if any
473  if (c.tlID != "") {
474  into.writeAttr(SUMO_ATTR_TLID, c.tlID);
476  }
477  if (style == SUMONET) {
478  // write the direction information
479  LinkDirection dir = from.getToNode()->getDirection(&from, c.toEdge);
480  assert(dir != LINKDIR_NODIR);
481  into.writeAttr(SUMO_ATTR_DIR, toString(dir));
482  // write the state information
483  const LinkState linkState = from.getToNode()->getLinkState(
484  &from, c.toEdge, c.toLane, c.mayDefinitelyPass, c.tlID);
485  into.writeAttr(SUMO_ATTR_STATE, linkState);
486  }
487  }
488  into.closeTag();
489 }
490 
491 
492 bool
494  bool ret = false;
495  const std::vector<NBEdge*>& incoming = n.getIncomingEdges();
496  for (std::vector<NBEdge*>::const_iterator i = incoming.begin(); i != incoming.end(); ++i) {
497  NBEdge* from = *i;
498  const std::vector<NBEdge::Connection>& connections = from->getConnections();
499  for (std::vector<NBEdge::Connection>::const_iterator j = connections.begin(); j != connections.end(); ++j) {
500  const NBEdge::Connection& c = *j;
501  assert(c.toEdge != 0);
502  if (c.haveVia) {
503  // internal split
504  writeInternalConnection(into, c.id, c.toEdge->getID(), c.internalLaneIndex, c.toLane, c.viaID + "_0");
505  writeInternalConnection(into, c.viaID, c.toEdge->getID(), 0, c.toLane, "");
506  } else {
507  // no internal split
509  }
510  ret = true;
511  }
512  }
513  return ret;
514 }
515 
516 
517 void
519  const std::string& from, const std::string& to,
520  int fromLane, int toLane, const std::string& via) {
522  into.writeAttr(SUMO_ATTR_FROM, from);
523  into.writeAttr(SUMO_ATTR_TO, to);
524  into.writeAttr(SUMO_ATTR_FROM_LANE, fromLane);
525  into.writeAttr(SUMO_ATTR_TO_LANE, toLane);
526  if (via != "") {
527  into.writeAttr(SUMO_ATTR_VIA, via);
528  }
529  into.writeAttr(SUMO_ATTR_DIR, "s");
530  into.writeAttr(SUMO_ATTR_STATE, "M");
531  into.closeTag();
532 }
533 
534 
535 void
536 NWWriter_SUMO::writeRoundabout(OutputDevice& into, const std::vector<std::string>& edgeIDs,
537  const NBEdgeCont& ec) {
538  std::vector<std::string> nodeIDs;
539  for (std::vector<std::string>::const_iterator i = edgeIDs.begin(); i != edgeIDs.end(); ++i) {
540  nodeIDs.push_back(ec.retrieve(*i)->getToNode()->getID());
541  }
542  std::sort(nodeIDs.begin(), nodeIDs.end());
544  into.writeAttr(SUMO_ATTR_NODES, joinToString(nodeIDs, " "));
545  into.writeAttr(SUMO_ATTR_EDGES, joinToString(edgeIDs, " "));
546  into.closeTag();
547 }
548 
549 
550 void
552  std::vector<SUMOReal> sourceW = d.getSourceWeights();
554  std::vector<SUMOReal> sinkW = d.getSinkWeights();
556  // write the head and the id of the district
558  if (d.getShape().size() > 0) {
560  }
561  size_t i;
562  // write all sources
563  const std::vector<NBEdge*>& sources = d.getSourceEdges();
564  for (i = 0; i < sources.size(); i++) {
565  // write the head and the id of the source
566  into.openTag(SUMO_TAG_TAZSOURCE).writeAttr(SUMO_ATTR_ID, sources[i]->getID()).writeAttr(SUMO_ATTR_WEIGHT, sourceW[i]);
567  into.closeTag();
568  }
569  // write all sinks
570  const std::vector<NBEdge*>& sinks = d.getSinkEdges();
571  for (i = 0; i < sinks.size(); i++) {
572  // write the head and the id of the sink
573  into.openTag(SUMO_TAG_TAZSINK).writeAttr(SUMO_ATTR_ID, sinks[i]->getID()).writeAttr(SUMO_ATTR_WEIGHT, sinkW[i]);
574  into.closeTag();
575  }
576  // write the tail
577  into.closeTag();
578 }
579 
580 
581 std::string
583  SUMOReal time = STEPS2TIME(steps);
584  if (time == std::floor(time)) {
585  return toString(int(time));
586  } else {
587  return toString(time);
588  }
589 }
590 
591 
592 void
594  for (NBConnectionProhibits::const_iterator j = prohibitions.begin(); j != prohibitions.end(); j++) {
595  NBConnection prohibited = (*j).first;
596  const NBConnectionVector& prohibiting = (*j).second;
597  for (NBConnectionVector::const_iterator k = prohibiting.begin(); k != prohibiting.end(); k++) {
598  NBConnection prohibitor = *k;
602  into.closeTag();
603  }
604  }
605 }
606 
607 
608 std::string
610  return c.getFrom()->getID() + "->" + c.getTo()->getID();
611 }
612 
613 
614 void
616  std::vector<NBTrafficLightLogic*> logics = tllCont.getComputed();
617  for (std::vector<NBTrafficLightLogic*>::iterator it = logics.begin(); it != logics.end(); it++) {
619  into.writeAttr(SUMO_ATTR_ID, (*it)->getID());
620  into.writeAttr(SUMO_ATTR_TYPE, (*it)->getType());
621  into.writeAttr(SUMO_ATTR_PROGRAMID, (*it)->getProgramID());
622  into.writeAttr(SUMO_ATTR_OFFSET, writeSUMOTime((*it)->getOffset()));
623  // write params
624  const std::map<std::string, std::string>& params = (*it)->getMap();
625  for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
626  into.openTag(SUMO_TAG_PARAM);
627  into.writeAttr(SUMO_ATTR_KEY, (*i).first);
628  into.writeAttr(SUMO_ATTR_VALUE, (*i).second);
629  into.closeTag();
630  }
631  // write the phases
632  const std::vector<NBTrafficLightLogic::PhaseDefinition>& phases = (*it)->getPhases();
633  for (std::vector<NBTrafficLightLogic::PhaseDefinition>::const_iterator j = phases.begin(); j != phases.end(); ++j) {
634  into.openTag(SUMO_TAG_PHASE);
635  into.writeAttr(SUMO_ATTR_DURATION, writeSUMOTime(j->duration));
636  into.writeAttr(SUMO_ATTR_STATE, j->state);
637  into.closeTag();
638  }
639  into.closeTag();
640  }
641  if (logics.size() > 0) {
642  into.lf();
643  }
644 }
645 
646 
647 void
649  const GeoConvHelper& geoConvHelper = GeoConvHelper::getFinal();
651  into.writeAttr(SUMO_ATTR_NET_OFFSET, geoConvHelper.getOffsetBase());
652  into.writeAttr(SUMO_ATTR_CONV_BOUNDARY, geoConvHelper.getConvBoundary());
653  if (geoConvHelper.usingGeoProjection()) {
655  }
656  into.writeAttr(SUMO_ATTR_ORIG_BOUNDARY, geoConvHelper.getOrigBoundary());
657  if (geoConvHelper.usingGeoProjection()) {
658  into.setPrecision();
659  }
660  into.writeAttr(SUMO_ATTR_ORIG_PROJ, geoConvHelper.getProjString());
661  into.closeTag();
662  into.lf();
663 }
664 
665 
666 void
668  if (permissions == SVCFreeForAll) {
669  return;
670  } else if (permissions == 0) {
671  // special case: since all-empty encodes FreeForAll we must list all disallowed
673  return;
674  } else {
675  std::pair<std::string, bool> encoding = getPermissionEncoding(permissions);
676  if (encoding.second) {
677  into.writeAttr(SUMO_ATTR_ALLOW, encoding.first);
678  } else {
679  into.writeAttr(SUMO_ATTR_DISALLOW, encoding.first);
680  }
681  }
682 }
683 
684 
685 void
687  if (preferred == SVCFreeForAll || preferred == 0) {
688  return;
689  } else {
691  }
692 }
693 /****************************************************************************/
694