SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NIImporter_OpenDrive.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Importer for networks stored in openDrive format
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 #include <string>
34 #include <cmath>
35 #include <iterator>
39 #include <utils/common/ToString.h>
42 #include <netbuild/NBEdge.h>
43 #include <netbuild/NBEdgeCont.h>
44 #include <netbuild/NBNode.h>
45 #include <netbuild/NBNodeCont.h>
46 #include <netbuild/NBNetBuilder.h>
47 #include <netbuild/NBOwnTLDef.h>
55 #include <utils/xml/XMLSubSys.h>
56 #include <utils/geom/Boundary.h>
57 #include "NILoader.h"
58 #include "NIImporter_OpenDrive.h"
59 
60 #ifdef CHECK_MEMORY_LEAKS
61 #include <foreign/nvwa/debug_new.h>
62 #endif // CHECK_MEMORY_LEAKS
63 
64 
65 // ===========================================================================
66 // definitions
67 // ===========================================================================
68 #define C_LENGTH 10.
69 
70 
71 // ===========================================================================
72 // static variables
73 // ===========================================================================
95 
97 };
98 
99 
131 
133 };
134 
135 
138 
139 // ===========================================================================
140 // method definitions
141 // ===========================================================================
142 // ---------------------------------------------------------------------------
143 // static methods (interface in this case)
144 // ---------------------------------------------------------------------------
145 void
147  // check whether the option is set (properly)
148  if (!oc.isUsableFileList("opendrive-files")) {
149  return;
150  }
151  // prepare types
152  myImportAllTypes = oc.getBool("opendrive.import-all-lanes");
153  myImportWidths = !oc.getBool("opendrive.ignore-widths");
154  NBTypeCont& tc = nb.getTypeCont();
155  // build the handler
156  std::map<std::string, OpenDriveEdge*> edges;
157  NIImporter_OpenDrive handler(nb.getTypeCont(), edges);
158  // parse file(s)
159  std::vector<std::string> files = oc.getStringVector("opendrive-files");
160  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
161  if (!FileHelpers::isReadable(*file)) {
162  WRITE_ERROR("Could not open opendrive file '" + *file + "'.");
163  return;
164  }
165  handler.setFileName(*file);
166  PROGRESS_BEGIN_MESSAGE("Parsing opendrive from '" + *file + "'");
167  XMLSubSys::runParser(handler, *file);
169  }
170  // split inner/outer edges
171  std::map<std::string, OpenDriveEdge*> innerEdges, outerEdges;
172  for (std::map<std::string, OpenDriveEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
173  if ((*i).second->isInner) {
174  innerEdges[(*i).first] = (*i).second;
175  } else {
176  outerEdges[(*i).first] = (*i).second;
177  }
178  }
179 
180  // convert geometries into a discretised representation
181  computeShapes(edges);
182  // check whether lane sections are valid and whether further must be introduced
183  revisitLaneSections(tc, edges);
184 
185  // -------------------------
186  // node building
187  // -------------------------
188  // build nodes#1
189  // look at all links which belong to a node, collect their bounding boxes
190  // and place the node in the middle of this bounding box
191  std::map<std::string, Boundary> posMap;
192  std::map<std::string, std::string> edge2junction;
193  // compute node positions
194  for (std::map<std::string, OpenDriveEdge*>::iterator i = innerEdges.begin(); i != innerEdges.end(); ++i) {
195  OpenDriveEdge* e = (*i).second;
196  assert(e->junction != "-1" && e->junction != "");
197  edge2junction[e->id] = e->junction;
198  if (posMap.find(e->junction) == posMap.end()) {
199  posMap[e->junction] = Boundary();
200  }
201  posMap[e->junction].add(e->geom.getBoxBoundary());
202  }
203  // build nodes
204  for (std::map<std::string, Boundary>::iterator i = posMap.begin(); i != posMap.end(); ++i) {
205  if (!nb.getNodeCont().insert((*i).first, (*i).second.getCenter())) {
206  throw ProcessError("Could not add node '" + (*i).first + "'.");
207  }
208  }
209  // assign built nodes
210  for (std::map<std::string, OpenDriveEdge*>::iterator i = outerEdges.begin(); i != outerEdges.end(); ++i) {
211  OpenDriveEdge* e = (*i).second;
212  for (std::vector<OpenDriveLink>::iterator j = e->links.begin(); j != e->links.end(); ++j) {
213  OpenDriveLink& l = *j;
214  if (l.elementType != OPENDRIVE_ET_ROAD) {
215  // set node information
217  continue;
218  }
219  if (edge2junction.find(l.elementID) != edge2junction.end()) {
220  // set node information of an internal road
221  setNodeSecure(nb.getNodeCont(), *e, edge2junction[l.elementID], l.linkType);
222  continue;
223  }
224  }
225  }
226  // we should now have all nodes set for links which are not outer edge-to-outer edge links
227 
228 
229  // build nodes#2
230  // build nodes for all outer edge-to-outer edge connections
231  for (std::map<std::string, OpenDriveEdge*>::iterator i = outerEdges.begin(); i != outerEdges.end(); ++i) {
232  OpenDriveEdge* e = (*i).second;
233  for (std::vector<OpenDriveLink>::iterator j = e->links.begin(); j != e->links.end(); ++j) {
234  OpenDriveLink& l = *j;
235  if (l.elementType != OPENDRIVE_ET_ROAD || edge2junction.find(l.elementID) != edge2junction.end()) {
236  // is a connection to an internal edge, or a node, skip
237  continue;
238  }
239  // we have a direct connection between to external edges
240  std::string id1 = e->id;
241  std::string id2 = l.elementID;
242  if (id1 < id2) {
243  std::swap(id1, id2);
244  }
245  std::string nid = id1 + "." + id2;
246  if (nb.getNodeCont().retrieve(nid) == 0) {
247  // not yet seen, build
248  Position pos = l.linkType == OPENDRIVE_LT_SUCCESSOR ? e->geom[-1] : e->geom[0];
249  if (!nb.getNodeCont().insert(nid, pos)) {
250  throw ProcessError("Could not build node '" + nid + "'.");
251  }
252  }
253  /* debug-stuff
254  else {
255  Position pos = l.linkType==OPENDRIVE_LT_SUCCESSOR ? e.geom[e.geom.size()-1] : e.geom[0];
256  cout << nid << " " << pos << " " << nb.getNodeCont().retrieve(nid)->getPosition() << endl;
257  }
258  */
259  setNodeSecure(nb.getNodeCont(), *e, nid, l.linkType);
260  }
261  }
262  // we should now have start/end nodes for all outer edge-to-outer edge connections
263 
264 
265  // build nodes#3
266  // assign further nodes generated from inner-edges
267  // these nodes have not been assigned earlier, because the connectiosn are referenced in inner-edges
268  for (std::map<std::string, OpenDriveEdge*>::iterator i = outerEdges.begin(); i != outerEdges.end(); ++i) {
269  OpenDriveEdge* e = (*i).second;
270  if (e->to != 0 && e->from != 0) {
271  continue;
272  }
273  for (std::map<std::string, OpenDriveEdge*>::iterator j = innerEdges.begin(); j != innerEdges.end(); ++j) {
274  OpenDriveEdge* ie = (*j).second;
275  for (std::vector<OpenDriveLink>::iterator k = ie->links.begin(); k != ie->links.end(); ++k) {
276  OpenDriveLink& il = *k;
277  if (il.elementType != OPENDRIVE_ET_ROAD || il.elementID != e->id) {
278  // not conneted to the currently investigated outer edge
279  continue;
280  }
281  std::string nid = edge2junction[ie->id];
282  if (il.contactPoint == OPENDRIVE_CP_START) {
284  } else {
286  }
287  }
288  }
289 
290  }
291 
292  // build start/end nodes which were not defined previously
293  for (std::map<std::string, OpenDriveEdge*>::iterator i = outerEdges.begin(); i != outerEdges.end(); ++i) {
294  OpenDriveEdge* e = (*i).second;
295  if (e->from == 0) {
296  const std::string nid = e->id + ".begin";
297  e->from = getOrBuildNode(nid, e->geom.front(), nb.getNodeCont());
298  }
299  if (e->to == 0) {
300  const std::string nid = e->id + ".end";
301  e->to = getOrBuildNode(nid, e->geom.back(), nb.getNodeCont());
302  }
303  }
304 
305 
306  // -------------------------
307  // edge building
308  // -------------------------
309  SUMOReal defaultSpeed = tc.getSpeed("");
310  // build edges
311  for (std::map<std::string, OpenDriveEdge*>::iterator i = outerEdges.begin(); i != outerEdges.end(); ++i) {
312  OpenDriveEdge* e = (*i).second;
313  bool lanesBuilt = false;
314 
315  // go along the lane sections, build a node in between of each pair
316 
319 
321  NBNode* sFrom = e->from;
322  NBNode* sTo = e->to;
323  int priorityR = e->getPriority(OPENDRIVE_TAG_RIGHT);
324  int priorityL = e->getPriority(OPENDRIVE_TAG_LEFT);
325  SUMOReal sB = 0;
326  SUMOReal sE = e->length;
327  // 0-length geometries are possible if only the inner points are represented
328  const SUMOReal length2D = e->geom.length2D();
329  SUMOReal cF = length2D == 0 ? 1 : e->length / length2D;
330  NBEdge* prevRight = 0;
331  NBEdge* prevLeft = 0;
332 
333  // starting at the same node as ending, and no lane sections?
334  if (sFrom == sTo && e->laneSections.size() == 1) {
335  // --> loop, split!
337  ls.s = e->length / 2.;
338  e->laneSections.push_back(ls);
339  WRITE_WARNING("Edge '" + e->id + "' has to be split as it connects same junctions.")
340  }
341 
342  // build along lane sections
343  for (std::vector<OpenDriveLaneSection>::iterator j = e->laneSections.begin(); j != e->laneSections.end(); ++j) {
344  // add internal node if needed
345  if (j == e->laneSections.end() - 1) {
346  sTo = e->to;
347  sE = e->length / cF;
348  } else {
349  SUMOReal nextS = (j + 1)->s;
350  sTo = new NBNode(e->id + "." + toString(nextS), e->geom.positionAtOffset(nextS));
351  if (!nb.getNodeCont().insert(sTo)) {
352  throw ProcessError("Could not add node '" + sTo->getID() + "'.");
353  }
354  sE = nextS / cF;
355  }
356  PositionVector geom = e->geom.getSubpart2D(sB, sE);
357  std::string id = e->id;
358  if (sFrom != e->from || sTo != e->to) {
359  id = id + "." + toString((*j).s);
360  } else if (e->laneSections.size() == 1) {
361  id = id + ".0.00";
362  }
363 
364  // build lanes to right
365  NBEdge* currRight = 0;
366  if ((*j).rightLaneNumber > 0) {
367  currRight = new NBEdge("-" + id, sFrom, sTo, "", defaultSpeed, (*j).rightLaneNumber, priorityR,
369  if (!nb.getEdgeCont().insert(currRight)) {
370  throw ProcessError("Could not add edge '" + currRight->getID() + "'.");
371  }
372  lanesBuilt = true;
373  const std::vector<OpenDriveLane>& lanes = (*j).lanesByDir[OPENDRIVE_TAG_RIGHT];
374  for (std::vector<OpenDriveLane>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
375  std::map<int, int>::const_iterator lp = (*j).laneMap.find((*k).id);
376  if (lp != (*j).laneMap.end()) {
377  int sumoLaneIndex = lp->second;
378  NBEdge::Lane& sumoLane = currRight->getLaneStruct(sumoLaneIndex);
379  const OpenDriveLane& odLane = *k;
380 
381  sumoLane.origID = e->id + " -" + toString((*k).id);
382  sumoLane.speed = odLane.speed != 0 ? odLane.speed : tc.getSpeed(odLane.type);
383  sumoLane.permissions = tc.getPermissions(odLane.type);
384  sumoLane.width = myImportWidths && odLane.width != 0 ? odLane.width : tc.getWidth(odLane.type);
385  }
386  }
387  // connect lane sections
388  if (prevRight != 0) {
389  std::map<int, int> connections = (*j).getInnerConnections(OPENDRIVE_TAG_RIGHT, *(j - 1));
390  for (std::map<int, int>::const_iterator k = connections.begin(); k != connections.end(); ++k) {
391  prevRight->addLane2LaneConnection((*k).first, currRight, (*k).second, NBEdge::L2L_VALIDATED);
392  }
393  }
394  prevRight = currRight;
395  }
396 
397  // build lanes to left
398  NBEdge* currLeft = 0;
399  if ((*j).leftLaneNumber > 0) {
400  currLeft = new NBEdge(id, sTo, sFrom, "", defaultSpeed, (*j).leftLaneNumber, priorityL,
402  if (!nb.getEdgeCont().insert(currLeft)) {
403  throw ProcessError("Could not add edge '" + currLeft->getID() + "'.");
404  }
405  lanesBuilt = true;
406  const std::vector<OpenDriveLane>& lanes = (*j).lanesByDir[OPENDRIVE_TAG_LEFT];
407  for (std::vector<OpenDriveLane>::const_iterator k = lanes.begin(); k != lanes.end(); ++k) {
408  std::map<int, int>::const_iterator lp = (*j).laneMap.find((*k).id);
409  if (lp != (*j).laneMap.end()) {
410  int sumoLaneIndex = lp->second;
411  NBEdge::Lane& sumoLane = currLeft->getLaneStruct(sumoLaneIndex);
412  const OpenDriveLane& odLane = *k;
413 
414  sumoLane.origID = e->id + " " + toString((*k).id);
415  sumoLane.speed = odLane.speed != 0 ? odLane.speed : tc.getSpeed(odLane.type);
416  sumoLane.permissions = tc.getPermissions(odLane.type);
417  sumoLane.width = myImportWidths && odLane.width != 0 ? odLane.width : tc.getWidth(odLane.type);
418  }
419  }
420  // connect lane sections
421  if (prevLeft != 0) {
422  std::map<int, int> connections = (*j).getInnerConnections(OPENDRIVE_TAG_LEFT, *(j - 1));
423  for (std::map<int, int>::const_iterator k = connections.begin(); k != connections.end(); ++k) {
424  currLeft->addLane2LaneConnection((*k).first, prevLeft, (*k).second, NBEdge::L2L_VALIDATED);
425  }
426  }
427  prevLeft = currLeft;
428  }
429  (*j).sumoID = id;
430 
431 
432  sB = sE;
433  sFrom = sTo;
434  }
435  if (!lanesBuilt) {
436  WRITE_WARNING("Edge '" + e->id + "' has no lanes.");
437  }
438  }
439 
440  // -------------------------
441  // connections building
442  // -------------------------
443  // generate explicit lane-to-lane connections
444  for (std::map<std::string, OpenDriveEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
445  setEdgeLinks2(*(*i).second, edges);
446  }
447  // compute connections across intersections, if any
448  std::vector<Connection> connections2;
449  for (std::map<std::string, OpenDriveEdge*>::iterator j = edges.begin(); j != edges.end(); ++j) {
450  const std::set<Connection>& conns = (*j).second->connections;
451 
452  for (std::set<Connection>::const_iterator i = conns.begin(); i != conns.end(); ++i) {
453  if (innerEdges.find((*i).fromEdge) != innerEdges.end()) {
454  // connections starting at inner edges are processed by starting from outer edges
455  continue;
456  }
457  if (innerEdges.find((*i).toEdge) != innerEdges.end()) {
458  buildConnectionsToOuter(*i, innerEdges, connections2);
459  } else {
460  connections2.push_back(*i);
461  }
462  }
463  }
464  // set connections
465  for (std::vector<Connection>::const_iterator i = connections2.begin(); i != connections2.end(); ++i) {
466  std::string fromEdge = (*i).fromEdge;
467  if (edges.find(fromEdge) == edges.end()) {
468  WRITE_WARNING("While setting connections: from-edge '" + fromEdge + "' is not known.");
469  continue;
470  }
471  OpenDriveEdge* odFrom = edges[fromEdge];
472  int fromLane = (*i).fromLane;
473  bool fromLast = ((*i).fromCP == OPENDRIVE_CP_END) ^ ((*i).fromLane > 0 && !(*i).all);
474  fromEdge = fromLast ? odFrom->laneSections.back().sumoID : odFrom->laneSections[0].sumoID;
475 
476  std::string toEdge = (*i).toEdge;
477  if (edges.find(toEdge) == edges.end()) {
478  WRITE_WARNING("While setting connections: to-edge '" + toEdge + "' is not known.");
479  continue;
480  }
481 
482  OpenDriveEdge* odTo = edges[toEdge];
483  int toLane = (*i).toLane;
484  bool toLast = ((*i).toCP == OPENDRIVE_CP_END) || ((*i).toLane > 0);
485  toEdge = toLast ? odTo->laneSections.back().sumoID : odTo->laneSections[0].sumoID;
486 
487  if (fromLane == UNSET_CONNECTION) {
488  fromLane = toLast ? odTo->laneSections.back().laneMap.begin()->first : odTo->laneSections[0].laneMap.begin()->first;
489  }
490  if (fromLane < 0) {
491  fromEdge = revertID(fromEdge);
492  }
493  if (toLane == UNSET_CONNECTION) {
494  toLane = toLast ? odTo->laneSections.back().laneMap.begin()->first : odTo->laneSections[0].laneMap.begin()->first;
495  }
496  if (toLane < 0) {
497  toEdge = revertID(toEdge);
498  }
499  fromLane = fromLast ? odFrom->laneSections.back().laneMap[fromLane] : odFrom->laneSections[0].laneMap[fromLane];
500  toLane = toLast ? odTo->laneSections.back().laneMap[toLane] : odTo->laneSections[0].laneMap[toLane];
501  NBEdge* from = nb.getEdgeCont().retrieve(fromEdge);
502  NBEdge* to = nb.getEdgeCont().retrieve(toEdge);
503  if (from == 0) {
504  WRITE_WARNING("Could not find fromEdge representation of '" + fromEdge + "' in connection '" + (*i).origID + "'.");
505  }
506  if (to == 0) {
507  WRITE_WARNING("Could not find fromEdge representation of '" + toEdge + "' in connection '" + (*i).origID + "'.");
508  }
509  if (from == 0 || to == 0) {
510  continue;
511  }
512 
513  from->addLane2LaneConnection(fromLane, to, toLane, NBEdge::L2L_USER);
514 
515  if ((*i).origID != "") {
516  // @todo: this is the most silly way to determine the connection
517  std::vector<NBEdge::Connection>& cons = from->getConnections();
518  for (std::vector<NBEdge::Connection>::iterator k = cons.begin(); k != cons.end(); ++k) {
519  if ((*k).fromLane == fromLane && (*k).toEdge == to && (*k).toLane == toLane) {
520  (*k).origID = (*i).origID + " " + toString((*i).origLane);
521  break;
522  }
523  }
524  }
525  }
526 
527 
528  // -------------------------
529  // traffic lights
530  // -------------------------
531  std::map<std::string, std::string> tlsControlled;
532  for (std::map<std::string, OpenDriveEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
533  OpenDriveEdge* e = (*i).second;
534  for (std::vector<OpenDriveSignal>::const_iterator j = e->signals.begin(); j != e->signals.end(); ++j) {
535  if ((*j).type != "1000001") {
536  continue;
537  }
538  std::vector<OpenDriveLaneSection>::iterator k = e->laneSections.begin();
539  bool found = false;
540  for (; k != e->laneSections.end() - 1 && !found;) {
541  if ((*j).s > (*k).s && (*j).s <= (*(k + 1)).s) {
542  found = true;
543  } else {
544  ++k;
545  }
546  }
547 
548  // @todo: major problem, currently, still not completely solved:
549  // inner edges may have traffic lights, too. Nice on one hand, as directions can be recognized
550  // but hard to follow backwards
551  std::string id = (*k).sumoID;
552  if (id == "") {
553  if (e->junction != "") {
554  //WRITE_WARNING("Found a traffic light signal on an internal edge; will not build it (original edge id='" + e->id + "').");
555  std::string fromID, toID;
556  for (std::vector<OpenDriveLink>::const_iterator l = e->links.begin(); l != e->links.end(); ++l) {
557  if ((*l).linkType == OPENDRIVE_LT_PREDECESSOR && (*l).elementType == OPENDRIVE_ET_ROAD) {
558  if (fromID != "") {
559  WRITE_WARNING("Ambigous start of connection.");
560  }
561  fromID = (*l).elementID;
562  OpenDriveEdge* e = edges[fromID];
563  fromID = (*l).contactPoint == OPENDRIVE_CP_START ? e->laneSections[0].sumoID : e->laneSections.back().sumoID;
564  }
565  if ((*l).linkType == OPENDRIVE_LT_SUCCESSOR && (*l).elementType == OPENDRIVE_ET_ROAD) {
566  if (toID != "") {
567  WRITE_WARNING("Ambigous end of connection.");
568  }
569  toID = (*l).elementID;
570  OpenDriveEdge* e = edges[toID];
571  toID = (*l).contactPoint == OPENDRIVE_CP_START ? e->laneSections[0].sumoID : e->laneSections.back().sumoID;
572  }
573  }
574  id = fromID + "->" + toID;
575  } else {
576  WRITE_WARNING("Found a traffic light signal on an unknown edge (original edge id='" + e->id + "').");
577  continue;
578  }
579  }
580 
581  if ((*j).orientation > 0) {
582  id = "-" + id;
583  }
584  tlsControlled[id] = (*j).name;
585  }
586  }
587 
588  for (std::map<std::string, std::string>::iterator i = tlsControlled.begin(); i != tlsControlled.end(); ++i) {
589  std::string id = (*i).first;
590  if (id.find("->") != std::string::npos) {
591  id = id.substr(0, id.find("->"));
592  }
593  NBEdge* e = nb.getEdgeCont().retrieve(id);
594  if (e == 0) {
595  WRITE_WARNING("Could not find edge '" + id + "' while building its traffic light.");
596  continue;
597  }
598  NBNode* toNode = e->getToNode();
599  NBTrafficLightDefinition* tlDef = 0;
600  if (!toNode->isTLControlled()) {
602  tlDef = new NBOwnTLDef(toNode->getID(), toNode, 0, type);
603  if (!nb.getTLLogicCont().insert(tlDef)) {
604  // actually, nothing should fail here
605  delete tlDef;
606  throw ProcessError();
607  }
608  toNode->addTrafficLight(tlDef);
609  static_cast<NBOwnTLDef*>(tlDef)->setSinglePhase();
610  }
611  tlDef = *toNode->getControllingTLS().begin();
612  tlDef->addParameter("connection:" + id, (*i).second);
613  }
614 
615  // -------------------------
616  // clean up
617  // -------------------------
618  if (oc.exists("geometry.min-dist") && oc.isSet("geometry.min-dist")) {
619  oc.unSet("geometry.min-dist");
620  }
621  for (std::map<std::string, OpenDriveEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
622  delete(*i).second;
623  }
624 }
625 
626 
627 
628 void
629 NIImporter_OpenDrive::buildConnectionsToOuter(const Connection& c, const std::map<std::string, OpenDriveEdge*>& innerEdges, std::vector<Connection>& into) {
630 
631  OpenDriveEdge* dest = innerEdges.find(c.toEdge)->second;
632  if (dest == 0) {
634  return;
635  }
636  const std::set<Connection>& conts = dest->connections;
637  for (std::set<Connection>::const_iterator i = conts.begin(); i != conts.end(); ++i) {
638  if (innerEdges.find((*i).toEdge) != innerEdges.end()) {
639  std::vector<Connection> t;
640  buildConnectionsToOuter(*i, innerEdges, t);
641  for (std::vector<Connection>::const_iterator j = t.begin(); j != t.end(); ++j) {
642  // @todo this section is unverified
643  Connection cn = (*j);
644  cn.fromEdge = c.fromEdge;
645  cn.fromLane = c.fromLane;
646  cn.fromCP = c.fromCP;
647  cn.all = c.all; // @todo "all" is a hack trying to avoid the "from is zero" problem;
648  into.push_back(cn);
649  }
650  } else {
651  if ((*i).fromLane == c.toLane) {
652  Connection cn = (*i);
653  cn.fromEdge = c.fromEdge;
654  cn.fromLane = c.fromLane;
655  cn.fromCP = c.fromCP;
656  cn.all = c.all;
657  cn.origID = c.toEdge;
658  cn.origLane = c.toLane;
659  into.push_back(cn);
660  }
661  }
662  }
663 }
664 
665 
666 void
667 NIImporter_OpenDrive::setEdgeLinks2(OpenDriveEdge& e, const std::map<std::string, OpenDriveEdge*>& edges) {
668  for (std::vector<OpenDriveLink>::iterator i = e.links.begin(); i != e.links.end(); ++i) {
669  OpenDriveLink& l = *i;
670  if (l.elementType != OPENDRIVE_ET_ROAD) {
671  // we assume that links to nodes are later given as connections to edges
672  continue;
673  }
674  // get the right direction of the connected edge
675  std::string connectedEdge = l.elementID;
676  std::string edgeID = e.id;
677 
678  OpenDriveLaneSection& laneSection = l.linkType == OPENDRIVE_LT_SUCCESSOR ? e.laneSections.back() : e.laneSections[0];
679  const std::map<int, int>& laneMap = laneSection.laneMap;
680  if (laneSection.lanesByDir.find(OPENDRIVE_TAG_RIGHT) != laneSection.lanesByDir.end()) {
681  const std::vector<OpenDriveLane>& lanes = laneSection.lanesByDir.find(OPENDRIVE_TAG_RIGHT)->second;
682  for (std::vector<OpenDriveLane>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
683  if (!myImportAllTypes && laneMap.find((*j).id) == laneMap.end()) {
684  continue;
685  }
686  Connection c; // @todo: give Connection a new name and a constructor
687  c.fromEdge = e.id;
688  c.fromLane = (*j).id;
690  c.toLane = l.linkType == OPENDRIVE_LT_SUCCESSOR ? (*j).successor : (*j).predecessor;
691  c.toEdge = connectedEdge;
692  c.toCP = l.contactPoint;
693  c.all = false;
694  if (l.linkType != OPENDRIVE_LT_SUCCESSOR) {
695  std::swap(c.fromEdge, c.toEdge);
696  std::swap(c.fromLane, c.toLane);
697  std::swap(c.fromCP, c.toCP);
698  }
699  if (edges.find(c.fromEdge) == edges.end()) {
700  WRITE_ERROR("While setting connections: incoming road '" + c.fromEdge + "' is not known.");
701  } else {
702  OpenDriveEdge* src = edges.find(c.fromEdge)->second;
703  src->connections.insert(c);
704  }
705  }
706  }
707  if (laneSection.lanesByDir.find(OPENDRIVE_TAG_LEFT) != laneSection.lanesByDir.end()) {
708  const std::vector<OpenDriveLane>& lanes = laneSection.lanesByDir.find(OPENDRIVE_TAG_LEFT)->second;
709  for (std::vector<OpenDriveLane>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
710  if (!myImportAllTypes && laneMap.find((*j).id) == laneMap.end()) {
711  continue;
712  }
713  Connection c;
714  c.toEdge = e.id;
715  c.toLane = (*j).id;
717  c.fromLane = l.linkType == OPENDRIVE_LT_SUCCESSOR ? (*j).successor : (*j).predecessor;
718  c.fromEdge = connectedEdge;
719  c.fromCP = l.contactPoint;
720  c.all = false;
721  if (l.linkType != OPENDRIVE_LT_SUCCESSOR) {
722  std::swap(c.fromEdge, c.toEdge);
723  std::swap(c.fromLane, c.toLane);
724  std::swap(c.fromCP, c.toCP);
725  }
726  if (edges.find(c.fromEdge) == edges.end()) {
727  WRITE_ERROR("While setting connections: incoming road '" + c.fromEdge + "' is not known.");
728  } else {
729  OpenDriveEdge* src = edges.find(c.fromEdge)->second;
730  src->connections.insert(c);
731  }
732  }
733  }
734  }
735 }
736 
737 
738 std::string NIImporter_OpenDrive::revertID(const std::string& id) {
739  if (id[0] == '-') {
740  return id.substr(1);
741  }
742  return "-" + id;
743 }
744 
745 NBNode*
746 NIImporter_OpenDrive::getOrBuildNode(const std::string& id, const Position& pos,
747  NBNodeCont& nc) {
748  if (nc.retrieve(id) == 0) {
749  // not yet built; build now
750  if (!nc.insert(id, pos)) {
751  // !!! clean up
752  throw ProcessError("Could not add node '" + id + "'.");
753  }
754  }
755  return nc.retrieve(id);
756 }
757 
758 
759 void
761  const std::string& nodeID, NIImporter_OpenDrive::LinkType lt) {
762  NBNode* n = nc.retrieve(nodeID);
763  if (n == 0) {
764  throw ProcessError("Could not find node '" + nodeID + "'.");
765  }
766  if (lt == OPENDRIVE_LT_SUCCESSOR) {
767  if (e.to != 0 && e.to != n) {
768  throw ProcessError("Edge '" + e.id + "' has two end nodes.");
769  }
770  e.to = n;
771  } else {
772  if (e.from != 0 && e.from != n) {
773  throw ProcessError("Edge '" + e.id + "' has two start nodes.");
774  }
775  e.from = n;
776  }
777 }
778 
779 
780 
781 
782 
783 
784 
785 void
786 NIImporter_OpenDrive::computeShapes(std::map<std::string, OpenDriveEdge*>& edges) {
788  for (std::map<std::string, OpenDriveEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
789  OpenDriveEdge& e = *(*i).second;
790  for (std::vector<OpenDriveGeometry>::iterator j = e.geometries.begin(); j != e.geometries.end(); ++j) {
791  OpenDriveGeometry& g = *j;
792  std::vector<Position> geom;
793  switch (g.type) {
795  break;
796  case OPENDRIVE_GT_LINE:
797  geom = geomFromLine(e, g);
798  break;
799  case OPENDRIVE_GT_SPIRAL:
800  geom = geomFromSpiral(e, g);
801  break;
802  case OPENDRIVE_GT_ARC:
803  geom = geomFromArc(e, g);
804  break;
805  case OPENDRIVE_GT_POLY3:
806  geom = geomFromPoly(e, g);
807  break;
808  default:
809  break;
810  }
811  for (std::vector<Position>::iterator k = geom.begin(); k != geom.end(); ++k) {
813  }
814  }
815  if (oc.exists("geometry.min-dist") && oc.isSet("geometry.min-dist")) {
816  e.geom.removeDoublePoints(oc.getFloat("geometry.min-dist"), true);
817  }
818  for (unsigned int j = 0; j < e.geom.size(); ++j) {
820  WRITE_ERROR("Unable to project coordinates for.");
821  }
822  }
823  }
824 }
825 
826 
827 void
828 NIImporter_OpenDrive::revisitLaneSections(const NBTypeCont& tc, std::map<std::string, OpenDriveEdge*>& edges) {
829  for (std::map<std::string, OpenDriveEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
830  OpenDriveEdge& e = *(*i).second;
831  std::vector<OpenDriveLaneSection>& laneSections = e.laneSections;
832  // split by speed limits
833  std::vector<OpenDriveLaneSection> newSections;
834  for (std::vector<OpenDriveLaneSection>::iterator j = laneSections.begin(); j != laneSections.end(); ++j) {
835  std::vector<OpenDriveLaneSection> splitSections;
836  bool splitBySpeed = (*j).buildSpeedChanges(tc, splitSections);
837  if (!splitBySpeed) {
838  newSections.push_back(*j);
839  } else {
840  std::copy(splitSections.begin(), splitSections.end(), back_inserter(newSections));
841  }
842  }
843 
844  e.laneSections = newSections;
845  laneSections = e.laneSections;
846  SUMOReal lastS = -1;
847  // check whether the lane sections are in the right order
848  bool sorted = true;
849  for (std::vector<OpenDriveLaneSection>::const_iterator j = laneSections.begin(); j != laneSections.end() && sorted; ++j) {
850  if ((*j).s <= lastS) {
851  sorted = false;
852  }
853  lastS = (*j).s;
854  }
855  if (!sorted) {
856  WRITE_WARNING("The sections of edge '" + e.id + "' are not sorted properly.");
857  sort(e.laneSections.begin(), e.laneSections.end(), sections_by_s_sorter());
858  }
859  // check whether no duplicates of s-value occure
860  lastS = -1;
861  laneSections = e.laneSections;
862  for (std::vector<OpenDriveLaneSection>::iterator j = laneSections.begin(); j != laneSections.end();) {
863  bool simlarToLast = fabs((*j).s - lastS) < POSITION_EPS;
864  lastS = (*j).s;
865  if (simlarToLast) {
866  WRITE_WARNING("Almost duplicate s-value '" + toString(lastS) + "' for lane sections occured at edge '" + e.id + "'; second entry was removed.");
867  j = laneSections.erase(j);
868  } else {
869  ++j;
870  }
871  }
872  }
873 }
874 
875 
876 std::vector<Position>
878  UNUSED_PARAMETER(e);
879  std::vector<Position> ret;
880  ret.push_back(Position(g.x, g.y));
881  ret.push_back(calculateStraightEndPoint(g.hdg, g.length, Position(g.x, g.y)));
882  return ret;
883 }
884 
885 
886 std::vector<Position>
888  UNUSED_PARAMETER(e);
889  std::vector<Position> ret;
890  SUMOReal curveStart = g.params[0];
891  SUMOReal curveEnd = g.params[1];
892  Point2D<double> end;
893  EulerSpiral s(Point2D<double>(g.x, g.y), g.hdg, curveStart, (curveEnd - curveStart) / g.length, g.length);
894  std::vector<Point2D<double> > into;
895  s.computeSpiral(into, 1.);
896  for (std::vector<Point2D<double> >::iterator i = into.begin(); i != into.end(); ++i) {
897  ret.push_back(Position((*i).getX(), (*i).getY()));
898  }
899  return ret;
900 }
901 
902 
903 std::vector<Position>
905  UNUSED_PARAMETER(e);
906  std::vector<Position> ret;
907  SUMOReal dist = 0.0;
908  SUMOReal centerX = g.x;
909  SUMOReal centerY = g.y;
910  // left: positive value
911  SUMOReal curvature = g.params[0];
912  SUMOReal radius = 1. / curvature;
913  // center point
914  calculateCurveCenter(&centerX, &centerY, radius, g.hdg);
915  SUMOReal endX = g.x;
916  SUMOReal endY = g.y;
917  SUMOReal startX = g.x;
918  SUMOReal startY = g.y;
919  SUMOReal geo_posS = g.s;
920  SUMOReal geo_posE = g.s;
921  bool end = false;
922  do {
923  geo_posE += C_LENGTH;
924  if (geo_posE - g.s > g.length) {
925  geo_posE = g.s + g.length;
926  }
927  if (geo_posE - g.s > g.length) {
928  geo_posE = g.s + g.length;
929  }
930  calcPointOnCurve(&endX, &endY, centerX, centerY, radius, geo_posE - geo_posS);
931 
932  dist += (geo_posE - geo_posS);
933  //
934  ret.push_back(Position(startX, startY));
935  //
936  startX = endX;
937  startY = endY;
938  geo_posS = geo_posE;
939 
940  if (geo_posE - (g.s + g.length) < 0.001 && geo_posE - (g.s + g.length) > -0.001) {
941  end = true;
942  }
943  } while (!end);
944  return ret;
945 }
946 
947 
948 std::vector<Position>
950  UNUSED_PARAMETER(e);
951  std::vector<Position> ret;
952  for (SUMOReal off = 0; off < g.length + 2.; off += 2.) {
953  SUMOReal x = off;
954  SUMOReal y = g.params[0] + g.params[1] * off + g.params[2] * pow(off, 2.) + g.params[3] * pow(off, 3.);
955  SUMOReal s = sin(g.hdg);
956  SUMOReal c = cos(g.hdg);
957  SUMOReal xnew = x * c - y * s;
958  SUMOReal ynew = x * s + y * c;
959  ret.push_back(Position(g.x + xnew, g.y + ynew));
960  }
961  return ret;
962 }
963 
964 
965 Position
966 NIImporter_OpenDrive::calculateStraightEndPoint(double hdg, double length, const Position& start) {
967  double normx = 1.0f;
968  double normy = 0.0f;
969  double x2 = normx * cos(hdg) - normy * sin(hdg);
970  double y2 = normx * sin(hdg) + normy * cos(hdg);
971  normx = x2 * length;
972  normy = y2 * length;
973  return Position(start.x() + normx, start.y() + normy);
974 }
975 
976 
977 void
979  SUMOReal normX = 1.0;
980  SUMOReal normY = 0.0;
981  SUMOReal tmpX;
982  SUMOReal turn;
983  if (ad_radius > 0) {
984  turn = -1.0;
985  } else {
986  turn = 1.0;
987  }
988 
989  tmpX = normX;
990  normX = normX * cos(ad_hdg) + normY * sin(ad_hdg);
991  normY = tmpX * sin(ad_hdg) + normY * cos(ad_hdg);
992 
993  tmpX = normX;
994  normX = turn * normY;
995  normY = -turn * tmpX;
996 
997  normX = fabs(ad_radius) * normX;
998  normY = fabs(ad_radius) * normY;
999 
1000  *ad_x += normX;
1001  *ad_y += normY;
1002 }
1003 
1004 
1005 void
1007  SUMOReal ad_r, SUMOReal ad_length) {
1008  double rotAngle = ad_length / fabs(ad_r);
1009  double vx = *ad_x - ad_centerX;
1010  double vy = *ad_y - ad_centerY;
1011  double tmpx;
1012 
1013  double turn;
1014  if (ad_r > 0) {
1015  turn = -1; //left
1016  } else {
1017  turn = 1; //right
1018  }
1019  tmpx = vx;
1020  vx = vx * cos(rotAngle) + turn * vy * sin(rotAngle);
1021  vy = -1 * turn * tmpx * sin(rotAngle) + vy * cos(rotAngle);
1022  *ad_x = vx + ad_centerX;
1023  *ad_y = vy + ad_centerY;
1024 }
1025 
1026 
1027 // ---------------------------------------------------------------------------
1028 // section
1029 // ---------------------------------------------------------------------------
1031  lanesByDir[OPENDRIVE_TAG_LEFT] = std::vector<OpenDriveLane>();
1032  lanesByDir[OPENDRIVE_TAG_RIGHT] = std::vector<OpenDriveLane>();
1033  lanesByDir[OPENDRIVE_TAG_CENTER] = std::vector<OpenDriveLane>();
1034 }
1035 
1036 
1037 void
1039  unsigned int sumoLane = 0;
1040  const std::vector<OpenDriveLane>& dirLanesR = lanesByDir.find(OPENDRIVE_TAG_RIGHT)->second;
1041  for (std::vector<OpenDriveLane>::const_reverse_iterator i = dirLanesR.rbegin(); i != dirLanesR.rend(); ++i) {
1042  if (myImportAllTypes || (tc.knows((*i).type) && !tc.getShallBeDiscarded((*i).type))) {
1043  laneMap[(*i).id] = sumoLane++;
1044  }
1045  }
1046  rightLaneNumber = sumoLane;
1047  sumoLane = 0;
1048  const std::vector<OpenDriveLane>& dirLanesL = lanesByDir.find(OPENDRIVE_TAG_LEFT)->second;
1049  for (std::vector<OpenDriveLane>::const_iterator i = dirLanesL.begin(); i != dirLanesL.end(); ++i) {
1050  if (myImportAllTypes || (tc.knows((*i).type) && !tc.getShallBeDiscarded((*i).type))) {
1051  laneMap[(*i).id] = sumoLane++;
1052  }
1053  }
1054  leftLaneNumber = sumoLane;
1055 }
1056 
1057 
1058 std::map<int, int>
1060  std::map<int, int> ret;
1061  const std::vector<OpenDriveLane>& dirLanes = lanesByDir.find(dir)->second;
1062  for (std::vector<OpenDriveLane>::const_reverse_iterator i = dirLanes.rbegin(); i != dirLanes.rend(); ++i) {
1063  std::map<int, int>::const_iterator toP = laneMap.find((*i).id);
1064  if (toP == laneMap.end()) {
1065  // the current lane is not available in SUMO
1066  continue;
1067  }
1068  int to = (*toP).second;
1069  int from = UNSET_CONNECTION;
1070  if ((*i).predecessor != UNSET_CONNECTION) {
1071  from = (*i).predecessor;
1072  }
1073  if (from != UNSET_CONNECTION) {
1074  std::map<int, int>::const_iterator fromP = prev.laneMap.find(from);
1075  if (fromP != prev.laneMap.end()) {
1076  from = (*fromP).second;
1077  } else {
1078  from = UNSET_CONNECTION;
1079  }
1080  }
1081  if (from != UNSET_CONNECTION && to != UNSET_CONNECTION) {
1082  if (ret.find(from) != ret.end()) {
1083 // WRITE_WARNING("double connection");
1084  }
1085  if (dir == OPENDRIVE_TAG_LEFT) {
1086  std::swap(from, to);
1087  }
1088  ret[from] = to;
1089  } else {
1090 // WRITE_WARNING("missing connection");
1091  }
1092  }
1093  return ret;
1094 }
1095 
1096 
1099  OpenDriveLaneSection ret(*this);
1100  ret.s += startPos;
1101  for (unsigned int k = 0; k != ret.lanesByDir[OPENDRIVE_TAG_RIGHT].size(); ++k) {
1103  l.speed = 0;
1104  std::vector<std::pair<SUMOReal, SUMOReal> >::const_iterator i = std::find_if(l.speeds.begin(), l.speeds.end(), same_position_finder(startPos));
1105  if (i != l.speeds.end()) {
1106  l.speed = (*i).second;
1107  }
1108  }
1109  for (unsigned int k = 0; k != ret.lanesByDir[OPENDRIVE_TAG_LEFT].size(); ++k) {
1111  std::vector<std::pair<SUMOReal, SUMOReal> >::const_iterator i = std::find_if(l.speeds.begin(), l.speeds.end(), same_position_finder(startPos));
1112  l.speed = 0;
1113  if (i != l.speeds.end()) {
1114  l.speed = (*i).second;
1115  }
1116  }
1117  return ret;
1118 }
1119 
1120 
1121 bool
1122 NIImporter_OpenDrive::OpenDriveLaneSection::buildSpeedChanges(const NBTypeCont& tc, std::vector<OpenDriveLaneSection>& newSections) {
1123  std::set<SUMOReal> speedChangePositions;
1124  // collect speed change positions and apply initial speed to the begin
1125  for (std::vector<OpenDriveLane>::iterator k = lanesByDir[OPENDRIVE_TAG_RIGHT].begin(); k != lanesByDir[OPENDRIVE_TAG_RIGHT].end(); ++k) {
1126  for (std::vector<std::pair<SUMOReal, SUMOReal> >::const_iterator l = (*k).speeds.begin(); l != (*k).speeds.end(); ++l) {
1127  speedChangePositions.insert((*l).first);
1128  if ((*l).first == 0) {
1129  (*k).speed = (*l).second;
1130  }
1131  }
1132  }
1133  for (std::vector<OpenDriveLane>::iterator k = lanesByDir[OPENDRIVE_TAG_LEFT].begin(); k != lanesByDir[OPENDRIVE_TAG_LEFT].end(); ++k) {
1134  for (std::vector<std::pair<SUMOReal, SUMOReal> >::const_iterator l = (*k).speeds.begin(); l != (*k).speeds.end(); ++l) {
1135  speedChangePositions.insert((*l).first);
1136  if ((*l).first == 0) {
1137  (*k).speed = (*l).second;
1138  }
1139  }
1140  }
1141  // do nothing if there is none
1142  if (speedChangePositions.size() == 0) {
1143  return false;
1144  }
1145  if (*speedChangePositions.begin() > 0) {
1146  speedChangePositions.insert(0);
1147  }
1148  //
1149  for (std::set<SUMOReal>::iterator i = speedChangePositions.begin(); i != speedChangePositions.end(); ++i) {
1150  if (i == speedChangePositions.begin()) {
1151  newSections.push_back(*this);
1152  } else {
1153  newSections.push_back(buildLaneSection(*i));
1154  }
1155  }
1156  // propagate speeds
1157  for (int i = 0; i != (int)newSections.size(); ++i) {
1158  OpenDriveLaneSection& ls = newSections[i];
1159  std::map<OpenDriveXMLTag, std::vector<OpenDriveLane> >& lanesByDir = ls.lanesByDir;
1160  for (std::map<OpenDriveXMLTag, std::vector<OpenDriveLane> >::iterator k = lanesByDir.begin(); k != lanesByDir.end(); ++k) {
1161  std::vector<OpenDriveLane>& lanes = (*k).second;
1162  for (int j = 0; j != (int)lanes.size(); ++j) {
1163  OpenDriveLane& l = lanes[j];
1164  if (l.speed != 0) {
1165  continue;
1166  }
1167  if (i > 0) {
1168  l.speed = newSections[i - 1].lanesByDir[(*k).first][j].speed;
1169  } else {
1170  tc.getSpeed(l.type);
1171  }
1172  }
1173  }
1174  }
1175  return true;
1176 }
1177 
1178 
1179 
1180 // ---------------------------------------------------------------------------
1181 // edge
1182 // ---------------------------------------------------------------------------
1183 int
1185  int prio = 1;
1186  for (std::vector<OpenDriveSignal>::const_iterator i = signals.begin(); i != signals.end(); ++i) {
1187  int tmp = 1;
1188  if ((*i).type == "301" || (*i).type == "306") {
1189  tmp = 2;
1190  }
1191  if ((*i).type == "205") {
1192  tmp = 0;
1193  }
1194  if (tmp != 1 && dir == OPENDRIVE_TAG_RIGHT && (*i).orientation > 0) {
1195  prio = tmp;
1196  }
1197  if (tmp != 1 && dir == OPENDRIVE_TAG_LEFT && (*i).orientation < 0) {
1198  prio = tmp;
1199  }
1200 
1201  }
1202  return prio;
1203 }
1204 
1205 
1206 
1207 // ---------------------------------------------------------------------------
1208 // loader methods
1209 // ---------------------------------------------------------------------------
1210 NIImporter_OpenDrive::NIImporter_OpenDrive(const NBTypeCont& tc, std::map<std::string, OpenDriveEdge*>& edges)
1212  myTypeContainer(tc), myCurrentEdge("", "", -1), myEdges(edges) {
1213 }
1214 
1215 
1217 }
1218 
1219 
1220 void
1222  const SUMOSAXAttributes& attrs) {
1223  bool ok = true;
1224  switch (element) {
1225  case OPENDRIVE_TAG_HEADER: {
1226  int majorVersion = attrs.get<int>(OPENDRIVE_ATTR_REVMAJOR, 0, ok);
1227  int minorVersion = attrs.get<int>(OPENDRIVE_ATTR_REVMINOR, 0, ok);
1228  if (majorVersion != 1 || minorVersion != 2) {
1229  WRITE_WARNING("Given openDrive file '" + getFileName() + "' uses version " + toString(majorVersion) + "." + toString(minorVersion) + ";\n Version 1.2 is supported.");
1230  }
1231  }
1232  break;
1233  case OPENDRIVE_TAG_ROAD: {
1234  std::string id = attrs.get<std::string>(OPENDRIVE_ATTR_ID, 0, ok);
1235  std::string junction = attrs.get<std::string>(OPENDRIVE_ATTR_JUNCTION, id.c_str(), ok);
1236  SUMOReal length = attrs.get<SUMOReal>(OPENDRIVE_ATTR_LENGTH, id.c_str(), ok);
1237  myCurrentEdge = OpenDriveEdge(id, junction, length);
1238  }
1239  break;
1241  if (myElementStack.size() >= 2 && myElementStack[myElementStack.size() - 2] == OPENDRIVE_TAG_ROAD) {
1242  std::string elementType = attrs.get<std::string>(OPENDRIVE_ATTR_ELEMENTTYPE, myCurrentEdge.id.c_str(), ok);
1243  std::string elementID = attrs.get<std::string>(OPENDRIVE_ATTR_ELEMENTID, myCurrentEdge.id.c_str(), ok);
1244  std::string contactPoint = attrs.hasAttribute(OPENDRIVE_ATTR_CONTACTPOINT)
1245  ? attrs.get<std::string>(OPENDRIVE_ATTR_CONTACTPOINT, myCurrentEdge.id.c_str(), ok)
1246  : "end";
1247  addLink(OPENDRIVE_LT_PREDECESSOR, elementType, elementID, contactPoint);
1248  }
1249  if (myElementStack.size() >= 2 && myElementStack[myElementStack.size() - 2] == OPENDRIVE_TAG_LANE) {
1250  int no = attrs.get<int>(OPENDRIVE_ATTR_ID, myCurrentEdge.id.c_str(), ok);
1251  OpenDriveLane& l = myCurrentEdge.laneSections.back().lanesByDir[myCurrentLaneDirection].back();
1252  l.predecessor = no;
1253  }
1254  }
1255  break;
1256  case OPENDRIVE_TAG_SUCCESSOR: {
1257  if (myElementStack.size() >= 2 && myElementStack[myElementStack.size() - 2] == OPENDRIVE_TAG_ROAD) {
1258  std::string elementType = attrs.get<std::string>(OPENDRIVE_ATTR_ELEMENTTYPE, myCurrentEdge.id.c_str(), ok);
1259  std::string elementID = attrs.get<std::string>(OPENDRIVE_ATTR_ELEMENTID, myCurrentEdge.id.c_str(), ok);
1260  std::string contactPoint = attrs.hasAttribute(OPENDRIVE_ATTR_CONTACTPOINT)
1261  ? attrs.get<std::string>(OPENDRIVE_ATTR_CONTACTPOINT, myCurrentEdge.id.c_str(), ok)
1262  : "start";
1263  addLink(OPENDRIVE_LT_SUCCESSOR, elementType, elementID, contactPoint);
1264  }
1265  if (myElementStack.size() >= 2 && myElementStack[myElementStack.size() - 2] == OPENDRIVE_TAG_LANE) {
1266  int no = attrs.get<int>(OPENDRIVE_ATTR_ID, myCurrentEdge.id.c_str(), ok);
1267  OpenDriveLane& l = myCurrentEdge.laneSections.back().lanesByDir[myCurrentLaneDirection].back();
1268  l.successor = no;
1269  }
1270  }
1271  break;
1272  case OPENDRIVE_TAG_GEOMETRY: {
1273  SUMOReal length = attrs.get<SUMOReal>(OPENDRIVE_ATTR_LENGTH, myCurrentEdge.id.c_str(), ok);
1274  SUMOReal s = attrs.get<SUMOReal>(OPENDRIVE_ATTR_S, myCurrentEdge.id.c_str(), ok);
1275  SUMOReal x = attrs.get<SUMOReal>(OPENDRIVE_ATTR_X, myCurrentEdge.id.c_str(), ok);
1276  SUMOReal y = attrs.get<SUMOReal>(OPENDRIVE_ATTR_Y, myCurrentEdge.id.c_str(), ok);
1277  SUMOReal hdg = attrs.get<SUMOReal>(OPENDRIVE_ATTR_HDG, myCurrentEdge.id.c_str(), ok);
1278  myCurrentEdge.geometries.push_back(OpenDriveGeometry(length, s, x, y, hdg));
1279  }
1280  break;
1281  case OPENDRIVE_TAG_LINE: {
1282  std::vector<SUMOReal> vals;
1284  }
1285  break;
1286  case OPENDRIVE_TAG_SPIRAL: {
1287  std::vector<SUMOReal> vals;
1288  vals.push_back(attrs.get<SUMOReal>(OPENDRIVE_ATTR_CURVSTART, myCurrentEdge.id.c_str(), ok));
1289  vals.push_back(attrs.get<SUMOReal>(OPENDRIVE_ATTR_CURVEND, myCurrentEdge.id.c_str(), ok));
1291  }
1292  break;
1293  case OPENDRIVE_TAG_ARC: {
1294  std::vector<SUMOReal> vals;
1295  vals.push_back(attrs.get<SUMOReal>(OPENDRIVE_ATTR_CURVATURE, myCurrentEdge.id.c_str(), ok));
1297  }
1298  break;
1299  case OPENDRIVE_TAG_POLY3: {
1300  std::vector<SUMOReal> vals;
1301  vals.push_back(attrs.get<SUMOReal>(OPENDRIVE_ATTR_A, myCurrentEdge.id.c_str(), ok));
1302  vals.push_back(attrs.get<SUMOReal>(OPENDRIVE_ATTR_B, myCurrentEdge.id.c_str(), ok));
1303  vals.push_back(attrs.get<SUMOReal>(OPENDRIVE_ATTR_C, myCurrentEdge.id.c_str(), ok));
1304  vals.push_back(attrs.get<SUMOReal>(OPENDRIVE_ATTR_D, myCurrentEdge.id.c_str(), ok));
1306  }
1307  break;
1309  SUMOReal s = attrs.get<SUMOReal>(OPENDRIVE_ATTR_S, myCurrentEdge.id.c_str(), ok);
1311  }
1312  break;
1313  case OPENDRIVE_TAG_LEFT:
1315  break;
1316  case OPENDRIVE_TAG_CENTER:
1318  break;
1319  case OPENDRIVE_TAG_RIGHT:
1321  break;
1322  case OPENDRIVE_TAG_LANE: {
1323  std::string type = attrs.get<std::string>(OPENDRIVE_ATTR_TYPE, myCurrentEdge.id.c_str(), ok);
1324  int id = attrs.get<int>(OPENDRIVE_ATTR_ID, myCurrentEdge.id.c_str(), ok);
1325  std::string level = attrs.hasAttribute(OPENDRIVE_ATTR_LEVEL)
1326  ? attrs.get<std::string>(OPENDRIVE_ATTR_LEVEL, myCurrentEdge.id.c_str(), ok)
1327  : "";
1329  ls.lanesByDir[myCurrentLaneDirection].push_back(OpenDriveLane(id, level, type));
1330  }
1331  break;
1332  case OPENDRIVE_TAG_SIGNAL: {
1333  int id = attrs.get<int>(OPENDRIVE_ATTR_ID, myCurrentEdge.id.c_str(), ok);
1334  std::string type = attrs.get<std::string>(OPENDRIVE_ATTR_TYPE, myCurrentEdge.id.c_str(), ok);
1335  std::string name = attrs.getOpt<std::string>(OPENDRIVE_ATTR_NAME, myCurrentEdge.id.c_str(), ok, "", false);
1336  int orientation = attrs.get<std::string>(OPENDRIVE_ATTR_ORIENTATION, myCurrentEdge.id.c_str(), ok) == "-" ? -1 : 1;
1337  SUMOReal s = attrs.get<SUMOReal>(OPENDRIVE_ATTR_S, myCurrentEdge.id.c_str(), ok);
1338  bool dynamic = attrs.get<std::string>(OPENDRIVE_ATTR_DYNAMIC, myCurrentEdge.id.c_str(), ok) == "no" ? false : true;
1339  myCurrentEdge.signals.push_back(OpenDriveSignal(id, type, name, orientation, dynamic, s));
1340  }
1341  break;
1343  myCurrentJunctionID = attrs.get<std::string>(OPENDRIVE_ATTR_ID, myCurrentJunctionID.c_str(), ok);
1344  break;
1345  case OPENDRIVE_TAG_CONNECTION: {
1346  std::string id = attrs.get<std::string>(OPENDRIVE_ATTR_ID, myCurrentJunctionID.c_str(), ok);
1347  myCurrentIncomingRoad = attrs.get<std::string>(OPENDRIVE_ATTR_INCOMINGROAD, myCurrentJunctionID.c_str(), ok);
1349  std::string cp = attrs.get<std::string>(OPENDRIVE_ATTR_CONTACTPOINT, myCurrentJunctionID.c_str(), ok);
1351  myConnectionWasEmpty = true;
1352  }
1353  break;
1354  case OPENDRIVE_TAG_LANELINK: {
1355  int from = attrs.get<int>(OPENDRIVE_ATTR_FROM, myCurrentJunctionID.c_str(), ok);
1356  int to = attrs.get<int>(OPENDRIVE_ATTR_TO, myCurrentJunctionID.c_str(), ok);
1357  Connection c;
1359  c.toEdge = myCurrentConnectingRoad;
1360  c.fromLane = from;
1361  c.toLane = to;
1362  c.fromCP = OPENDRIVE_CP_END;
1363  c.toCP = myCurrentContactPoint;
1364  c.all = false;
1365  if (myEdges.find(c.fromEdge) == myEdges.end()) {
1366  WRITE_ERROR("In laneLink-element: incoming road '" + c.fromEdge + "' is not known.");
1367  } else {
1368  OpenDriveEdge* e = myEdges.find(c.fromEdge)->second;
1369  e->connections.insert(c);
1370  myConnectionWasEmpty = false;
1371  }
1372  }
1373  break;
1374  case OPENDRIVE_TAG_WIDTH: {
1375  if (myElementStack.size() >= 2 && myElementStack[myElementStack.size() - 1] == OPENDRIVE_TAG_LANE) {
1376  SUMOReal width = attrs.get<SUMOReal>(OPENDRIVE_ATTR_A, myCurrentEdge.id.c_str(), ok);
1377  OpenDriveLane& l = myCurrentEdge.laneSections.back().lanesByDir[myCurrentLaneDirection].back();
1378  l.width = MAX2(l.width, width);
1379  }
1380  }
1381  break;
1382  case OPENDRIVE_TAG_SPEED: {
1383  if (myElementStack.size() >= 2 && myElementStack[myElementStack.size() - 1] == OPENDRIVE_TAG_LANE) {
1384  SUMOReal speed = attrs.get<SUMOReal>(OPENDRIVE_ATTR_MAX, myCurrentEdge.id.c_str(), ok);
1385  SUMOReal pos = attrs.get<SUMOReal>(OPENDRIVE_ATTR_SOFFSET, myCurrentEdge.id.c_str(), ok);
1386  myCurrentEdge.laneSections.back().lanesByDir[myCurrentLaneDirection].back().speeds.push_back(std::make_pair(pos, speed));
1387  }
1388  }
1389  break;
1390  default:
1391  break;
1392  }
1393  myElementStack.push_back(element);
1394 }
1395 
1396 
1397 void
1399  myElementStack.pop_back();
1400  switch (element) {
1401  case OPENDRIVE_TAG_ROAD:
1403  break;
1405  if (myConnectionWasEmpty) {
1406  Connection c;
1409  c.fromLane = 0;
1410  c.toLane = 0;
1413  c.all = true;
1414  if (myEdges.find(c.fromEdge) == myEdges.end()) {
1415  WRITE_ERROR("In laneLink-element: incoming road '" + c.fromEdge + "' is not known.");
1416  } else {
1417  OpenDriveEdge* e = myEdges.find(c.fromEdge)->second;
1418  e->connections.insert(c);
1419  }
1420  }
1421  break;
1423  myCurrentEdge.laneSections.back().buildLaneMapping(myTypeContainer);
1424  }
1425  break;
1426  default:
1427  break;
1428  }
1429 }
1430 
1431 
1432 
1433 void
1434 NIImporter_OpenDrive::addLink(LinkType lt, const std::string& elementType,
1435  const std::string& elementID,
1436  const std::string& contactPoint) {
1437  OpenDriveLink l(lt, elementID);
1438  // elementType
1439  if (elementType == "road") {
1441  } else if (elementType == "junction") {
1443  }
1444  // contact point
1445  if (contactPoint == "start") {
1447  } else if (contactPoint == "end") {
1449  }
1450  // add
1451  myCurrentEdge.links.push_back(l);
1452 }
1453 
1454 
1455 void
1456 NIImporter_OpenDrive::addGeometryShape(GeometryType type, const std::vector<SUMOReal>& vals) {
1457  // checks
1458  if (myCurrentEdge.geometries.size() == 0) {
1459  throw ProcessError("Mismatching paranthesis in geometry definition for road '" + myCurrentEdge.id + "'");
1460  }
1462  if (last.type != OPENDRIVE_GT_UNKNOWN) {
1463  throw ProcessError("Double geometry information for road '" + myCurrentEdge.id + "'");
1464  }
1465  // set
1466  last.type = type;
1467  last.params = vals;
1468 }
1469 
1470 
1471 bool
1473  if (c1.fromEdge != c2.fromEdge) {
1474  return c1.fromEdge < c2.fromEdge;
1475  }
1476  if (c1.toEdge != c2.toEdge) {
1477  return c1.toEdge < c2.toEdge;
1478  }
1479  if (c1.fromLane != c2.fromLane) {
1480  return c1.fromLane < c2.fromLane;
1481  }
1482  return c1.toLane < c2.toLane;
1483 }
1484 
1485 
1486 
1487 /****************************************************************************/
1488 
std::map< std::string, OpenDriveEdge * > & myEdges
static void calculateCurveCenter(SUMOReal *ad_x, SUMOReal *ad_y, SUMOReal ad_radius, SUMOReal ad_hdg)
std::vector< int > myElementStack
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:203
static StringBijection< int >::Entry openDriveAttrs[]
The names of openDrive-XML attributes (for passing to GenericSAXHandler)
NBTypeCont & getTypeCont()
Returns the type container.
Definition: NBNetBuilder.h:170
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
PositionVector getSubpart2D(SUMOReal beginOffset, SUMOReal endOffset) const
void addLink(LinkType lt, const std::string &elementType, const std::string &elementID, const std::string &contactPoint)
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:58
std::string junction
The id of the junction the edge belongs to.
GeometryType
OpenDrive geometry type enumeration.
static std::vector< Position > geomFromPoly(const OpenDriveEdge &e, const OpenDriveGeometry &g)
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition: NBNode.h:311
static void buildConnectionsToOuter(const Connection &c, const std::map< std::string, OpenDriveEdge * > &innerEdges, std::vector< Connection > &into)
void unSet(const std::string &name, bool failOnNonExistant=true) const
Marks the option as unset.
Representation of a lane section.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
Definition: NBEdge.h:71
Representation of an openDrive &quot;link&quot;.
The base class for traffic light logic definitions.
ContactPoint myCurrentContactPoint
SUMOReal s
The starting offset of this lane section.
T MAX2(T a, T b)
Definition: StdDefs.h:74
std::map< OpenDriveXMLTag, std::vector< OpenDriveLane > > lanesByDir
The lanes, sorted by their direction.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:205
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything&#39;s ok.
Definition: XMLSubSys.cpp:114
SUMOReal x() const
Returns the x-position.
Definition: Position.h:63
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
SUMOReal getWidth(const std::string &type) const
Returns the lane width for the given type [m].
Definition: NBTypeCont.cpp:217
static NBNode * getOrBuildNode(const std::string &id, const Position &pos, NBNodeCont &nc)
Builds a node or returns the already built.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The connection was computed and validated.
Definition: NBEdge.h:116
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
static std::string revertID(const std::string &id)
PositionVector reverse() const
#define C_LENGTH
SUMOReal speed
The speed allowed on this lane.
Definition: NBEdge.h:130
OpenDriveXMLTag myCurrentLaneDirection
static void calcPointOnCurve(SUMOReal *ad_x, SUMOReal *ad_y, SUMOReal ad_centerX, SUMOReal ad_centerY, SUMOReal ad_r, SUMOReal ad_length)
An (internal) definition of a single lane of an edge.
Definition: NBEdge.h:123
const std::string & getID() const
Returns the id.
Definition: Named.h:60
SUMOReal length2D() const
Returns the length.
SVCPermissions permissions
List of vehicle types that are allowed on this lane.
Definition: NBEdge.h:132
std::vector< OpenDriveLink > links
A handler which converts occuring elements and attributes into enums.
OpenDriveLaneSection buildLaneSection(SUMOReal startPos)
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:181
bool operator<(const NBConnection &c1, const NBConnection &c2)
const std::string & getFileName() const
returns the current file name
const std::set< NBTrafficLightDefinition * > & getControllingTLS() const
Returns the traffic lights that were assigned to this node.
Definition: NBNode.h:325
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:189
std::string type
The lane&#39;s type.
int getPriority(OpenDriveXMLTag dir) const
Returns the edge&#39;s priority, regarding the direction.
Encapsulated SAX-Attributes.
static StringBijection< TrafficLightType > TrafficLightTypes
static Position calculateStraightEndPoint(double hdg, double length, const Position &start)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
NBEdgeCont & getEdgeCont()
Returns the edge container.
Definition: NBNetBuilder.h:154
void computeSpiral(std::vector< Point2D< double > > &spiral, double ds=0, int NPts=0)
Definition: euler.cpp:262
std::string id
The id of the edge.
A list of positions.
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given SUMO file.
NIImporter_OpenDrive(const NBTypeCont &tc, std::map< std::string, OpenDriveEdge * > &edges)
Constructor.
bool isUsableFileList(const std::string &name) const
Checks whether the named option is usable as a file list (with at least a single file) ...
bool buildSpeedChanges(const NBTypeCont &tc, std::vector< OpenDriveLaneSection > &newSections)
const NBTypeCont & myTypeContainer
SUMOReal width
The lane&#39;s width;.
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
std::vector< OpenDriveLaneSection > laneSections
std::map< int, int > laneMap
A mapping from OpenDrive to SUMO-index (the first is signed, the second unsigned) ...
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition: MsgHandler.h:202
#define POSITION_EPS
Definition: config.h:189
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
OpenDriveXMLTag
Numbers representing openDrive-XML - element names.
bool knows(const std::string &type) const
Returns whether the named type is in the container.
Definition: NBTypeCont.cpp:75
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
The connection was given by the user.
Definition: NBEdge.h:114
static StringBijection< int >::Entry openDriveTags[]
The names of openDrive-XML elements (for passing to GenericSAXHandler)
static std::vector< Position > geomFromLine(const OpenDriveEdge &e, const OpenDriveGeometry &g)
std::string origID
An original ID, if given (.
Definition: NBEdge.h:140
void buildLaneMapping(const NBTypeCont &tc)
Build the mapping from OpenDrive to SUMO lanes.
std::vector< OpenDriveSignal > signals
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
LinkType
OpenDrive link type enumeration.
void addParameter(const std::string &key, const std::string &value)
Adds a parameter.
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true)
Adds a connection between the specified this edge&#39;s lane and an approached one.
Definition: NBEdge.cpp:670
static void computeShapes(std::map< std::string, OpenDriveEdge * > &edges)
Computes a polygon representation of each edge&#39;s geometry.
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:367
void addTrafficLight(NBTrafficLightDefinition *tlDef)
Adds a traffic light to the list of traffic lights that control this node.
Definition: NBNode.cpp:307
void removeDoublePoints(SUMOReal minDist=POSITION_EPS, bool assertLength=false)
Removes positions if too near.
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:274
std::map< int, int > getInnerConnections(OpenDriveXMLTag dir, const OpenDriveLaneSection &prev)
Returns the links from the previous to this lane section.
NBNodeCont & getNodeCont()
Returns the node container.
Definition: NBNetBuilder.h:162
SUMOReal speed
The lane&#39;s speed (set in post-processing)
Instance responsible for building networks.
Definition: NBNetBuilder.h:113
Representation of an OpenDrive geometry part.
bool getShallBeDiscarded(const std::string &type) const
Returns the information whether edges of this type shall be discarded.
Definition: NBTypeCont.cpp:199
SUMOReal y() const
Returns the y-position.
Definition: Position.h:68
A storage for options typed value containers)
Definition: OptionsCont.h:108
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:79
NBTrafficLightLogicCont & getTLLogicCont()
Returns the traffic light logics container.
Definition: NBNetBuilder.h:178
static void setEdgeLinks2(OpenDriveEdge &e, const std::map< std::string, OpenDriveEdge * > &edges)
std::vector< OpenDriveGeometry > geometries
Represents a single node (junction) during network building.
Definition: NBNode.h:75
T get(const std::string &str) const
Lane & getLaneStruct(unsigned int lane)
Definition: NBEdge.h:1051
A class for sorting lane sections by their s-value.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
#define SUMOReal
Definition: config.h:215
static void setNodeSecure(NBNodeCont &nc, OpenDriveEdge &e, const std::string &nodeID, NIImporter_OpenDrive::LinkType lt)
void push_back_noDoublePos(const Position &p)
A connection between two roads.
void addGeometryShape(GeometryType type, const std::vector< SUMOReal > &vals)
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:108
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
Definition: NBTypeCont.cpp:211
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:64
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
SUMOReal length
The length of the edge.
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:203
A traffic light logics which must be computed (only nodes/edges are given)
Definition: NBOwnTLDef.h:54
static std::vector< Position > geomFromArc(const OpenDriveEdge &e, const OpenDriveGeometry &g)
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:751
Importer for networks stored in openDrive format.
static std::vector< Position > geomFromSpiral(const OpenDriveEdge &e, const OpenDriveGeometry &g)
std::vector< std::pair< SUMOReal, SUMOReal > > speeds
List of positions/speeds of speed changes.
bool exists(const std::string &name) const
Returns the information whether the named option is known.
SUMOReal width
This lane&#39;s width.
Definition: NBEdge.h:138
#define UNSET_CONNECTION
TrafficLightType
A storage for available types of edges.
Definition: NBTypeCont.h:62
void myEndElement(int element)
Called when a closing tag occurs.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static void revisitLaneSections(const NBTypeCont &tc, std::map< std::string, OpenDriveEdge * > &edges)
Rechecks lane sections of the given edges.