SUMO - Simulation of Urban MObility
NIImporter_SUMO.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // Importer for networks stored in SUMO format
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 #include <string>
37 #include <utils/common/ToString.h>
41 #include <utils/xml/XMLSubSys.h>
45 #include <netbuild/NBEdge.h>
46 #include <netbuild/NBEdgeCont.h>
47 #include <netbuild/NBNode.h>
48 #include <netbuild/NBNodeCont.h>
50 #include <netbuild/NBNetBuilder.h>
51 #include "NILoader.h"
52 #include "NIXMLTypesHandler.h"
53 #include "NIImporter_SUMO.h"
54 
55 
56 // ===========================================================================
57 // method definitions
58 // ===========================================================================
59 // ---------------------------------------------------------------------------
60 // static methods (interface in this case)
61 // ---------------------------------------------------------------------------
62 void
64  NIImporter_SUMO importer(nb);
65  importer._loadNetwork(oc);
66 }
67 
68 
69 // ---------------------------------------------------------------------------
70 // loader methods
71 // ---------------------------------------------------------------------------
73  : SUMOSAXHandler("sumo-network"),
74  myNetBuilder(nb),
75  myNodeCont(nb.getNodeCont()),
76  myTLLCont(nb.getTLLogicCont()),
77  myCurrentEdge(0),
78  myCurrentLane(0),
79  myCurrentTL(0),
80  myLocation(0),
82  myAmLefthand(false),
83  myCornerDetail(0),
84  myLinkDetail(-1),
85  myRectLaneCut(false),
86  myWalkingAreas(false) {
87 }
88 
89 
91  for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
92  EdgeAttrs* ed = (*i).second;
93  for (std::vector<LaneAttrs*>::const_iterator j = ed->lanes.begin(); j != ed->lanes.end(); ++j) {
94  delete *j;
95  }
96  delete ed;
97  }
98  delete myLocation;
99 }
100 
101 
102 void
104  // check whether the option is set (properly)
105  if (!oc.isUsableFileList("sumo-net-file")) {
106  return;
107  }
108  // parse file(s)
110  std::vector<std::string> files = oc.getStringVector("sumo-net-file");
111  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
112  if (!FileHelpers::isReadable(*file)) {
113  WRITE_ERROR("Could not open sumo-net-file '" + *file + "'.");
114  return;
115  }
116  setFileName(*file);
117  PROGRESS_BEGIN_MESSAGE("Parsing sumo-net from '" + *file + "'");
118  XMLSubSys::runParser(*this, *file, true);
119  XMLSubSys::runParser(*typesHandler, *file, true);
121  }
122  // build edges
123  for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
124  EdgeAttrs* ed = (*i).second;
125  // skip internal edges
126  if (ed->func == EDGEFUNC_INTERNAL || ed->func == EDGEFUNC_CROSSING || ed->func == EDGEFUNC_WALKINGAREA) {
127  continue;
128  }
129  // get and check the nodes
130  NBNode* from = myNodeCont.retrieve(ed->fromNode);
131  NBNode* to = myNodeCont.retrieve(ed->toNode);
132  if (from == 0) {
133  WRITE_ERROR("Edge's '" + ed->id + "' from-node '" + ed->fromNode + "' is not known.");
134  continue;
135  }
136  if (to == 0) {
137  WRITE_ERROR("Edge's '" + ed->id + "' to-node '" + ed->toNode + "' is not known.");
138  continue;
139  }
140  if (from == to) {
141  WRITE_ERROR("Edge's '" + ed->id + "' from-node and to-node '" + ed->toNode + "' art identical.");
142  continue;
143  }
144  // edge shape
145  PositionVector geom;
146  if (ed->shape.size() > 0) {
147  geom = ed->shape;
148  } else {
149  // either the edge has default shape consisting only of the two node
150  // positions or we have a legacy network
151  geom = reconstructEdgeShape(ed, from->getPosition(), to->getPosition());
152  }
153  // build and insert the edge
154  NBEdge* e = new NBEdge(ed->id, from, to,
155  ed->type, ed->maxSpeed,
156  (int) ed->lanes.size(),
158  geom, ed->streetName, "", ed->lsf, true); // always use tryIgnoreNodePositions to keep original shape
159  e->setLoadedLength(ed->length);
160  e->updateParameter(ed->getMap());
161  if (!myNetBuilder.getEdgeCont().insert(e)) {
162  WRITE_ERROR("Could not insert edge '" + ed->id + "'.");
163  delete e;
164  continue;
165  }
167  }
168  // assign further lane attributes (edges are built)
169  EdgeVector toRemove;
170  for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
171  EdgeAttrs* ed = (*i).second;
172  NBEdge* nbe = ed->builtEdge;
173  if (nbe == 0) { // inner edge or removed by explicit list, vclass, ...
174  continue;
175  }
176  for (int fromLaneIndex = 0; fromLaneIndex < (int) ed->lanes.size(); ++fromLaneIndex) {
177  LaneAttrs* lane = ed->lanes[fromLaneIndex];
178  // connections
179  const std::vector<Connection>& connections = lane->connections;
180  for (std::vector<Connection>::const_iterator c_it = connections.begin(); c_it != connections.end(); c_it++) {
181  const Connection& c = *c_it;
182  if (myEdges.count(c.toEdgeID) == 0) {
183  WRITE_ERROR("Unknown edge '" + c.toEdgeID + "' given in connection.");
184  continue;
185  }
186  NBEdge* toEdge = myEdges[c.toEdgeID]->builtEdge;
187  if (toEdge == 0) { // removed by explicit list, vclass, ...
188  continue;
189  }
190  if (nbe->hasConnectionTo(toEdge, c.toLaneIdx)) {
191  WRITE_WARNING("Target lane '" + toEdge->getLaneID(c.toLaneIdx) + "' has multiple connections from '" + nbe->getID() + "'.");
192  }
194  fromLaneIndex, toEdge, c.toLaneIdx, NBEdge::L2L_VALIDATED,
196 
197  // maybe we have a tls-controlled connection
198  if (c.tlID != "" && myRailSignals.count(c.tlID) == 0) {
199  const std::map<std::string, NBTrafficLightDefinition*>& programs = myTLLCont.getPrograms(c.tlID);
200  if (programs.size() > 0) {
201  std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
202  for (it = programs.begin(); it != programs.end(); it++) {
203  NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(it->second);
204  if (tlDef) {
205  tlDef->addConnection(nbe, toEdge, fromLaneIndex, c.toLaneIdx, c.tlLinkNo, false);
206  } else {
207  throw ProcessError("Corrupt traffic light definition '" + c.tlID + "' (program '" + it->first + "')");
208  }
209  }
210  } else {
211  WRITE_ERROR("The traffic light '" + c.tlID + "' is not known.");
212  }
213  }
214  }
215  // allow/disallow XXX preferred
216  nbe->setPermissions(parseVehicleClasses(lane->allow, lane->disallow), fromLaneIndex);
217  // width, offset
218  nbe->setLaneWidth(fromLaneIndex, lane->width);
219  nbe->setEndOffset(fromLaneIndex, lane->endOffset);
220  nbe->setSpeed(fromLaneIndex, lane->maxSpeed);
221  nbe->setAcceleration(fromLaneIndex, lane->accelRamp);
222  nbe->getLaneStruct(fromLaneIndex).oppositeID = lane->oppositeID;
223  nbe->getLaneStruct(fromLaneIndex).updateParameter(lane->getMap());
224  if (lane->customShape) {
225  nbe->setLaneShape(fromLaneIndex, lane->shape);
226  }
227  }
229  if (!nbe->hasLaneSpecificWidth() && nbe->getLanes()[0].width != NBEdge::UNSPECIFIED_WIDTH) {
230  nbe->setLaneWidth(-1, nbe->getLaneWidth(0));
231  }
233  nbe->setEndOffset(-1, nbe->getEndOffset(0));
234  }
235  // check again after permissions are set
238  toRemove.push_back(nbe);
239  }
240  }
241  for (EdgeVector::iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
243  }
244  // insert loaded prohibitions
245  for (std::vector<Prohibition>::const_iterator it = myProhibitions.begin(); it != myProhibitions.end(); it++) {
246  NBEdge* prohibitedFrom = myEdges[it->prohibitedFrom]->builtEdge;
247  NBEdge* prohibitedTo = myEdges[it->prohibitedTo]->builtEdge;
248  NBEdge* prohibitorFrom = myEdges[it->prohibitorFrom]->builtEdge;
249  NBEdge* prohibitorTo = myEdges[it->prohibitorTo]->builtEdge;
250  if (prohibitedFrom == 0) {
251  WRITE_WARNING("Edge '" + it->prohibitedFrom + "' in prohibition was not built");
252  } else if (prohibitedTo == 0) {
253  WRITE_WARNING("Edge '" + it->prohibitedTo + "' in prohibition was not built");
254  } else if (prohibitorFrom == 0) {
255  WRITE_WARNING("Edge '" + it->prohibitorFrom + "' in prohibition was not built");
256  } else if (prohibitorTo == 0) {
257  WRITE_WARNING("Edge '" + it->prohibitorTo + "' in prohibition was not built");
258  } else {
259  NBNode* n = prohibitedFrom->getToNode();
261  NBConnection(prohibitorFrom, prohibitorTo),
262  NBConnection(prohibitedFrom, prohibitedTo));
263  }
264  }
265  if (!myHaveSeenInternalEdge) {
267  }
268  if (oc.isDefault("lefthand")) {
269  oc.set("lefthand", toString(myAmLefthand));
270  }
271  if (oc.isDefault("junctions.corner-detail")) {
272  oc.set("junctions.corner-detail", toString(myCornerDetail));
273  }
274  if (oc.isDefault("junctions.internal-link-detail") && myLinkDetail > 0) {
275  oc.set("junctions.internal-link-detail", toString(myLinkDetail));
276  }
277  if (oc.isDefault("rectangular-lane-cut")) {
278  oc.set("rectangular-lane-cut", toString(myRectLaneCut));
279  }
280  if (oc.isDefault("walkingareas")) {
281  oc.set("walkingareas", toString(myWalkingAreas));
282  }
283  if (!deprecatedVehicleClassesSeen.empty()) {
284  WRITE_WARNING("Deprecated vehicle class(es) '" + toString(deprecatedVehicleClassesSeen) + "' in input network.");
286  }
287  if (!oc.getBool("no-internal-links")) {
288  // add loaded crossings
289  for (std::map<std::string, std::vector<Crossing> >::const_iterator it = myPedestrianCrossings.begin(); it != myPedestrianCrossings.end(); ++it) {
290  NBNode* node = myNodeCont.retrieve((*it).first);
291  for (std::vector<Crossing>::const_iterator it_c = (*it).second.begin(); it_c != (*it).second.end(); ++it_c) {
292  const Crossing& crossing = (*it_c);
293  EdgeVector edges;
294  for (std::vector<std::string>::const_iterator it_e = crossing.crossingEdges.begin(); it_e != crossing.crossingEdges.end(); ++it_e) {
295  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(*it_e);
296  // edge might have been removed due to options
297  if (edge != 0) {
298  edges.push_back(edge);
299  }
300  }
301  if (edges.size() > 0) {
302  node->addCrossing(edges, crossing.width, crossing.priority, crossing.customTLIndex, crossing.customShape, true);
303  }
304  }
305  }
306  // add walking area custom shapes
307  for (auto item : myWACustomShapes) {
308  std::string nodeID = SUMOXMLDefinitions::getJunctionIDFromInternalEdge(item.first);
309  NBNode* node = myNodeCont.retrieve(nodeID);
310  std::vector<std::string> edgeIDs;
311  if (item.second.fromEdges.size() + item.second.toEdges.size() == 0) {
312  // must be a split crossing
313  assert(item.second.fromCrossed.size() > 0);
314  assert(item.second.toCrossed.size() > 0);
315  edgeIDs = item.second.fromCrossed;
316  edgeIDs.insert(edgeIDs.end(), item.second.toCrossed.begin(), item.second.toCrossed.end());
317  } else if (item.second.fromEdges.size() > 0) {
318  edgeIDs = item.second.fromEdges;
319  } else {
320  edgeIDs = item.second.toEdges;
321  }
322  EdgeVector edges;
323  for (std::string edgeID : edgeIDs) {
324  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeID);
325  // edge might have been removed due to options
326  if (edge != 0) {
327  edges.push_back(edge);
328  }
329  }
330  if (edges.size() > 0) {
331  node->addWalkingAreaShape(edges, item.second.shape);
332  }
333  }
334  }
335  // add roundabouts
336  for (std::vector<std::vector<std::string> >::const_iterator it = myRoundabouts.begin(); it != myRoundabouts.end(); ++it) {
337  EdgeSet roundabout;
338  for (std::vector<std::string>::const_iterator it_r = it->begin(); it_r != it->end(); ++it_r) {
339  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(*it_r);
340  if (edge == 0) {
341  if (!myNetBuilder.getEdgeCont().wasIgnored(*it_r)) {
342  WRITE_ERROR("Unknown edge '" + (*it_r) + "' in roundabout");
343  }
344  } else {
345  roundabout.insert(edge);
346  }
347  }
348  myNetBuilder.getEdgeCont().addRoundabout(roundabout);
349  }
350 }
351 
352 
353 
354 void
356  const SUMOSAXAttributes& attrs) {
357  /* our goal is to reproduce the input net faithfully
358  * there are different types of objects in the netfile:
359  * 1) those which must be loaded into NBNetBuilder-Containers for processing
360  * 2) those which can be ignored because they are recomputed based on group 1
361  * 3) those which are of no concern to NBNetBuilder but should be exposed to
362  * NETEDIT. We will probably have to patch NBNetBuilder to contain them
363  * and hand them over to NETEDIT
364  * alternative idea: those shouldn't really be contained within the
365  * network but rather in separate files. teach NETEDIT how to open those
366  * (POI?)
367  * 4) those which are of concern neither to NBNetBuilder nor NETEDIT and
368  * must be copied over - need to patch NBNetBuilder for this.
369  * copy unknown by default
370  */
371  switch (element) {
372  case SUMO_TAG_NET: {
373  bool ok;
374  myAmLefthand = attrs.getOpt<bool>(SUMO_ATTR_LEFTHAND, 0, ok, false);
375  myCornerDetail = attrs.getOpt<int>(SUMO_ATTR_CORNERDETAIL, 0, ok, 0);
376  myLinkDetail = attrs.getOpt<int>(SUMO_ATTR_LINKDETAIL, 0, ok, -1);
377  myRectLaneCut = attrs.getOpt<bool>(SUMO_ATTR_RECTANGULAR_LANE_CUT, 0, ok, false);
378  myWalkingAreas = attrs.getOpt<bool>(SUMO_ATTR_WALKINGAREAS, 0, ok, false);
379  break;
380  }
381  case SUMO_TAG_EDGE:
382  addEdge(attrs);
383  break;
384  case SUMO_TAG_LANE:
385  addLane(attrs);
386  break;
387  case SUMO_TAG_NEIGH:
389  break;
390  case SUMO_TAG_JUNCTION:
391  addJunction(attrs);
392  break;
393  case SUMO_TAG_REQUEST:
394  addRequest(attrs);
395  break;
396  case SUMO_TAG_CONNECTION:
397  addConnection(attrs);
398  break;
399  case SUMO_TAG_TLLOGIC:
401  if (myCurrentTL) {
402  myLastParameterised.push_back(myCurrentTL);
403  }
404  break;
405  case SUMO_TAG_PHASE:
406  addPhase(attrs, myCurrentTL);
407  break;
408  case SUMO_TAG_LOCATION:
409  myLocation = loadLocation(attrs);
410  break;
412  addProhibition(attrs);
413  break;
414  case SUMO_TAG_ROUNDABOUT:
415  addRoundabout(attrs);
416  break;
417  case SUMO_TAG_PARAM:
418  if (myLastParameterised.size() != 0) {
419  bool ok = true;
420  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, 0, ok);
421  // circumventing empty string test
422  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
423  myLastParameterised.back()->setParameter(key, val);
424  }
425  default:
426  break;
427  }
428 }
429 
430 
431 void
433  switch (element) {
434  case SUMO_TAG_EDGE:
435  if (myEdges.find(myCurrentEdge->id) != myEdges.end()) {
436  WRITE_ERROR("Edge '" + myCurrentEdge->id + "' occured at least twice in the input.");
437  } else {
439  }
440  myCurrentEdge = 0;
441  myLastParameterised.pop_back();
442  break;
443  case SUMO_TAG_LANE:
444  if (myCurrentEdge != 0) {
446  myCurrentEdge->lanes.push_back(myCurrentLane);
447  }
448  myCurrentLane = 0;
449  myLastParameterised.pop_back();
450  break;
451  case SUMO_TAG_TLLOGIC:
452  if (!myCurrentTL) {
453  WRITE_ERROR("Unmatched closing tag for tl-logic.");
454  } else {
455  if (!myTLLCont.insert(myCurrentTL)) {
456  WRITE_WARNING("Could not add program '" + myCurrentTL->getProgramID() + "' for traffic light '" + myCurrentTL->getID() + "'");
457  delete myCurrentTL;
458  }
459  myCurrentTL = 0;
460  myLastParameterised.pop_back();
461  }
462  break;
463  case SUMO_TAG_JUNCTION:
464  if (myCurrentJunction.node != 0) {
465  myLastParameterised.pop_back();
466  }
467  break;
468  case SUMO_TAG_CONNECTION:
469  break;
470  default:
471  break;
472  }
473 }
474 
475 
476 void
478  // get the id, report an error if not given or empty...
479  bool ok = true;
480  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
481  if (!ok) {
482  return;
483  }
484  myCurrentEdge = new EdgeAttrs();
487  myCurrentEdge->id = id;
488  // get the function
489  myCurrentEdge->func = attrs.getEdgeFunc(ok);
491  // add the crossing but don't do anything else
492  Crossing c(id);
495  return;
497  myHaveSeenInternalEdge = true;
498  return; // skip internal edges
499  }
500  // get the type
501  myCurrentEdge->type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
502  // get the origin and the destination node
503  myCurrentEdge->fromNode = attrs.getOpt<std::string>(SUMO_ATTR_FROM, id.c_str(), ok, "");
504  myCurrentEdge->toNode = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "");
505  myCurrentEdge->priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1);
506  myCurrentEdge->type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
510  myCurrentEdge->maxSpeed = 0;
511  myCurrentEdge->streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
512  if (myCurrentEdge->streetName != "" && OptionsCont::getOptions().isDefault("output.street-names")) {
513  OptionsCont::getOptions().set("output.street-names", "true");
514  }
515 
516  std::string lsfS = toString(LANESPREAD_RIGHT);
517  lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, id.c_str(), ok, lsfS);
518  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
520  } else {
521  WRITE_ERROR("Unknown spreadType '" + lsfS + "' for edge '" + id + "'.");
522  }
523 }
524 
525 
526 void
528  bool ok = true;
529  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
530  if (!ok) {
531  return;
532  }
533  if (!myCurrentEdge) {
534  WRITE_ERROR("Found lane '" + id + "' not within edge element");
535  return;
536  }
537  myCurrentLane = new LaneAttrs();
539  myCurrentLane->customShape = attrs.getOpt<bool>(SUMO_ATTR_CUSTOMSHAPE, 0, ok, false);
540  myCurrentLane->shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
542  // save the width and the lane id of the crossing but don't do anything else
544  assert(crossings.size() > 0);
545  crossings.back().width = attrs.get<double>(SUMO_ATTR_WIDTH, id.c_str(), ok);
546  if (myCurrentLane->customShape) {
547  crossings.back().customShape = myCurrentLane->shape;
548  }
549  } else if (myCurrentEdge->func == EDGEFUNC_WALKINGAREA) {
550  // save custom shape if needed but don't do anything else
551  if (myCurrentLane->customShape) {
553  wacs.shape = myCurrentLane->shape;
555  }
556  return;
557  } else if (myCurrentEdge->func == EDGEFUNC_INTERNAL) {
558  return; // skip internal edges
559  }
560  if (attrs.hasAttribute("maxspeed")) {
561  // !!! deprecated
562  myCurrentLane->maxSpeed = attrs.getFloat("maxspeed");
563  } else {
564  myCurrentLane->maxSpeed = attrs.get<double>(SUMO_ATTR_SPEED, id.c_str(), ok);
565  }
566  try {
567  myCurrentLane->allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "", false);
568  } catch (EmptyData e) {
569  // !!! deprecated
570  myCurrentLane->allow = "";
571  }
572  myCurrentLane->disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
573  myCurrentLane->width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, (double) NBEdge::UNSPECIFIED_WIDTH);
574  myCurrentLane->endOffset = attrs.getOpt<double>(SUMO_ATTR_ENDOFFSET, id.c_str(), ok, (double) NBEdge::UNSPECIFIED_OFFSET);
575  myCurrentLane->accelRamp = attrs.getOpt<bool>(SUMO_ATTR_ACCELERATION, id.c_str(), ok, false);
576  // lane coordinates are derived (via lane spread) do not include them in convex boundary
578 }
579 
580 
581 void
583  // get the id, report an error if not given or empty...
585  myCurrentJunction.intLanes.clear();
586  myCurrentJunction.response.clear();
587  bool ok = true;
588  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
589  if (!ok) {
590  return;
591  }
592  if (id[0] == ':') { // internal node
593  return;
594  }
595  SumoXMLNodeType type = attrs.getNodeType(ok);
596  if (ok) {
597  if (type == NODETYPE_DEAD_END_DEPRECATED || type == NODETYPE_DEAD_END) {
598  // dead end is a computed status. Reset this to unknown so it will
599  // be corrected if additional connections are loaded
600  type = NODETYPE_UNKNOWN;
601  }
602  } else {
603  WRITE_WARNING("Unknown node type for junction '" + id + "'.");
604  }
605  Position pos = readPosition(attrs, id, ok);
607  NBNode* node = new NBNode(id, pos, type);
608  myLastParameterised.push_back(node);
609  if (!myNodeCont.insert(node)) {
610  WRITE_ERROR("Problems on adding junction '" + id + "'.");
611  delete node;
612  return;
613  }
614  myCurrentJunction.node = node;
616  // set optional radius
617  if (attrs.hasAttribute(SUMO_ATTR_RADIUS)) {
618  node->setRadius(attrs.get<double>(SUMO_ATTR_RADIUS, id.c_str(), ok));
619  }
620  // handle custom shape
621  if (attrs.getOpt<bool>(SUMO_ATTR_CUSTOMSHAPE, 0, ok, false)) {
622  node->setCustomShape(attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok));
623  }
624  if (type == NODETYPE_RAIL_SIGNAL || type == NODETYPE_RAIL_CROSSING) {
625  // both types of nodes come without a tlLogic
626  myRailSignals.insert(id);
627  }
628 }
629 
630 
631 void
633  if (myCurrentJunction.node != 0) {
634  bool ok = true;
635  myCurrentJunction.response.push_back(attrs.get<std::string>(SUMO_ATTR_RESPONSE, 0, ok));
636  }
637 }
638 
639 
640 void
642  bool ok = true;
643  std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
644  if (myEdges.count(fromID) == 0) {
645  WRITE_ERROR("Unknown edge '" + fromID + "' given in connection.");
646  return;
647  }
648  EdgeAttrs* from = myEdges[fromID];
649  Connection conn;
650  conn.toEdgeID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
651  int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, 0, ok);
652  conn.toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, 0, ok);
653  conn.tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, 0, ok, "");
654  conn.mayDefinitelyPass = attrs.getOpt<bool>(SUMO_ATTR_PASS, 0, ok, false);
655  conn.keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, 0, ok, true);
656  conn.contPos = attrs.getOpt<double>(SUMO_ATTR_CONTPOS, 0, ok, NBEdge::UNSPECIFIED_CONTPOS);
658  conn.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, 0, ok, NBEdge::UNSPECIFIED_SPEED);
660  if (conn.tlID != "") {
661  conn.tlLinkNo = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, 0, ok);
662  }
663  if ((int)from->lanes.size() <= fromLaneIdx) {
664  WRITE_ERROR("Invalid lane index '" + toString(fromLaneIdx) + "' for connection from '" + fromID + "'.");
665  return;
666  }
667  from->lanes[fromLaneIdx]->connections.push_back(conn);
668 
669  // determine crossing priority and tlIndex
670  if (myPedestrianCrossings.size() > 0
671  && from->func == EDGEFUNC_WALKINGAREA
672  && myEdges[conn.toEdgeID]->func == EDGEFUNC_CROSSING) {
673  std::vector<Crossing>& crossings = myPedestrianCrossings[SUMOXMLDefinitions::getJunctionIDFromInternalEdge(fromID)];
674  for (std::vector<Crossing>::iterator it = crossings.begin(); it != crossings.end(); ++it) {
675  if (conn.toEdgeID == (*it).edgeID) {
676  if (conn.tlID != "") {
677  (*it).priority = true;
678  (*it).customTLIndex = conn.tlLinkNo;
679  } else {
680  LinkState state = SUMOXMLDefinitions::LinkStates.get(attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok));
681  (*it).priority = state == LINKSTATE_MAJOR;
682  }
683  }
684  }
685  }
686  // determine walking area reference edges
687  if (myWACustomShapes.size() > 0) {
688  EdgeAttrs* to = myEdges[conn.toEdgeID];
689  if (from->func == EDGEFUNC_WALKINGAREA) {
690  std::map<std::string, WalkingAreaParsedCustomShape>::iterator it = myWACustomShapes.find(fromID);
691  if (it != myWACustomShapes.end()) {
692  if (to->func == EDGEFUNC_NORMAL) {
693  // add target sidewalk as reference
694  it->second.toEdges.push_back(conn.toEdgeID);
695  } else if (to->func == EDGEFUNC_CROSSING) {
696  // add target crossing edges as reference
698  if (conn.toEdgeID == crossing.edgeID) {
699  it->second.toCrossed.insert(it->second.toCrossed.end(), crossing.crossingEdges.begin(), crossing.crossingEdges.end());
700  }
701  }
702  }
703  }
704  } else if (to->func == EDGEFUNC_WALKINGAREA) {
705  std::map<std::string, WalkingAreaParsedCustomShape>::iterator it = myWACustomShapes.find(conn.toEdgeID);
706  if (it != myWACustomShapes.end()) {
707  if (from->func == EDGEFUNC_NORMAL) {
708  // add origin sidewalk as reference
709  it->second.fromEdges.push_back(fromID);
710  } else if (from->func == EDGEFUNC_CROSSING) {
711  // add origin crossing edges as reference
713  if (fromID == crossing.edgeID) {
714  it->second.fromCrossed.insert(it->second.fromCrossed.end(), crossing.crossingEdges.begin(), crossing.crossingEdges.end());
715  }
716  }
717  }
718  }
719  }
720  }
721 }
722 
723 
724 void
726  bool ok = true;
727  std::string prohibitor = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITOR, 0, ok, "");
728  std::string prohibited = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITED, 0, ok, "");
729  if (!ok) {
730  return;
731  }
732  Prohibition p;
735  if (!ok) {
736  return;
737  }
738  myProhibitions.push_back(p);
739 }
740 
741 
743 NIImporter_SUMO::getLaneAttrsFromID(EdgeAttrs* edge, std::string lane_id) {
744  std::string edge_id;
745  int index;
746  NBHelpers::interpretLaneID(lane_id, edge_id, index);
747  assert(edge->id == edge_id);
748  if ((int)edge->lanes.size() <= index) {
749  WRITE_ERROR("Unknown lane '" + lane_id + "' given in succedge.");
750  return 0;
751  } else {
752  return edge->lanes[index];
753  }
754 }
755 
756 
759  if (currentTL) {
760  WRITE_ERROR("Definition of tl-logic '" + currentTL->getID() + "' was not finished.");
761  return 0;
762  }
763  bool ok = true;
764  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
765  SUMOTime offset = TIME2STEPS(attrs.get<double>(SUMO_ATTR_OFFSET, id.c_str(), ok));
766  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
767  std::string typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
768  TrafficLightType type;
769  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
771  } else {
772  WRITE_ERROR("Unknown traffic light type '" + typeS + "' for tlLogic '" + id + "'.");
773  return 0;
774  }
775  if (ok) {
776  return new NBLoadedSUMOTLDef(id, programID, offset, type);
777  } else {
778  return 0;
779  }
780 }
781 
782 
783 void
785  if (!currentTL) {
786  WRITE_ERROR("found phase without tl-logic");
787  return;
788  }
789  const std::string& id = currentTL->getID();
790  bool ok = true;
791  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, id.c_str(), ok);
792  SUMOTime duration = TIME2STEPS(attrs.get<double>(SUMO_ATTR_DURATION, id.c_str(), ok));
793  if (duration < 0) {
794  WRITE_ERROR("Phase duration for tl-logic '" + id + "/" + currentTL->getProgramID() + "' must be positive.");
795  return;
796  }
797  // if the traffic light is an actuated traffic light, try to get
798  // the minimum and maximum durations
801  if (ok) {
802  currentTL->addPhase(duration, state, minDuration, maxDuration);
803  }
804 }
805 
806 
808 NIImporter_SUMO::reconstructEdgeShape(const EdgeAttrs* edge, const Position& from, const Position& to) {
809  PositionVector result;
810  result.push_back(from);
811 
812  if (edge->lanes[0]->customShape) {
813  // this is a new network where edge shapes are writen if they exist.
814  result.push_back(to);
815  return result;
816  }
817  const PositionVector& firstLane = edge->lanes[0]->shape;
818 
819  // reverse logic of NBEdge::computeLaneShape
820  // !!! this will only work for old-style constant width lanes
821  const int noLanes = (int)edge->lanes.size();
822  double offset;
823  if (edge->lsf == LANESPREAD_RIGHT) {
824  offset = (SUMO_const_laneWidth + SUMO_const_laneOffset) / 2.; // @todo: why is the lane offset counted in here?
825  } else {
826  offset = (SUMO_const_laneWidth) / 2. - (SUMO_const_laneWidth * (double)noLanes - 1) / 2.;
827  }
828  for (int i = 1; i < (int)firstLane.size() - 1; i++) {
829  const Position& from = firstLane[i - 1];
830  const Position& me = firstLane[i];
831  const Position& to = firstLane[i + 1];
832  Position offsets = PositionVector::sideOffset(from, me, offset);
833  Position offsets2 = PositionVector::sideOffset(me, to, offset);
834 
835  PositionVector l1(from - offsets, me - offsets);
836  l1.extrapolate(100);
837  PositionVector l2(me - offsets2, to - offsets2);
838  l2.extrapolate(100);
839  if (l1.intersects(l2)) {
840  result.push_back(l1.intersectionPosition2D(l2));
841  } else {
842  WRITE_WARNING("Could not reconstruct shape for edge '" + edge->id + "'.");
843  }
844  }
845 
846  result.push_back(to);
847  return result;
848 }
849 
850 
853  // @todo refactor parsing of location since its duplicated in NLHandler and PCNetProjectionLoader
854  bool ok = true;
855  GeoConvHelper* result = 0;
857  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, 0, ok);
858  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, 0, ok);
859  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, 0, ok);
860  if (ok) {
861  Position networkOffset = s[0];
862  result = new GeoConvHelper(proj, networkOffset, origBoundary, convBoundary);
863  GeoConvHelper::setLoaded(*result);
864  }
865  return result;
866 }
867 
868 
869 Position
870 NIImporter_SUMO::readPosition(const SUMOSAXAttributes& attrs, const std::string& id, bool& ok) {
871  const double x = attrs.get<double>(SUMO_ATTR_X, id.c_str(), ok);
872  const double y = attrs.get<double>(SUMO_ATTR_Y, id.c_str(), ok);
873  const double z = attrs.getOpt<double>(SUMO_ATTR_Z, id.c_str(), ok, 0.);
874  return Position(x, y, z);
875 }
876 
877 
878 void
879 NIImporter_SUMO::parseProhibitionConnection(const std::string& attr, std::string& from, std::string& to, bool& ok) {
880  // split from/to
881  const std::string::size_type div = attr.find("->");
882  if (div == std::string::npos) {
883  WRITE_ERROR("Missing connection divider in prohibition attribute '" + attr + "'");
884  ok = false;
885  }
886  from = attr.substr(0, div);
887  to = attr.substr(div + 2);
888  // check whether the definition includes a lane information and discard it
889  if (from.find('_') != std::string::npos) {
890  from = from.substr(0, from.find('_'));
891  }
892  if (to.find('_') != std::string::npos) {
893  to = to.substr(0, to.find('_'));
894  }
895  // check whether the edges are known
896  if (myEdges.count(from) == 0) {
897  WRITE_ERROR("Unknown edge prohibition '" + from + "'");
898  ok = false;
899  }
900  if (myEdges.count(to) == 0) {
901  WRITE_ERROR("Unknown edge prohibition '" + to + "'");
902  ok = false;
903  }
904 }
905 
906 
907 void
909  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
911  } else {
912  WRITE_ERROR("Empty edges in roundabout.");
913  }
914 }
915 
916 
917 /****************************************************************************/
PositionVector customShape
custom shape connection
void addPhase(SUMOTime duration, const std::string &state, SUMOTime minDur, SUMOTime maxDur)
Adds a phase to the logic the new phase is inserted at the end of the list of already added phases...
static const PositionVector EMPTY
empty Vector
std::map< std::string, EdgeAttrs * > myEdges
Loaded edge definitions.
LaneAttrs * myCurrentLane
The currently parsed lanes&#39;s definition (to add the shape to)
The information about how to spread the lanes from the given position.
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:108
PositionVector shape
This edges&#39;s shape.
std::vector< Prohibition > myProhibitions
Loaded prohibitions.
static void addPhase(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
adds a phase to the traffic lights logic currently build
std::set< std::string > deprecatedVehicleClassesSeen
NBTypeCont & getTypeCont()
Returns a reference to the type container.
Definition: NBNetBuilder.h:166
Whether vehicles must keep the junction clear.
whether a given shape is user-defined
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
Definition: NBEdge.h:269
bool accelRamp
Whether this lane is an acceleration lane.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
root element of a network file
begin/end of the description of a junction
begin/end of the description of a single lane
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:53
NBNodeCont & myNodeCont
The node container to fill.
void addEdge(const SUMOSAXAttributes &attrs)
Parses an edge and stores the values in "myCurrentEdge".
static const double UNSPECIFIED_VISIBILITY_DISTANCE
unspecified foe visibility for connections
Definition: NBEdge.h:266
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2950
void addRoundabout(const SUMOSAXAttributes &attrs)
Parses a roundabout and stores it in myEdgeCont.
A loaded (complete) traffic light logic.
std::vector< LaneAttrs * > lanes
This edge&#39;s lanes.
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2966
Describes a pedestrian crossing.
connectio between two lanes
Position intersectionPosition2D(const Position &p1, const Position &p2, const double withinDist=0.) const
Returns the position of the intersection.
double maxSpeed
The maximum velocity allowed on this lane.
const double SUMO_const_laneWidth
Definition: StdDefs.h:49
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
The representation of a single edge during network building.
Definition: NBEdge.h:70
A connection description.
foe visibility distance of a link
std::vector< std::string > response
static void setLoaded(const GeoConvHelper &loaded)
sets the coordinate transformation loaded from a location element
link,node: the traffic light id responsible for this link
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:257
T MAX2(T a, T b)
Definition: StdDefs.h:73
static const SUMOTime UNSPECIFIED_DURATION
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
Definition: NBEdge.cpp:2997
void setLoadedLength(double val)
set loaded lenght
Definition: NBEdge.cpp:3040
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:569
double width
The width of this lane.
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
bool myAmLefthand
whether the loaded network was built for lefthand traffic
const double SUMO_const_laneOffset
Definition: StdDefs.h:52
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static NBLoadedSUMOTLDef * initTrafficLightLogic(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
begins the reading of a traffic lights logic
maximum duration of a phase
const std::string & getID() const
Returns the id.
Definition: Named.h:74
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
static StringBijection< LinkState > LinkStates
link states
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1177
void setCustomShape(const PositionVector &shape)
set the junction shape
Definition: NBNode.cpp:1732
SAX-handler base for SUMO-files.
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:109
NIImporter_SUMO(NBNetBuilder &nb)
Constructor.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
Describes custom shape for a walking area during parsing.
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:254
virtual SumoXMLEdgeFunc getEdgeFunc(bool &ok) const =0
Returns the value of the named attribute.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
prohibition of circulation between two edges
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
Describes the values found in a lane&#39;s definition.
The connection was computed and validated.
Definition: NBEdge.h:114
LaneAttrs * getLaneAttrsFromID(EdgeAttrs *edge, std::string lane_id)
Parses lane index from lane ID an retrieve lane from EdgeAttrs.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:64
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
Definition: NBEdge.cpp:2989
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
Definition: NBEdge.cpp:2981
std::string toEdgeID
The id of the target edge.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
static const double UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:260
int tlLinkNo
The index of this connection within the controlling traffic light.
double maxSpeed
The maximum velocity allowed on this edge (!!!)
The state of a link.
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and stores the values in "myCurrentLane".
NBNetBuilder & myNetBuilder
The network builder to fill.
std::vector< std::vector< std::string > > myRoundabouts
loaded roundabout edges
void addConnection(const SUMOSAXAttributes &attrs)
Parses a connection and saves it into the lane&#39;s definition stored in "myCurrentLane".
void setRadius(double radius)
set the turning radius
Definition: NBNode.h:479
static void parseStringVector(const std::string &def, std::vector< std::string > &into)
Splits the given string.
std::string toNode
The node this edge ends at.
The turning radius at an intersection in m.
Describes the values found in an edge&#39;s definition and this edge&#39;s lanes.
void setFileName(const std::string &name)
Sets the current file name.
bool hasLaneSpecificWidth() const
whether lanes differ in width
Definition: NBEdge.cpp:1806
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:50
int myLinkDetail
the level of geometry detail for internal lanes in the loaded network
JunctionAttrs myCurrentJunction
The currently parsed junction definition to help in reconstructing crossings.
bool hasLaneSpecificEndOffset() const
whether lanes differ in offset
Definition: NBEdge.cpp:1817
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:59
the edges of a route
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:157
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
std::vector< std::string > crossingEdges
void updateParameter(const std::map< std::string, std::string > &mapArg)
Adds or updates all given parameters from the map.
std::string allow
This lane&#39;s allowed vehicle classes.
bool isUsableFileList(const std::string &name) const
Checks whether the named option is usable as a file list (with at least a single file) ...
std::vector< Parameterised * > myLastParameterised
element to receive parameters
Encapsulated SAX-Attributes.
static GeoConvHelper * loadLocation(const SUMOSAXAttributes &attrs)
Parses network location description and registers it with GeoConveHelper::setLoaded.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
std::string getLaneID(int lane) const
get Lane ID (Secure)
Definition: NBEdge.cpp:2783
Describes the values found in a prohibition.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
Importer for networks stored in SUMO format.
parameter associated to a certain key
std::string tlID
The id of the traffic light that controls this connection.
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:156
EdgeAttrs * myCurrentEdge
The currently parsed edge&#39;s definition (to add loaded lanes to)
A list of positions.
void parseProhibitionConnection(const std::string &attr, std::string &from, std::string &to, bool &ok)
parses connection string of a prohibition (very old school)
bool myRectLaneCut
whether all lanes of an edge should have the same stop line
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex, bool reconstruct=true)
Adds a connection and immediately informs the edges.
void haveLoadedNetworkWithoutInternalEdges()
notify about style of loaded network (Without internal edges
Definition: NBNetBuilder.h:197
double visibility
custom foe visibility for connection
LaneSpreadFunction lsf
The lane spread function.
bool customShape
Whether this lane has a custom shape.
static const double UNSPECIFIED_CONTPOS
unspecified internal junction position
Definition: NBEdge.h:263
T get(const std::string &str) const
bool hasConnectionTo(NBEdge *destEdge, int destLane, int fromLane=-1) const
Retrieves info about a connection to a certain lane of a certain edge.
Definition: NBEdge.cpp:1078
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
roundabout defined in junction
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) ...
double length
The length of the edge if set explicitly.
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition: MsgHandler.h:201
std::string disallow
This lane&#39;s disallowed vehicle classes.
edge: the shape in xml-definition
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
double getEndOffset() const
Returns the offset to the destination node.
Definition: NBEdge.h:547
double speed
custom speed for connection
const std::string & getProgramID() const
Returns the ProgramID.
begin/end of the description of a neighboring lane
NBEdge * builtEdge
The built edge.
virtual SumoXMLNodeType getNodeType(bool &ok) const =0
Returns the value of the named attribute.
static PositionVector reconstructEdgeShape(const EdgeAttrs *edge, const Position &from, const Position &to)
reconstructs the edge shape from the node positions and the given lane shapes since we do not know th...
SumoXMLEdgeFunc func
This edge&#39;s function.
std::string oppositeID
This lane&#39;s opposite lane.
void _loadNetwork(OptionsCont &oc)
load the network
description of a logic request within the junction
void addCrossing(EdgeVector edges, double width, bool priority, int tlIndex=-1, const PositionVector &customShape=PositionVector::EMPTY, bool fromSumoNet=false)
add a pedestrian crossing to this node
Definition: NBNode.cpp:2635
begin/end of the description of an edge
bool keepClear
Whether the junction must be kept clear coming from this connection.
std::vector< std::string > intLanes
double endOffset
This lane&#39;s offset from the intersection.
std::string streetName
This edge&#39;s street name.
static void loadNetwork(OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given SUMO file.
virtual std::vector< std::string > getStringVector(int attr) const =0
Tries to read given attribute assuming it is a string vector.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
void addWalkingAreaShape(EdgeVector edges, const PositionVector &shape)
add custom shape for walkingArea
Definition: NBNode.cpp:2587
double getLaneWidth() const
Returns the default width of lanes of this edge.
Definition: NBEdge.h:522
Importer for edge type information stored in XML.
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
virtual double getFloat(int id) const =0
Returns the double-value of the named (by its enum-value) attribute.
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.
std::vector< Connection > connections
This lane&#39;s connections.
void addJunction(const SUMOSAXAttributes &attrs)
Parses a junction and saves it in the node control.
std::string type
This edge&#39;s type.
bool set(const std::string &name, const std::string &value)
Sets the given value for the named option.
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE, double speed=UNSPECIFIED_SPEED, const PositionVector &customShape=PositionVector::EMPTY)
Adds a connection between the specified this edge&#39;s lane and an approached one.
Definition: NBEdge.cpp:921
std::string oppositeID
An opposite lane ID, if given.
Definition: NBEdge.h:144
the edges crossed by a pedestrian crossing
double contPos
custom position for internal junction on this connection
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Instance responsible for building networks.
Definition: NBNetBuilder.h:115
static void interpretLaneID(const std::string &lane_id, std::string &edge_id, int &index)
parses edge-id and index from lane-id
Definition: NBHelpers.cpp:127
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:40
int myCornerDetail
the level of corner detail in the loaded network
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:250
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
static Position sideOffset(const Position &beg, const Position &end, const double amount)
get a side position of position vector using a offset
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
static Position readPosition(const SUMOSAXAttributes &attrs, const std::string &id, bool &ok)
read position from the given attributes, attribute errors to id
std::map< std::string, std::vector< Crossing > > myPedestrianCrossings
The pedestrian crossings found in the network.
A storage for options typed value containers)
Definition: OptionsCont.h:98
int priority
This edge&#39;s priority.
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:384
std::string id
This edge&#39;s id.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:79
void myEndElement(int element)
Called when a closing tag occurs.
This is an uncontrolled, major link, may pass.
std::string fromNode
The node this edge starts at.
void ignore(std::string id)
mark the given edge id as ignored
Definition: NBEdgeCont.h:479
void declareConnectionsAsLoaded(EdgeBuildingStep step=LANES2LANES_USER)
declares connections as fully loaded. This is needed to avoid recomputing connections if an edge has ...
Definition: NBEdge.h:1191
const Position & getPosition() const
Definition: NBNode.h:241
Represents a single node (junction) during network building.
Definition: NBNode.h:74
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
~NIImporter_SUMO()
Destructor.
void addRequest(const SUMOSAXAttributes &attrs)
Parses a reques and saves selected attributes in myCurrentJunction.
GeoConvHelper * myLocation
The coordinate transformation which was used to build the loaded network.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
PositionVector shape
This lane&#39;s shape (needed to reconstruct edge shape for legacy networks)
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
add shorted link FOES
Definition: NBNode.cpp:1238
link: the index of the link within the traffic light
NBTrafficLightLogicCont & myTLLCont
The node container to fill.
long long int SUMOTime
Definition: TraCIDefs.h:51
a traffic light logic
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:474
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:202
std::map< std::string, WalkingAreaParsedCustomShape > myWACustomShapes
Map from walkingArea edge IDs to custom shapes.
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
void addProhibition(const SUMOSAXAttributes &attrs)
Parses a prohibition and saves it.
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
Definition: NBNetBuilder.h:176
NBLoadedSUMOTLDef * myCurrentTL
The currently parsed traffic light.
bool myWalkingAreas
whether walkingareas must be built
std::set< std::string > myRailSignals
list of node id with rail signals (no NBTrafficLightDefinition exists)
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:433
int toLaneIdx
The index of the target lane.
a single phase description
bool intersects(const Position &p1, const Position &p2) const
Returns the information whether this list of points interesects the given line.
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:2911
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
Definition: NBEdgeCont.cpp:178
TrafficLightType