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