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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Importer for networks stored in SUMO format
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 #include <string>
32 #include <utils/common/ToString.h>
36 #include <utils/xml/XMLSubSys.h>
40 #include <netbuild/NBEdge.h>
41 #include <netbuild/NBEdgeCont.h>
42 #include <netbuild/NBNode.h>
43 #include <netbuild/NBNodeCont.h>
45 #include <netbuild/NBNetBuilder.h>
46 #include "NILoader.h"
47 #include "NIXMLTypesHandler.h"
48 #include "NIImporter_SUMO.h"
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 // ---------------------------------------------------------------------------
55 // static methods (interface in this case)
56 // ---------------------------------------------------------------------------
57 void
59  NIImporter_SUMO importer(nb);
60  importer._loadNetwork(oc);
61 }
62 
63 
64 // ---------------------------------------------------------------------------
65 // loader methods
66 // ---------------------------------------------------------------------------
68  : SUMOSAXHandler("sumo-network"),
69  myNetBuilder(nb),
70  myNodeCont(nb.getNodeCont()),
71  myTLLCont(nb.getTLLogicCont()),
72  myCurrentEdge(0),
73  myCurrentLane(0),
74  myCurrentTL(0),
75  myLocation(0),
77  myAmLefthand(false),
78  myCornerDetail(0),
79  myLinkDetail(-1),
80  myRectLaneCut(false),
81  myWalkingAreas(false),
82  myLimitTurnSpeed(-1) {
83 }
84 
85 
87  for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
88  EdgeAttrs* ed = (*i).second;
89  for (std::vector<LaneAttrs*>::const_iterator j = ed->lanes.begin(); j != ed->lanes.end(); ++j) {
90  delete *j;
91  }
92  delete ed;
93  }
94  delete myLocation;
95 }
96 
97 
98 void
100  // check whether the option is set (properly)
101  if (!oc.isUsableFileList("sumo-net-file")) {
102  return;
103  }
104  // parse file(s)
106  std::vector<std::string> files = oc.getStringVector("sumo-net-file");
107  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
108  if (!FileHelpers::isReadable(*file)) {
109  WRITE_ERROR("Could not open sumo-net-file '" + *file + "'.");
110  return;
111  }
112  setFileName(*file);
113  PROGRESS_BEGIN_MESSAGE("Parsing sumo-net from '" + *file + "'");
114  XMLSubSys::runParser(*this, *file, true);
115  XMLSubSys::runParser(*typesHandler, *file, true);
117  }
118  // build edges
119  for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
120  EdgeAttrs* ed = (*i).second;
121  // skip internal edges
122  if (ed->func == EDGEFUNC_INTERNAL || ed->func == EDGEFUNC_CROSSING || ed->func == EDGEFUNC_WALKINGAREA) {
123  continue;
124  }
125  // get and check the nodes
126  NBNode* from = myNodeCont.retrieve(ed->fromNode);
127  NBNode* to = myNodeCont.retrieve(ed->toNode);
128  if (from == 0) {
129  WRITE_ERROR("Edge's '" + ed->id + "' from-node '" + ed->fromNode + "' is not known.");
130  continue;
131  }
132  if (to == 0) {
133  WRITE_ERROR("Edge's '" + ed->id + "' to-node '" + ed->toNode + "' is not known.");
134  continue;
135  }
136  if (from == to) {
137  WRITE_ERROR("Edge's '" + ed->id + "' from-node and to-node '" + ed->toNode + "' art identical.");
138  continue;
139  }
140  // edge shape
141  PositionVector geom;
142  if (ed->shape.size() > 0) {
143  geom = ed->shape;
144  } else {
145  // either the edge has default shape consisting only of the two node
146  // positions or we have a legacy network
147  geom = reconstructEdgeShape(ed, from->getPosition(), to->getPosition());
148  }
149  // build and insert the edge
150  NBEdge* e = new NBEdge(ed->id, from, to,
151  ed->type, ed->maxSpeed,
152  (int) ed->lanes.size(),
154  geom, ed->streetName, "", ed->lsf, true); // always use tryIgnoreNodePositions to keep original shape
155  e->setLoadedLength(ed->length);
156  e->updateParameter(ed->getParametersMap());
157  if (!myNetBuilder.getEdgeCont().insert(e)) {
158  WRITE_ERROR("Could not insert edge '" + ed->id + "'.");
159  delete e;
160  continue;
161  }
163  if (ed->builtEdge != nullptr) {
164  ed->builtEdge->setStopOffsets(-1, ed->stopOffsets);
165  }
166  }
167  // assign further lane attributes (edges are built)
168  EdgeVector toRemove;
169  const bool dismissVclasses = oc.getBool("dismiss-vclasses");
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.tlLinkIndex, 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  if (!dismissVclasses) {
217  nbe->setPermissions(parseVehicleClasses(lane->allow, lane->disallow), fromLaneIndex);
218  }
219  // width, offset
220  nbe->setLaneWidth(fromLaneIndex, lane->width);
221  nbe->setEndOffset(fromLaneIndex, lane->endOffset);
222  nbe->setSpeed(fromLaneIndex, lane->maxSpeed);
223  nbe->setAcceleration(fromLaneIndex, lane->accelRamp);
224  nbe->getLaneStruct(fromLaneIndex).oppositeID = lane->oppositeID;
225  nbe->getLaneStruct(fromLaneIndex).updateParameter(lane->getParametersMap());
226  if (lane->customShape) {
227  nbe->setLaneShape(fromLaneIndex, lane->shape);
228  }
229  // stop offset for lane
230  bool stopOffsetSet = false;
231  if (lane->stopOffsets.size() != 0 || nbe->getStopOffsets().size() == 0) {
232  // apply lane-specific stopOffset (might be none as well)
233  stopOffsetSet = nbe->setStopOffsets(fromLaneIndex, lane->stopOffsets);
234  }
235  if (!stopOffsetSet) {
236  // apply default stop offset to lane
237  nbe->setStopOffsets(fromLaneIndex, nbe->getStopOffsets());
238  }
239  }
241  if (!nbe->hasLaneSpecificWidth() && nbe->getLanes()[0].width != NBEdge::UNSPECIFIED_WIDTH) {
242  nbe->setLaneWidth(-1, nbe->getLaneWidth(0));
243  }
245  nbe->setEndOffset(-1, nbe->getEndOffset(0));
246  }
247  if (!nbe->hasLaneSpecificStopOffsets() && nbe->getStopOffsets().size() != 0) {
248  nbe->setStopOffsets(-1, nbe->getStopOffsets());
249  }
250  // check again after permissions are set
253  toRemove.push_back(nbe);
254  }
255  }
256  for (EdgeVector::iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
258  }
259  // insert loaded prohibitions
260  for (std::vector<Prohibition>::const_iterator it = myProhibitions.begin(); it != myProhibitions.end(); it++) {
261  NBEdge* prohibitedFrom = myEdges[it->prohibitedFrom]->builtEdge;
262  NBEdge* prohibitedTo = myEdges[it->prohibitedTo]->builtEdge;
263  NBEdge* prohibitorFrom = myEdges[it->prohibitorFrom]->builtEdge;
264  NBEdge* prohibitorTo = myEdges[it->prohibitorTo]->builtEdge;
265  if (prohibitedFrom == 0) {
266  WRITE_WARNING("Edge '" + it->prohibitedFrom + "' in prohibition was not built");
267  } else if (prohibitedTo == 0) {
268  WRITE_WARNING("Edge '" + it->prohibitedTo + "' in prohibition was not built");
269  } else if (prohibitorFrom == 0) {
270  WRITE_WARNING("Edge '" + it->prohibitorFrom + "' in prohibition was not built");
271  } else if (prohibitorTo == 0) {
272  WRITE_WARNING("Edge '" + it->prohibitorTo + "' in prohibition was not built");
273  } else {
274  NBNode* n = prohibitedFrom->getToNode();
276  NBConnection(prohibitorFrom, prohibitorTo),
277  NBConnection(prohibitedFrom, prohibitedTo));
278  }
279  }
280  if (!myHaveSeenInternalEdge && oc.isDefault("no-internal-links")) {
281  oc.set("no-internal-links", "true");
282  }
283  if (oc.isDefault("lefthand")) {
284  oc.set("lefthand", toString(myAmLefthand));
285  }
286  if (oc.isDefault("junctions.corner-detail")) {
287  oc.set("junctions.corner-detail", toString(myCornerDetail));
288  }
289  if (oc.isDefault("junctions.internal-link-detail") && myLinkDetail > 0) {
290  oc.set("junctions.internal-link-detail", toString(myLinkDetail));
291  }
292  if (oc.isDefault("rectangular-lane-cut")) {
293  oc.set("rectangular-lane-cut", toString(myRectLaneCut));
294  }
295  if (oc.isDefault("walkingareas")) {
296  oc.set("walkingareas", toString(myWalkingAreas));
297  }
298  if (oc.isDefault("junctions.limit-turn-speed")) {
299  oc.set("junctions.limit-turn-speed", toString(myLimitTurnSpeed));
300  }
301  if (!deprecatedVehicleClassesSeen.empty()) {
302  WRITE_WARNING("Deprecated vehicle class(es) '" + toString(deprecatedVehicleClassesSeen) + "' in input network.");
304  }
305  if (!oc.getBool("no-internal-links")) {
306  // add loaded crossings
307  for (std::map<std::string, std::vector<Crossing> >::const_iterator it = myPedestrianCrossings.begin(); it != myPedestrianCrossings.end(); ++it) {
308  NBNode* node = myNodeCont.retrieve((*it).first);
309  for (std::vector<Crossing>::const_iterator it_c = (*it).second.begin(); it_c != (*it).second.end(); ++it_c) {
310  const Crossing& crossing = (*it_c);
311  EdgeVector edges;
312  for (std::vector<std::string>::const_iterator it_e = crossing.crossingEdges.begin(); it_e != crossing.crossingEdges.end(); ++it_e) {
313  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(*it_e);
314  // edge might have been removed due to options
315  if (edge != 0) {
316  edges.push_back(edge);
317  }
318  }
319  if (edges.size() > 0) {
320  node->addCrossing(edges, crossing.width, crossing.priority, crossing.customTLIndex, crossing.customTLIndex2, crossing.customShape, true);
321  }
322  }
323  }
324  // add walking area custom shapes
325  for (auto item : myWACustomShapes) {
326  std::string nodeID = SUMOXMLDefinitions::getJunctionIDFromInternalEdge(item.first);
327  NBNode* node = myNodeCont.retrieve(nodeID);
328  std::vector<std::string> edgeIDs;
329  if (item.second.fromEdges.size() + item.second.toEdges.size() == 0) {
330  // must be a split crossing
331  assert(item.second.fromCrossed.size() > 0);
332  assert(item.second.toCrossed.size() > 0);
333  edgeIDs = item.second.fromCrossed;
334  edgeIDs.insert(edgeIDs.end(), item.second.toCrossed.begin(), item.second.toCrossed.end());
335  } else if (item.second.fromEdges.size() > 0) {
336  edgeIDs = item.second.fromEdges;
337  } else {
338  edgeIDs = item.second.toEdges;
339  }
340  EdgeVector edges;
341  for (std::string edgeID : edgeIDs) {
342  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeID);
343  // edge might have been removed due to options
344  if (edge != 0) {
345  edges.push_back(edge);
346  }
347  }
348  if (edges.size() > 0) {
349  node->addWalkingAreaShape(edges, item.second.shape);
350  }
351  }
352  }
353  // add roundabouts
354  for (std::vector<std::vector<std::string> >::const_iterator it = myRoundabouts.begin(); it != myRoundabouts.end(); ++it) {
355  EdgeSet roundabout;
356  for (std::vector<std::string>::const_iterator it_r = it->begin(); it_r != it->end(); ++it_r) {
357  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(*it_r);
358  if (edge == 0) {
359  if (!myNetBuilder.getEdgeCont().wasIgnored(*it_r)) {
360  WRITE_ERROR("Unknown edge '" + (*it_r) + "' in roundabout");
361  }
362  } else {
363  roundabout.insert(edge);
364  }
365  }
366  myNetBuilder.getEdgeCont().addRoundabout(roundabout);
367  }
368 }
369 
370 
371 
372 void
374  const SUMOSAXAttributes& attrs) {
375  /* our goal is to reproduce the input net faithfully
376  * there are different types of objects in the netfile:
377  * 1) those which must be loaded into NBNetBuilder-Containers for processing
378  * 2) those which can be ignored because they are recomputed based on group 1
379  * 3) those which are of no concern to NBNetBuilder but should be exposed to
380  * NETEDIT. We will probably have to patch NBNetBuilder to contain them
381  * and hand them over to NETEDIT
382  * alternative idea: those shouldn't really be contained within the
383  * network but rather in separate files. teach NETEDIT how to open those
384  * (POI?)
385  * 4) those which are of concern neither to NBNetBuilder nor NETEDIT and
386  * must be copied over - need to patch NBNetBuilder for this.
387  * copy unknown by default
388  */
389  switch (element) {
390  case SUMO_TAG_NET: {
391  bool ok;
392  myAmLefthand = attrs.getOpt<bool>(SUMO_ATTR_LEFTHAND, 0, ok, false);
393  myCornerDetail = attrs.getOpt<int>(SUMO_ATTR_CORNERDETAIL, 0, ok, 0);
394  myLinkDetail = attrs.getOpt<int>(SUMO_ATTR_LINKDETAIL, 0, ok, -1);
395  myRectLaneCut = attrs.getOpt<bool>(SUMO_ATTR_RECTANGULAR_LANE_CUT, 0, ok, false);
396  myWalkingAreas = attrs.getOpt<bool>(SUMO_ATTR_WALKINGAREAS, 0, ok, false);
397  myLimitTurnSpeed = attrs.getOpt<double>(SUMO_ATTR_LIMIT_TURN_SPEED, 0, ok, -1);
398  break;
399  }
400  case SUMO_TAG_EDGE:
401  addEdge(attrs);
402  break;
403  case SUMO_TAG_LANE:
404  addLane(attrs);
405  break;
406  case SUMO_TAG_STOPOFFSET: {
407  bool ok = true;
408  addStopOffsets(attrs, ok);
409  }
410  break;
411  case SUMO_TAG_NEIGH:
413  break;
414  case SUMO_TAG_JUNCTION:
415  addJunction(attrs);
416  break;
417  case SUMO_TAG_REQUEST:
418  addRequest(attrs);
419  break;
420  case SUMO_TAG_CONNECTION:
421  addConnection(attrs);
422  break;
423  case SUMO_TAG_TLLOGIC:
425  if (myCurrentTL) {
426  myLastParameterised.push_back(myCurrentTL);
427  }
428  break;
429  case SUMO_TAG_PHASE:
430  addPhase(attrs, myCurrentTL);
431  break;
432  case SUMO_TAG_LOCATION:
433  myLocation = loadLocation(attrs);
434  break;
436  addProhibition(attrs);
437  break;
438  case SUMO_TAG_ROUNDABOUT:
439  addRoundabout(attrs);
440  break;
441  case SUMO_TAG_PARAM:
442  if (myLastParameterised.size() != 0) {
443  bool ok = true;
444  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, 0, ok);
445  // circumventing empty string test
446  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
447  myLastParameterised.back()->setParameter(key, val);
448  }
449  break;
450  default:
451  break;
452  }
453 }
454 
455 
456 void
458  switch (element) {
459  case SUMO_TAG_EDGE:
460  if (myEdges.find(myCurrentEdge->id) != myEdges.end()) {
461  WRITE_ERROR("Edge '" + myCurrentEdge->id + "' occurred at least twice in the input.");
462  } else {
464  }
465  myCurrentEdge = 0;
466  myLastParameterised.pop_back();
467  break;
468  case SUMO_TAG_LANE:
469  if (myCurrentEdge != 0) {
471  myCurrentEdge->lanes.push_back(myCurrentLane);
472  }
473  myCurrentLane = 0;
474  myLastParameterised.pop_back();
475  break;
476  case SUMO_TAG_TLLOGIC:
477  if (!myCurrentTL) {
478  WRITE_ERROR("Unmatched closing tag for tl-logic.");
479  } else {
480  if (!myTLLCont.insert(myCurrentTL)) {
481  WRITE_WARNING("Could not add program '" + myCurrentTL->getProgramID() + "' for traffic light '" + myCurrentTL->getID() + "'");
482  delete myCurrentTL;
483  }
484  myCurrentTL = 0;
485  myLastParameterised.pop_back();
486  }
487  break;
488  case SUMO_TAG_JUNCTION:
489  if (myCurrentJunction.node != 0) {
490  myLastParameterised.pop_back();
491  }
492  break;
493  case SUMO_TAG_CONNECTION:
494  break;
495  default:
496  break;
497  }
498 }
499 
500 
501 void
503  // get the id, report an error if not given or empty...
504  bool ok = true;
505  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
506  if (!ok) {
507  return;
508  }
509  myCurrentEdge = new EdgeAttrs();
512  myCurrentEdge->id = id;
513  // get the function
514  myCurrentEdge->func = attrs.getEdgeFunc(ok);
516  // add the crossing but don't do anything else
517  Crossing c(id);
520  return;
522  myHaveSeenInternalEdge = true;
523  return; // skip internal edges
524  }
525  // get the type
526  myCurrentEdge->type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
527  // get the origin and the destination node
528  myCurrentEdge->fromNode = attrs.getOpt<std::string>(SUMO_ATTR_FROM, id.c_str(), ok, "");
529  myCurrentEdge->toNode = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "");
530  myCurrentEdge->priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1);
531  myCurrentEdge->type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
535  myCurrentEdge->maxSpeed = 0;
536  myCurrentEdge->streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
537  if (myCurrentEdge->streetName != "" && OptionsCont::getOptions().isDefault("output.street-names")) {
538  OptionsCont::getOptions().set("output.street-names", "true");
539  }
540 
541  std::string lsfS = toString(LANESPREAD_RIGHT);
542  lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, id.c_str(), ok, lsfS);
543  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
545  } else {
546  WRITE_ERROR("Unknown spreadType '" + lsfS + "' for edge '" + id + "'.");
547  }
548 }
549 
550 
551 void
553  bool ok = true;
554  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
555  if (!ok) {
556  return;
557  }
558  if (!myCurrentEdge) {
559  WRITE_ERROR("Found lane '" + id + "' not within edge element");
560  return;
561  }
562  myCurrentLane = new LaneAttrs();
564  myCurrentLane->customShape = attrs.getOpt<bool>(SUMO_ATTR_CUSTOMSHAPE, 0, ok, false);
565  myCurrentLane->shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
567  // save the width and the lane id of the crossing but don't do anything else
569  assert(crossings.size() > 0);
570  crossings.back().width = attrs.get<double>(SUMO_ATTR_WIDTH, id.c_str(), ok);
571  if (myCurrentLane->customShape) {
572  crossings.back().customShape = myCurrentLane->shape;
573  }
574  } else if (myCurrentEdge->func == EDGEFUNC_WALKINGAREA) {
575  // save custom shape if needed but don't do anything else
576  if (myCurrentLane->customShape) {
578  wacs.shape = myCurrentLane->shape;
581  }
582  return;
583  } else if (myCurrentEdge->func == EDGEFUNC_INTERNAL) {
584  return; // skip internal edges
585  }
586  if (attrs.hasAttribute("maxspeed")) {
587  // !!! deprecated
588  myCurrentLane->maxSpeed = attrs.getFloat("maxspeed");
589  } else {
590  myCurrentLane->maxSpeed = attrs.get<double>(SUMO_ATTR_SPEED, id.c_str(), ok);
591  }
592  try {
593  myCurrentLane->allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "", false);
594  } catch (EmptyData&) {
595  // !!! deprecated
596  myCurrentLane->allow = "";
597  }
598  myCurrentLane->disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
599  myCurrentLane->width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, (double) NBEdge::UNSPECIFIED_WIDTH);
600  myCurrentLane->endOffset = attrs.getOpt<double>(SUMO_ATTR_ENDOFFSET, id.c_str(), ok, (double) NBEdge::UNSPECIFIED_OFFSET);
601  myCurrentLane->accelRamp = attrs.getOpt<bool>(SUMO_ATTR_ACCELERATION, id.c_str(), ok, false);
602  // lane coordinates are derived (via lane spread) do not include them in convex boundary
604 }
605 
606 
607 void
609  std::map<SVCPermissions, double> offsets = parseStopOffsets(attrs, ok);
610  if (!ok) {
611  return;
612  }
613  assert(offsets.size() == 1);
614  // Admissibility of value will be checked in _loadNetwork(), when lengths are known
615  if (myCurrentLane == 0) {
616  if (myCurrentEdge->stopOffsets.size() != 0) {
617  std::stringstream ss;
618  ss << "Duplicate definition of stopOffset for edge " << myCurrentEdge->id << ".\nIgnoring duplicate specification.";
619  WRITE_WARNING(ss.str());
620  return;
621  } else {
622  myCurrentEdge->stopOffsets = offsets;
623  }
624  } else {
625  if (myCurrentLane->stopOffsets.size() != 0) {
626  std::stringstream ss;
627  ss << "Duplicate definition of lane's stopOffset on edge " << myCurrentEdge->id << ".\nIgnoring duplicate specifications.";
628  WRITE_WARNING(ss.str());
629  return;
630  } else {
631  myCurrentLane->stopOffsets = offsets;
632  }
633  }
634 }
635 
636 
637 void
639  // get the id, report an error if not given or empty...
641  myCurrentJunction.intLanes.clear();
642  myCurrentJunction.response.clear();
643  bool ok = true;
644  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
645  if (!ok) {
646  return;
647  }
648  if (id[0] == ':') { // internal node
649  return;
650  }
651  SumoXMLNodeType type = attrs.getNodeType(ok);
652  if (ok) {
653  if (type == NODETYPE_DEAD_END_DEPRECATED || type == NODETYPE_DEAD_END) {
654  // dead end is a computed status. Reset this to unknown so it will
655  // be corrected if additional connections are loaded
656  type = NODETYPE_UNKNOWN;
657  }
658  } else {
659  WRITE_WARNING("Unknown node type for junction '" + id + "'.");
660  }
661  Position pos = readPosition(attrs, id, ok);
663  NBNode* node = new NBNode(id, pos, type);
664  myLastParameterised.push_back(node);
665  if (!myNodeCont.insert(node)) {
666  WRITE_ERROR("Problems on adding junction '" + id + "'.");
667  delete node;
668  return;
669  }
670  myCurrentJunction.node = node;
672  // set optional radius
673  if (attrs.hasAttribute(SUMO_ATTR_RADIUS)) {
674  node->setRadius(attrs.get<double>(SUMO_ATTR_RADIUS, id.c_str(), ok));
675  }
676  // handle custom shape
677  if (attrs.getOpt<bool>(SUMO_ATTR_CUSTOMSHAPE, 0, ok, false)) {
678  node->setCustomShape(attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok));
679  }
680  if (type == NODETYPE_RAIL_SIGNAL || type == NODETYPE_RAIL_CROSSING) {
681  // both types of nodes come without a tlLogic
682  myRailSignals.insert(id);
683  }
684 }
685 
686 
687 void
689  if (myCurrentJunction.node != 0) {
690  bool ok = true;
691  myCurrentJunction.response.push_back(attrs.get<std::string>(SUMO_ATTR_RESPONSE, 0, ok));
692  }
693 }
694 
695 
696 void
698  bool ok = true;
699  std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
700  if (myEdges.count(fromID) == 0) {
701  WRITE_ERROR("Unknown edge '" + fromID + "' given in connection.");
702  return;
703  }
704  EdgeAttrs* from = myEdges[fromID];
705  Connection conn;
706  conn.toEdgeID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
707  int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, 0, ok);
708  conn.toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, 0, ok);
709  conn.tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, 0, ok, "");
710  conn.mayDefinitelyPass = attrs.getOpt<bool>(SUMO_ATTR_PASS, 0, ok, false);
711  conn.keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, 0, ok, true);
712  conn.contPos = attrs.getOpt<double>(SUMO_ATTR_CONTPOS, 0, ok, NBEdge::UNSPECIFIED_CONTPOS);
714  conn.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, 0, ok, NBEdge::UNSPECIFIED_SPEED);
717  if (conn.tlID != "") {
718  conn.tlLinkIndex = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, 0, ok);
719  }
720  if ((int)from->lanes.size() <= fromLaneIdx) {
721  WRITE_ERROR("Invalid lane index '" + toString(fromLaneIdx) + "' for connection from '" + fromID + "'.");
722  return;
723  }
724  from->lanes[fromLaneIdx]->connections.push_back(conn);
725 
726  // determine crossing priority and tlIndex
727  if (myPedestrianCrossings.size() > 0) {
728  if (from->func == EDGEFUNC_WALKINGAREA && myEdges[conn.toEdgeID]->func == EDGEFUNC_CROSSING) {
729  // connection from walkingArea to crossing
730  std::vector<Crossing>& crossings = myPedestrianCrossings[SUMOXMLDefinitions::getJunctionIDFromInternalEdge(fromID)];
731  for (std::vector<Crossing>::iterator it = crossings.begin(); it != crossings.end(); ++it) {
732  if (conn.toEdgeID == (*it).edgeID) {
733  if (conn.tlID != "") {
734  (*it).priority = true;
735  (*it).customTLIndex = conn.tlLinkIndex;
736  } else {
737  LinkState state = SUMOXMLDefinitions::LinkStates.get(attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok));
738  (*it).priority = state == LINKSTATE_MAJOR;
739  }
740  }
741  }
742  } else if (from->func == EDGEFUNC_CROSSING && myEdges[conn.toEdgeID]->func == EDGEFUNC_WALKINGAREA) {
743  // connection from crossing to walkingArea (set optional linkIndex2)
745  if (fromID == c.edgeID) {
746  c.customTLIndex2 = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX, 0, ok, -1);
747  }
748  }
749  }
750  }
751  // determine walking area reference edges
752  if (myWACustomShapes.size() > 0) {
753  EdgeAttrs* to = myEdges[conn.toEdgeID];
754  if (from->func == EDGEFUNC_WALKINGAREA) {
755  std::map<std::string, WalkingAreaParsedCustomShape>::iterator it = myWACustomShapes.find(fromID);
756  if (it != myWACustomShapes.end()) {
757  if (to->func == EDGEFUNC_NORMAL) {
758  // add target sidewalk as reference
759  it->second.toEdges.push_back(conn.toEdgeID);
760  } else if (to->func == EDGEFUNC_CROSSING) {
761  // add target crossing edges as reference
763  if (conn.toEdgeID == crossing.edgeID) {
764  it->second.toCrossed.insert(it->second.toCrossed.end(), crossing.crossingEdges.begin(), crossing.crossingEdges.end());
765  }
766  }
767  }
768  }
769  } else if (to->func == EDGEFUNC_WALKINGAREA) {
770  std::map<std::string, WalkingAreaParsedCustomShape>::iterator it = myWACustomShapes.find(conn.toEdgeID);
771  if (it != myWACustomShapes.end()) {
772  if (from->func == EDGEFUNC_NORMAL) {
773  // add origin sidewalk as reference
774  it->second.fromEdges.push_back(fromID);
775  } else if (from->func == EDGEFUNC_CROSSING) {
776  // add origin crossing edges as reference
778  if (fromID == crossing.edgeID) {
779  it->second.fromCrossed.insert(it->second.fromCrossed.end(), crossing.crossingEdges.begin(), crossing.crossingEdges.end());
780  }
781  }
782  }
783  }
784  }
785  }
786 }
787 
788 
789 void
791  bool ok = true;
792  std::string prohibitor = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITOR, 0, ok, "");
793  std::string prohibited = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITED, 0, ok, "");
794  if (!ok) {
795  return;
796  }
797  Prohibition p;
800  if (!ok) {
801  return;
802  }
803  myProhibitions.push_back(p);
804 }
805 
806 
808 NIImporter_SUMO::getLaneAttrsFromID(EdgeAttrs* edge, std::string lane_id) {
809  std::string edge_id;
810  int index;
811  NBHelpers::interpretLaneID(lane_id, edge_id, index);
812  assert(edge->id == edge_id);
813  if ((int)edge->lanes.size() <= index) {
814  WRITE_ERROR("Unknown lane '" + lane_id + "' given in succedge.");
815  return 0;
816  } else {
817  return edge->lanes[index];
818  }
819 }
820 
821 
824  if (currentTL) {
825  WRITE_ERROR("Definition of tl-logic '" + currentTL->getID() + "' was not finished.");
826  return 0;
827  }
828  bool ok = true;
829  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
830  SUMOTime offset = TIME2STEPS(attrs.get<double>(SUMO_ATTR_OFFSET, id.c_str(), ok));
831  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
832  std::string typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
833  TrafficLightType type;
834  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
836  } else {
837  WRITE_ERROR("Unknown traffic light type '" + typeS + "' for tlLogic '" + id + "'.");
838  return 0;
839  }
840  if (ok) {
841  return new NBLoadedSUMOTLDef(id, programID, offset, type);
842  } else {
843  return 0;
844  }
845 }
846 
847 
848 void
850  if (!currentTL) {
851  WRITE_ERROR("found phase without tl-logic");
852  return;
853  }
854  const std::string& id = currentTL->getID();
855  bool ok = true;
856  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, id.c_str(), ok);
857  SUMOTime duration = TIME2STEPS(attrs.get<double>(SUMO_ATTR_DURATION, id.c_str(), ok));
858  if (duration < 0) {
859  WRITE_ERROR("Phase duration for tl-logic '" + id + "/" + currentTL->getProgramID() + "' must be positive.");
860  return;
861  }
862  // if the traffic light is an actuated traffic light, try to get
863  // the minimum and maximum durations
866  if (ok) {
867  currentTL->addPhase(duration, state, minDuration, maxDuration);
868  }
869 }
870 
871 
873 NIImporter_SUMO::reconstructEdgeShape(const EdgeAttrs* edge, const Position& from, const Position& to) {
874  PositionVector result;
875  result.push_back(from);
876 
877  if (edge->lanes[0]->customShape) {
878  // this is a new network where edge shapes are writen if they exist.
879  result.push_back(to);
880  return result;
881  }
882  const PositionVector& firstLane = edge->lanes[0]->shape;
883 
884  // reverse logic of NBEdge::computeLaneShape
885  // !!! this will only work for old-style constant width lanes
886  const int noLanes = (int)edge->lanes.size();
887  double offset;
888  if (edge->lsf == LANESPREAD_RIGHT) {
889  offset = (SUMO_const_laneWidth + SUMO_const_laneOffset) / 2.; // @todo: why is the lane offset counted in here?
890  } else {
891  offset = (SUMO_const_laneWidth) / 2. - (SUMO_const_laneWidth * (double)noLanes - 1) / 2.;
892  }
893  for (int i = 1; i < (int)firstLane.size() - 1; i++) {
894  const Position& from = firstLane[i - 1];
895  const Position& me = firstLane[i];
896  const Position& to = firstLane[i + 1];
897  Position offsets = PositionVector::sideOffset(from, me, offset);
898  Position offsets2 = PositionVector::sideOffset(me, to, offset);
899 
900  PositionVector l1(from - offsets, me - offsets);
901  l1.extrapolate(100);
902  PositionVector l2(me - offsets2, to - offsets2);
903  l2.extrapolate(100);
904  if (l1.intersects(l2)) {
905  result.push_back(l1.intersectionPosition2D(l2));
906  } else {
907  WRITE_WARNING("Could not reconstruct shape for edge '" + edge->id + "'.");
908  }
909  }
910 
911  result.push_back(to);
912  return result;
913 }
914 
915 
918  // @todo refactor parsing of location since its duplicated in NLHandler and PCNetProjectionLoader
919  bool ok = true;
920  GeoConvHelper* result = 0;
922  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, 0, ok);
923  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, 0, ok);
924  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, 0, ok);
925  if (ok) {
926  Position networkOffset = s[0];
927  result = new GeoConvHelper(proj, networkOffset, origBoundary, convBoundary);
928  GeoConvHelper::setLoaded(*result);
929  }
930  return result;
931 }
932 
933 
934 Position
935 NIImporter_SUMO::readPosition(const SUMOSAXAttributes& attrs, const std::string& id, bool& ok) {
936  const double x = attrs.get<double>(SUMO_ATTR_X, id.c_str(), ok);
937  const double y = attrs.get<double>(SUMO_ATTR_Y, id.c_str(), ok);
938  const double z = attrs.getOpt<double>(SUMO_ATTR_Z, id.c_str(), ok, 0.);
939  return Position(x, y, z);
940 }
941 
942 
943 void
944 NIImporter_SUMO::parseProhibitionConnection(const std::string& attr, std::string& from, std::string& to, bool& ok) {
945  // split from/to
946  const std::string::size_type div = attr.find("->");
947  if (div == std::string::npos) {
948  WRITE_ERROR("Missing connection divider in prohibition attribute '" + attr + "'");
949  ok = false;
950  }
951  from = attr.substr(0, div);
952  to = attr.substr(div + 2);
953  // check whether the definition includes a lane information and discard it
954  if (from.find('_') != std::string::npos) {
955  from = from.substr(0, from.find('_'));
956  }
957  if (to.find('_') != std::string::npos) {
958  to = to.substr(0, to.find('_'));
959  }
960  // check whether the edges are known
961  if (myEdges.count(from) == 0) {
962  WRITE_ERROR("Unknown edge prohibition '" + from + "'");
963  ok = false;
964  }
965  if (myEdges.count(to) == 0) {
966  WRITE_ERROR("Unknown edge prohibition '" + to + "'");
967  ok = false;
968  }
969 }
970 
971 
972 void
974  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
976  } else {
977  WRITE_ERROR("Empty edges in roundabout.");
978  }
979 }
980 
981 
982 /****************************************************************************/
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
static const bool UNSPECIFIED_CONNECTION_UNCONTROLLED
TLS-controlled despite its node controlled not specified.
Definition: NBEdge.h:283
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
long long int SUMOTime
Definition: SUMOTime.h:36
std::set< std::string > deprecatedVehicleClassesSeen
NBTypeCont & getTypeCont()
Returns a reference to the type container.
Definition: NBNetBuilder.h:160
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:271
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...
const std::map< int, double > & getStopOffsets() const
Returns the stopOffset to the end of the edge.
Definition: NBEdge.h:560
root element of a network file
begin/end of the description of a junction
begin/end of the description of a single lane
bool uncontrolled
if set to true, This connection will not be TLS-controlled despite its node being controlled...
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:47
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:268
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3190
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:3240
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:51
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
return the junction id when given an edge of type internal, crossing or WalkingArea ...
The representation of a single edge during network building.
Definition: NBEdge.h:65
A connection description.
foe visibility distance of a link
int tlLinkIndex
The index of this connection within the controlling traffic light.
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:259
std::map< SVCPermissions, double > parseStopOffsets(const SUMOSAXAttributes &attrs, bool &ok)
Extract stopOffsets from attributes of stopOffset element.
T MAX2(T a, T b)
Definition: StdDefs.h:76
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:3271
void setLoadedLength(double val)
set loaded lenght
Definition: NBEdge.cpp:3314
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:587
double myLimitTurnSpeed
whether turning speed was limited in the network
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:69
#define TIME2STEPS(x)
Definition: SUMOTime.h:60
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:1204
void setCustomShape(const PositionVector &shape)
set the junction shape
Definition: NBNode.cpp:1917
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:113
NIImporter_SUMO(NBNetBuilder &nb)
Constructor.
bool setStopOffsets(int lane, std::map< int, double > offsets, bool overwrite=false)
set lane and vehicle class specific stopOffset (negative lane implies set for all lanes) ...
Definition: NBEdge.cpp:3206
bool hasLaneSpecificStopOffsets() const
whether lanes differ in stopOffsets
Definition: NBEdge.cpp:1993
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:256
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:42
prohibition of circulation between two edges
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:242
Describes the values found in a lane&#39;s definition.
The connection was computed and validated.
Definition: NBEdge.h:109
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:58
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
Definition: NBEdge.cpp:3263
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
Definition: NBEdge.cpp:3255
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:262
double maxSpeed
The maximum velocity allowed on this edge (!!!)
The state of a link.
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, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED)
Adds a connection between the specified this edge&#39;s lane and an approached one.
Definition: NBEdge.cpp:966
void addStopOffsets(const SUMOSAXAttributes &attrs, bool &ok)
parses stop offsets for the current lane or edge
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:484
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:1971
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:46
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:1982
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:53
the edges of a route
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:152
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
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:2990
Describes the values found in a prohibition.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
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:150
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.
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:265
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:1126
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:244
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:553
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::map< SVCPermissions, double > stopOffsets
This edge&#39;s vehicle specific stop offsets (used for lanes, that do not have a specified stopOffset) ...
std::string oppositeID
This lane&#39;s opposite lane.
void _loadNetwork(OptionsCont &oc)
load the network
description of a logic request within the junction
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.
NBNode::Crossing * addCrossing(EdgeVector edges, double width, bool priority, int tlIndex=-1, int tlIndex2=-1, const PositionVector &customShape=PositionVector::EMPTY, bool fromSumoNet=false)
add a pedestrian crossing to this node
Definition: NBNode.cpp:2836
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:248
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:2788
double getLaneWidth() const
Returns the default width of lanes of this edge.
Definition: NBEdge.h:528
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.
std::string oppositeID
An opposite lane ID, if given.
Definition: NBEdge.h:143
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:109
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:121
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
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:245
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:92
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:379
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:508
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:1218
const Position & getPosition() const
Definition: NBNode.h:241
Represents a single node (junction) during network building.
Definition: NBNode.h:68
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
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:1349
link: the index of the link within the traffic light
NBTrafficLightLogicCont & myTLLCont
The node container to fill.
a traffic light logic
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:503
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:245
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:170
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:439
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.
std::map< SVCPermissions, double > stopOffsets
This lane&#39;s vehicle specific stop offsets.
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:3142
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
Definition: NBEdgeCont.cpp:173
TrafficLightType
Information on vClass specific stop offsets at lane end.