Eclipse 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.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Importer for networks stored in SUMO format
22 /****************************************************************************/
23 #include <config.h>
24 #include <string>
30 #include <utils/common/ToString.h>
34 #include <utils/xml/XMLSubSys.h>
38 #include <netbuild/NBEdge.h>
39 #include <netbuild/NBEdgeCont.h>
40 #include <netbuild/NBNode.h>
41 #include <netbuild/NBNodeCont.h>
43 #include <netbuild/NBNetBuilder.h>
44 #include "NILoader.h"
45 #include "NIXMLTypesHandler.h"
46 #include "NIImporter_SUMO.h"
47 
48 
49 // ===========================================================================
50 // method definitions
51 // ===========================================================================
52 // ---------------------------------------------------------------------------
53 // static methods (interface in this case)
54 // ---------------------------------------------------------------------------
55 void
57  NIImporter_SUMO importer(nb);
58  importer._loadNetwork(oc);
59 }
60 
61 
62 // ---------------------------------------------------------------------------
63 // loader methods
64 // ---------------------------------------------------------------------------
66  : SUMOSAXHandler("sumo-network"),
67  myNetBuilder(nb),
68  myNodeCont(nb.getNodeCont()),
69  myTLLCont(nb.getTLLogicCont()),
70  myTypesHandler(nb.getTypeCont()),
71  myCurrentEdge(nullptr),
72  myCurrentLane(nullptr),
73  myCurrentTL(nullptr),
74  myLocation(nullptr),
75  myNetworkVersion(0, 0),
76  myHaveSeenInternalEdge(false),
77  myAmLefthand(false),
78  myChangeLefthand(false),
79  myCornerDetail(0),
80  myLinkDetail(-1),
81  myRectLaneCut(false),
82  myWalkingAreas(false),
83  myLimitTurnSpeed(-1),
84  myCheckLaneFoesAll(false),
85  myCheckLaneFoesRoundabout(true),
86  myTlsIgnoreInternalJunctionJam(false),
87  myDefaultSpreadType(toString(LaneSpreadFunction::RIGHT)),
88  myGeomAvoidOverlap(true),
89  myJunctionsHigherSpeed(false),
90  myInternalJunctionsVehicleWidth(OptionsCont::getOptions().getFloat("internal-junctions.vehicle-width")),
91  myJunctionsMinimalShape(OptionsCont::getOptions().getBool("junctions.minimal-shape")),
92  myJunctionsEndpointShape(OptionsCont::getOptions().getBool("junctions.endpoint-shape")) {
93 }
94 
95 
97  for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
98  EdgeAttrs* ed = (*i).second;
99  for (std::vector<LaneAttrs*>::const_iterator j = ed->lanes.begin(); j != ed->lanes.end(); ++j) {
100  delete *j;
101  }
102  delete ed;
103  }
104  delete myLocation;
105 }
106 
107 
108 void
110  // check whether the option is set (properly)
111  if (!oc.isUsableFileList("sumo-net-file")) {
112  return;
113  }
114  const std::vector<std::string> discardableParams = oc.getStringVector("discard-params");
115  myDiscardableParams.insert(discardableParams.begin(), discardableParams.end());
116  // parse file(s)
117  const std::vector<std::string> files = oc.getStringVector("sumo-net-file");
118  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
119  if (!FileHelpers::isReadable(*file)) {
120  WRITE_ERRORF(TL("Could not open sumo-net-file '%'."), *file);
121  return;
122  }
123  setFileName(*file);
124  const long before = PROGRESS_BEGIN_TIME_MESSAGE("Parsing sumo-net from '" + *file + "'");
125  XMLSubSys::runParser(*this, *file, true);
126  PROGRESS_TIME_MESSAGE(before);
127  }
128  // build edges
129  const double maxSegmentLength = oc.getFloat("geometry.max-segment-length");
130  for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
131  EdgeAttrs* ed = (*i).second;
132  // skip internal edges
134  continue;
135  }
136  // get and check the nodes
137  NBNode* from = myNodeCont.retrieve(ed->fromNode);
138  NBNode* to = myNodeCont.retrieve(ed->toNode);
139  if (from == nullptr) {
140  WRITE_ERRORF(TL("Edge's '%' from-node '%' is not known."), ed->id, ed->fromNode);
141  continue;
142  }
143  if (to == nullptr) {
144  WRITE_ERRORF(TL("Edge's '%' to-node '%' is not known."), ed->id, ed->toNode);
145  continue;
146  }
147  if (from == to) {
148  WRITE_ERRORF(TL("Edge's '%' from-node and to-node '%' are identical."), ed->id, ed->toNode);
149  continue;
150  }
151  if (ed->shape.size() == 0 && maxSegmentLength > 0) {
152  ed->shape.push_back(from->getPosition());
153  ed->shape.push_back(to->getPosition());
154  // shape is already cartesian but we must use a copy because the original will be modified
155  NBNetBuilder::addGeometrySegments(ed->shape, PositionVector(ed->shape), maxSegmentLength);
156  }
157  // build and insert the edge
158  NBEdge* e = new NBEdge(ed->id, from, to,
160  (int) ed->lanes.size(),
162  ed->shape, ed->lsf, ed->streetName, "", true); // always use tryIgnoreNodePositions to keep original shape
163  e->setLoadedLength(ed->length);
165  e->setDistance(ed->distance);
166  if (!myNetBuilder.getEdgeCont().insert(e)) {
167  WRITE_ERRORF(TL("Could not insert edge '%'."), ed->id);
168  delete e;
169  continue;
170  }
172  if (ed->builtEdge != nullptr) {
174  ed->builtEdge->setBidi(ed->bidi != "");
175  }
176  }
177  // assign further lane attributes (edges are built)
178  EdgeVector toRemove;
179  const bool dismissVclasses = oc.getBool("dismiss-vclasses");
180  for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
181  EdgeAttrs* ed = (*i).second;
182  NBEdge* nbe = ed->builtEdge;
183  if (nbe == nullptr) { // inner edge or removed by explicit list, vclass, ...
184  continue;
185  }
186  const SumoXMLNodeType toType = nbe->getToNode()->getType();
187  for (int fromLaneIndex = 0; fromLaneIndex < (int) ed->lanes.size(); ++fromLaneIndex) {
188  LaneAttrs* lane = ed->lanes[fromLaneIndex];
189  // connections
190  const std::vector<Connection>& connections = lane->connections;
191  for (const Connection& c : connections) {
192  if (myEdges.count(c.toEdgeID) == 0) {
193  WRITE_ERRORF(TL("Unknown edge '%' given in connection."), c.toEdgeID);
194  continue;
195  }
196  NBEdge* toEdge = myEdges[c.toEdgeID]->builtEdge;
197  if (toEdge == nullptr) { // removed by explicit list, vclass, ...
198  continue;
199  }
200  if (toEdge->getFromNode() != nbe->getToNode()) { // inconsistency may occur when merging networks
201  WRITE_WARNINGF("Removing invalid connection from edge '%' to edge '%'", nbe->getID(), toEdge->getID());
202  continue;
203  }
204  // patch attribute uncontrolled for legacy networks where it is not set explicitly
205  bool uncontrolled = c.uncontrolled;
206 
207  if ((NBNode::isTrafficLight(toType) || toType == SumoXMLNodeType::RAIL_SIGNAL)
208  && c.tlLinkIndex == NBConnection::InvalidTlIndex) {
209  uncontrolled = true;
210  }
212  fromLaneIndex, toEdge, c.toLaneIdx, NBEdge::Lane2LaneInfoType::VALIDATED,
213  true, c.mayDefinitelyPass, c.keepClear ? KEEPCLEAR_TRUE : KEEPCLEAR_FALSE,
214  c.contPos, c.visibility, c.speed, c.friction, c.customLength, c.customShape, uncontrolled, c.permissions, c.indirectLeft, c.edgeType, c.changeLeft, c.changeRight);
215  if (c.getParametersMap().size() > 0) {
216  nbe->getConnectionRef(fromLaneIndex, toEdge, c.toLaneIdx).updateParameters(c.getParametersMap());
217  }
218  // maybe we have a tls-controlled connection
219  if (c.tlID != "" && myRailSignals.count(c.tlID) == 0) {
220  const std::map<std::string, NBTrafficLightDefinition*>& programs = myTLLCont.getPrograms(c.tlID);
221  if (programs.size() > 0) {
222  std::map<std::string, NBTrafficLightDefinition*>::const_iterator it;
223  for (it = programs.begin(); it != programs.end(); it++) {
224  NBLoadedSUMOTLDef* tlDef = dynamic_cast<NBLoadedSUMOTLDef*>(it->second);
225  if (tlDef) {
226  tlDef->addConnection(nbe, toEdge, fromLaneIndex, c.toLaneIdx, c.tlLinkIndex, c.tlLinkIndex2, false);
227  } else {
228  throw ProcessError("Corrupt traffic light definition '" + c.tlID + "' (program '" + it->first + "')");
229  }
230  }
231  } else {
232  WRITE_ERRORF(TL("The traffic light '%' is not known."), c.tlID);
233  }
234  }
235  }
236  // allow/disallow XXX preferred
237  if (!dismissVclasses) {
238  nbe->setPermissions(parseVehicleClasses(lane->allow, lane->disallow, myNetworkVersion), fromLaneIndex);
239  }
240  nbe->setPermittedChanging(fromLaneIndex, parseVehicleClasses(lane->changeLeft, ""), parseVehicleClasses(lane->changeRight, ""));
241  // width, offset
242  nbe->setLaneWidth(fromLaneIndex, lane->width);
243  nbe->setEndOffset(fromLaneIndex, lane->endOffset);
244  nbe->setSpeed(fromLaneIndex, lane->maxSpeed);
245  nbe->setFriction(fromLaneIndex, lane->friction);
246  nbe->setAcceleration(fromLaneIndex, lane->accelRamp);
247  nbe->getLaneStruct(fromLaneIndex).oppositeID = lane->oppositeID;
248  nbe->getLaneStruct(fromLaneIndex).type = lane->type;
249  nbe->getLaneStruct(fromLaneIndex).updateParameters(lane->getParametersMap());
250  if (lane->customShape) {
251  nbe->setLaneShape(fromLaneIndex, lane->shape);
252  }
253  // stop offset for lane
254  bool stopOffsetSet = false;
255  if (lane->laneStopOffset.isDefined() || nbe->getEdgeStopOffset().isDefined()) {
256  // apply lane-specific stopOffset (might be none as well)
257  stopOffsetSet = nbe->setEdgeStopOffset(fromLaneIndex, lane->laneStopOffset);
258  }
259  if (!stopOffsetSet) {
260  // apply default stop offset to lane
261  nbe->setEdgeStopOffset(fromLaneIndex, nbe->getEdgeStopOffset());
262  }
263  }
265  if (!nbe->hasLaneSpecificWidth() && nbe->getLanes()[0].width != NBEdge::UNSPECIFIED_WIDTH) {
266  nbe->setLaneWidth(-1, nbe->getLaneWidth(0));
267  }
269  nbe->setEndOffset(-1, nbe->getEndOffset(0));
270  }
271  if (!nbe->hasLaneSpecificStopOffsets() && nbe->getEdgeStopOffset().isDefined()) {
272  nbe->setEdgeStopOffset(-1, nbe->getEdgeStopOffset());
273  }
274  // check again after permissions are set
277  toRemove.push_back(nbe);
278  }
279  }
280  for (EdgeVector::iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
282  }
283  // insert loaded prohibitions
284  for (std::vector<Prohibition>::const_iterator it = myProhibitions.begin(); it != myProhibitions.end(); it++) {
285  NBEdge* prohibitedFrom = myEdges[it->prohibitedFrom]->builtEdge;
286  NBEdge* prohibitedTo = myEdges[it->prohibitedTo]->builtEdge;
287  NBEdge* prohibitorFrom = myEdges[it->prohibitorFrom]->builtEdge;
288  NBEdge* prohibitorTo = myEdges[it->prohibitorTo]->builtEdge;
289  if (prohibitedFrom == nullptr) {
290  WRITE_WARNINGF(TL("Edge '%' in prohibition was not built."), it->prohibitedFrom);
291  } else if (prohibitedTo == nullptr) {
292  WRITE_WARNINGF(TL("Edge '%' in prohibition was not built."), it->prohibitedTo);
293  } else if (prohibitorFrom == nullptr) {
294  WRITE_WARNINGF(TL("Edge '%' in prohibition was not built."), it->prohibitorFrom);
295  } else if (prohibitorTo == nullptr) {
296  WRITE_WARNINGF(TL("Edge '%' in prohibition was not built."), it->prohibitorTo);
297  } else {
298  NBNode* n = prohibitedFrom->getToNode();
300  NBConnection(prohibitorFrom, prohibitorTo),
301  NBConnection(prohibitedFrom, prohibitedTo));
302  }
303  }
304  if (!myHaveSeenInternalEdge && oc.isWriteable("no-internal-links")) {
305  oc.set("no-internal-links", "true");
306  }
307  if (oc.isWriteable("lefthand")) {
308  oc.set("lefthand", toString(myAmLefthand));
309  }
310  if (oc.isWriteable("junctions.corner-detail")) {
311  oc.set("junctions.corner-detail", toString(myCornerDetail));
312  }
313  if (oc.isWriteable("junctions.internal-link-detail") && myLinkDetail > 0) {
314  oc.set("junctions.internal-link-detail", toString(myLinkDetail));
315  }
316  if (oc.isWriteable("rectangular-lane-cut")) {
317  oc.set("rectangular-lane-cut", toString(myRectLaneCut));
318  }
319  if (oc.isWriteable("walkingareas")) {
320  oc.set("walkingareas", toString(myWalkingAreas));
321  }
322  if (oc.isWriteable("junctions.limit-turn-speed")) {
323  oc.set("junctions.limit-turn-speed", toString(myLimitTurnSpeed));
324  }
325  if (oc.isWriteable("check-lane-foes.all") && oc.getBool("check-lane-foes.all") != myCheckLaneFoesAll) {
326  oc.set("check-lane-foes.all", toString(myCheckLaneFoesAll));
327  }
328  if (oc.isWriteable("check-lane-foes.roundabout") && oc.getBool("check-lane-foes.roundabout") != myCheckLaneFoesRoundabout) {
329  oc.set("check-lane-foes.roundabout", toString(myCheckLaneFoesRoundabout));
330  }
331  if (oc.isWriteable("tls.ignore-internal-junction-jam") && oc.getBool("tls.ignore-internal-junction-jam") != myTlsIgnoreInternalJunctionJam) {
332  oc.set("tls.ignore-internal-junction-jam", toString(myTlsIgnoreInternalJunctionJam));
333  }
334  if (oc.isWriteable("default.spreadtype") && oc.getString("default.spreadtype") != myDefaultSpreadType) {
335  oc.set("default.spreadtype", myDefaultSpreadType);
336  }
337  if (oc.isWriteable("geometry.avoid-overlap") && oc.getBool("geometry.avoid-overlap") != myGeomAvoidOverlap) {
338  oc.set("geometry.avoid-overlap", toString(myGeomAvoidOverlap));
339  }
340  if (oc.isWriteable("junctions.higher-speed") && oc.getBool("junctions.higher-speed") != myJunctionsHigherSpeed) {
341  oc.set("junctions.higher-speed", toString(myJunctionsHigherSpeed));
342  }
343  if (oc.isWriteable("internal-junctions.vehicle-width") && oc.getFloat("internal-junctions.vehicle-width") != myInternalJunctionsVehicleWidth) {
344  oc.set("internal-junctions.vehicle-width", toString(myInternalJunctionsVehicleWidth));
345  }
346  if (oc.isWriteable("junctions.minimal-shape") && oc.getBool("junctions.minimal-shape") != myJunctionsMinimalShape) {
347  oc.set("junctions.minimal-shape", toString(myJunctionsMinimalShape));
348  }
349  if (oc.isWriteable("junctions.endpoint-shape") && oc.getBool("junctions.endpoint-shape") != myJunctionsEndpointShape) {
350  oc.set("junctions.endpoint-shape", toString(myJunctionsEndpointShape));
351  }
352  if (!deprecatedVehicleClassesSeen.empty()) {
353  WRITE_WARNINGF(TL("Deprecated vehicle class(es) '%' in input network."), toString(deprecatedVehicleClassesSeen));
355  }
356  if (!oc.getBool("no-internal-links")) {
357  // add loaded crossings
358  for (const auto& crossIt : myPedestrianCrossings) {
359  NBNode* const node = myNodeCont.retrieve(crossIt.first);
360  for (const Crossing& crossing : crossIt.second) {
361  EdgeVector edges;
362  for (const std::string& edgeID : crossing.crossingEdges) {
363  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeID);
364  // edge might have been removed due to options
365  if (edge != nullptr) {
366  edges.push_back(edge);
367  }
368  }
369  if (!edges.empty()) {
370  node->addCrossing(edges, crossing.width, crossing.priority,
371  crossing.customTLIndex, crossing.customTLIndex2, crossing.customShape, true, &crossing);
372  }
373  }
374  }
375  // add walking area custom shapes
376  for (const auto& item : myWACustomShapes) {
377  std::string nodeID = SUMOXMLDefinitions::getJunctionIDFromInternalEdge(item.first);
378  NBNode* node = myNodeCont.retrieve(nodeID);
379  std::vector<std::string> edgeIDs;
380  if (item.second.fromEdges.size() + item.second.toEdges.size() == 0) {
381  // must be a split crossing
382  assert(item.second.fromCrossed.size() > 0);
383  assert(item.second.toCrossed.size() > 0);
384  edgeIDs = item.second.fromCrossed;
385  edgeIDs.insert(edgeIDs.end(), item.second.toCrossed.begin(), item.second.toCrossed.end());
386  } else if (item.second.fromEdges.size() > 0) {
387  edgeIDs = item.second.fromEdges;
388  } else {
389  edgeIDs = item.second.toEdges;
390  }
391  EdgeVector edges;
392  for (const std::string& edgeID : edgeIDs) {
393  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeID);
394  // edge might have been removed due to options
395  if (edge != nullptr) {
396  edges.push_back(edge);
397  }
398  }
399  if (edges.size() > 0) {
400  node->addWalkingAreaShape(edges, item.second.shape, item.second.width);
401  }
402  }
403  }
404  // add roundabouts
405  for (const std::vector<std::string>& ra : myRoundabouts) {
406  EdgeSet roundabout;
407  for (const std::string& edgeID : ra) {
408  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeID);
409  if (edge == nullptr) {
410  if (!myNetBuilder.getEdgeCont().wasIgnored(edgeID)) {
411  WRITE_ERRORF(TL("Unknown edge '%' in roundabout"), (edgeID));
412  }
413  } else {
414  roundabout.insert(edge);
415  }
416  }
417  myNetBuilder.getEdgeCont().addRoundabout(roundabout);
418  }
419 }
420 
421 
422 void
424  const SUMOSAXAttributes& attrs) {
425  /* our goal is to reproduce the input net faithfully
426  * there are different types of objects in the netfile:
427  * 1) those which must be loaded into NBNetBuilder-Containers for processing
428  * 2) those which can be ignored because they are recomputed based on group 1
429  * 3) those which are of no concern to NBNetBuilder but should be exposed to
430  * netedit. We will probably have to patch NBNetBuilder to contain them
431  * and hand them over to netedit
432  * alternative idea: those shouldn't really be contained within the
433  * network but rather in separate files. teach netedit how to open those
434  * (POI?)
435  * 4) those which are of concern neither to NBNetBuilder nor netedit and
436  * must be copied over - need to patch NBNetBuilder for this.
437  * copy unknown by default
438  */
439  switch (element) {
440  case SUMO_TAG_NET: {
441  bool ok;
442  myNetworkVersion = StringUtils::toVersion(attrs.get<std::string>(SUMO_ATTR_VERSION, nullptr, ok, false));
443  myAmLefthand = attrs.getOpt<bool>(SUMO_ATTR_LEFTHAND, nullptr, ok, false);
444  myCornerDetail = attrs.getOpt<int>(SUMO_ATTR_CORNERDETAIL, nullptr, ok, 0);
445  myLinkDetail = attrs.getOpt<int>(SUMO_ATTR_LINKDETAIL, nullptr, ok, -1);
446  myRectLaneCut = attrs.getOpt<bool>(SUMO_ATTR_RECTANGULAR_LANE_CUT, nullptr, ok, false);
447  myWalkingAreas = attrs.getOpt<bool>(SUMO_ATTR_WALKINGAREAS, nullptr, ok, false);
448  myLimitTurnSpeed = attrs.getOpt<double>(SUMO_ATTR_LIMIT_TURN_SPEED, nullptr, ok, -1);
449  myCheckLaneFoesAll = attrs.getOpt<bool>(SUMO_ATTR_CHECKLANEFOES_ALL, nullptr, ok, false);
450  myCheckLaneFoesRoundabout = attrs.getOpt<bool>(SUMO_ATTR_CHECKLANEFOES_ROUNDABOUT, nullptr, ok, true);
452  myDefaultSpreadType = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, nullptr, ok, myDefaultSpreadType);
458  // derived
459  const OptionsCont& oc = OptionsCont::getOptions();
460  myChangeLefthand = !oc.isDefault("lefthand") && (oc.getBool("lefthand") != myAmLefthand);
461 
462  break;
463  }
464  case SUMO_TAG_EDGE:
465  addEdge(attrs);
466  break;
467  case SUMO_TAG_LANE:
468  addLane(attrs);
469  break;
470  case SUMO_TAG_STOPOFFSET: {
471  bool ok = true;
472  addStopOffsets(attrs, ok);
473  }
474  break;
475  case SUMO_TAG_NEIGH:
477  break;
478  case SUMO_TAG_JUNCTION:
479  addJunction(attrs);
480  break;
481  case SUMO_TAG_REQUEST:
482  addRequest(attrs);
483  break;
484  case SUMO_TAG_CONNECTION:
485  addConnection(attrs);
486  break;
487  case SUMO_TAG_TLLOGIC:
489  if (myCurrentTL) {
490  myLastParameterised.push_back(myCurrentTL);
491  }
492  break;
493  case SUMO_TAG_PHASE:
494  addPhase(attrs, myCurrentTL);
495  break;
496  case SUMO_TAG_LOCATION:
497  delete myLocation;
498  myLocation = loadLocation(attrs);
499  break;
501  addProhibition(attrs);
502  break;
503  case SUMO_TAG_ROUNDABOUT:
504  addRoundabout(attrs);
505  break;
506  case SUMO_TAG_PARAM:
507  if (myLastParameterised.size() != 0) {
508  bool ok = true;
509  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
510  if (myDiscardableParams.count(key) == 0) {
511  // circumventing empty string test
512  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
513  myLastParameterised.back()->setParameter(key, val);
514  }
515  }
516  break;
517  default:
518  myTypesHandler.myStartElement(element, attrs);
519  break;
520  }
521 }
522 
523 
524 void
526  switch (element) {
527  case SUMO_TAG_EDGE:
528  if (myCurrentEdge != nullptr) {
529  if (myEdges.find(myCurrentEdge->id) != myEdges.end()) {
530  WRITE_WARNINGF(TL("Edge '%' occurred at least twice in the input."), myCurrentEdge->id);
531  for (LaneAttrs* const lane : myCurrentEdge->lanes) {
532  delete lane;
533  }
534  delete myCurrentEdge;
535  } else {
537  }
538  myCurrentEdge = nullptr;
539  myLastParameterised.pop_back();
540  }
541  break;
542  case SUMO_TAG_LANE:
543  if (myCurrentEdge != nullptr && myCurrentLane != nullptr) {
545  myCurrentEdge->lanes.push_back(myCurrentLane);
546  myLastParameterised.pop_back();
547  }
548  myCurrentLane = nullptr;
549  break;
550  case SUMO_TAG_TLLOGIC:
551  if (myCurrentTL == nullptr) {
552  WRITE_ERROR(TL("Unmatched closing tag for tl-logic."));
553  } else {
554  if (!myTLLCont.insert(myCurrentTL)) {
555  WRITE_WARNINGF(TL("Could not add program '%' for traffic light '%'"), myCurrentTL->getProgramID(), myCurrentTL->getID());
556  delete myCurrentTL;
557  }
558  myCurrentTL = nullptr;
559  myLastParameterised.pop_back();
560  }
561  break;
562  case SUMO_TAG_JUNCTION:
563  if (myCurrentJunction.node != nullptr) {
564  myLastParameterised.pop_back();
565  }
566  break;
567  case SUMO_TAG_CONNECTION:
568  // !!! this just avoids a crash but is not a real check that it was a connection
569  if (!myLastParameterised.empty()) {
570  myLastParameterised.pop_back();
571  }
572  break;
573  default:
574  break;
575  }
576 }
577 
578 
579 void
581  // get the id, report an error if not given or empty...
582  bool ok = true;
583  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
584  if (!ok) {
585  return;
586  }
587  myCurrentEdge = new EdgeAttrs();
589  myCurrentEdge->builtEdge = nullptr;
590  myCurrentEdge->id = id;
591  // get the function
594  // add the crossing but don't do anything else
595  Crossing c(id);
596  c.crossingEdges = attrs.get<std::vector<std::string> >(SUMO_ATTR_CROSSING_EDGES, nullptr, ok);
598  return;
600  myHaveSeenInternalEdge = true;
601  return; // skip internal edges
602  }
603  // get the type
604  myCurrentEdge->type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
605  // get the origin and the destination node
606  myCurrentEdge->fromNode = attrs.getOpt<std::string>(SUMO_ATTR_FROM, id.c_str(), ok, "");
607  myCurrentEdge->toNode = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "");
608  myCurrentEdge->priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1);
609  myCurrentEdge->type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
613  myCurrentEdge->maxSpeed = 0;
614  myCurrentEdge->streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
615  myCurrentEdge->distance = attrs.getOpt<double>(SUMO_ATTR_DISTANCE, id.c_str(), ok, 0);
616  myCurrentEdge->bidi = attrs.getOpt<std::string>(SUMO_ATTR_BIDI, id.c_str(), ok, "");
617  if (myCurrentEdge->streetName != "" && OptionsCont::getOptions().isDefault("output.street-names")) {
618  OptionsCont::getOptions().set("output.street-names", "true");
619  }
620 
621  std::string lsfS = attrs.getOpt<std::string>(SUMO_ATTR_SPREADTYPE, id.c_str(), ok, myDefaultSpreadType);
622  if (SUMOXMLDefinitions::LaneSpreadFunctions.hasString(lsfS)) {
624  } else {
625  WRITE_ERRORF(TL("Unknown spreadType '%' for edge '%'."), lsfS, id);
626  }
627 }
628 
629 
630 void
632  bool ok = true;
633  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
634  if (!ok) {
635  return;
636  }
637  if (myCurrentEdge == nullptr) {
638  WRITE_ERRORF(TL("Found lane '%' not within edge element."), id);
639  return;
640  }
641  const std::string expectedID = myCurrentEdge->id + "_" + toString(myCurrentEdge->lanes.size());
642  if (id != expectedID) {
643  WRITE_WARNINGF(TL("Renaming lane '%' to '%'."), id, expectedID);
644  }
645  myCurrentLane = new LaneAttrs();
647  myCurrentLane->customShape = attrs.getOpt<bool>(SUMO_ATTR_CUSTOMSHAPE, nullptr, ok, false);
648  myCurrentLane->shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
649  myCurrentLane->width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, (double) NBEdge::UNSPECIFIED_WIDTH);
650  myCurrentLane->type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
652  // save the width and the lane id of the crossing but don't do anything else
654  assert(crossings.size() > 0);
655  crossings.back().width = attrs.get<double>(SUMO_ATTR_WIDTH, id.c_str(), ok);
656  myLastParameterised.pop_back();
657  myLastParameterised.push_back(&crossings.back());
658  if (myCurrentLane->customShape) {
659  crossings.back().customShape = myCurrentLane->shape;
660  NBNetBuilder::transformCoordinates(crossings.back().customShape, true, myLocation);
661  }
663  // save custom shape if needed but don't do anything else
664  if (myCurrentLane->customShape) {
666  wacs.shape = myCurrentLane->shape;
667  wacs.width = myCurrentLane->width;
670  }
671  return;
673  return; // skip internal edges
674  }
675  if (attrs.hasAttribute("maxspeed")) {
676  // !!! deprecated
677  myCurrentLane->maxSpeed = attrs.getFloat("maxspeed");
678  } else {
679  myCurrentLane->maxSpeed = attrs.get<double>(SUMO_ATTR_SPEED, id.c_str(), ok);
680  }
681  myCurrentLane->friction = attrs.getOpt<double>(SUMO_ATTR_FRICTION, id.c_str(), ok, NBEdge::UNSPECIFIED_FRICTION, false); //sets 1 on empty
682  try {
683  myCurrentLane->allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "", false);
684  } catch (EmptyData&) {
685  // !!! deprecated
686  myCurrentLane->allow = "";
687  }
688  myCurrentLane->disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
689  myCurrentLane->endOffset = attrs.getOpt<double>(SUMO_ATTR_ENDOFFSET, id.c_str(), ok, (double) NBEdge::UNSPECIFIED_OFFSET);
690  myCurrentLane->accelRamp = attrs.getOpt<bool>(SUMO_ATTR_ACCELERATION, id.c_str(), ok, false);
691  myCurrentLane->changeLeft = attrs.getOpt<std::string>(SUMO_ATTR_CHANGE_LEFT, id.c_str(), ok, "");
692  myCurrentLane->changeRight = attrs.getOpt<std::string>(SUMO_ATTR_CHANGE_RIGHT, id.c_str(), ok, "");
693  if (myChangeLefthand) {
695  }
696 
697  // lane coordinates are derived (via lane spread) do not include them in convex boundary
699 }
700 
701 
702 void
704  const StopOffset offset(attrs, ok);
705  if (!ok) {
706  return;
707  }
708  // Admissibility of value will be checked in _loadNetwork(), when lengths are known
709  if (myCurrentLane == nullptr) {
711  WRITE_WARNINGF(TL("Duplicate definition of stopOffset for edge %.\nIgnoring duplicate specification."), myCurrentEdge->id);
712  } else {
713  myCurrentEdge->edgeStopOffset = offset;
714  }
715  } else {
717  WRITE_WARNINGF(TL("Duplicate definition of lane's stopOffset on edge %.\nIgnoring duplicate specifications."), myCurrentEdge->id);
718  } else {
719  myCurrentLane->laneStopOffset = offset;
720  }
721  }
722 }
723 
724 
725 void
727  // get the id, report an error if not given or empty...
728  myCurrentJunction.node = nullptr;
729  myCurrentJunction.intLanes.clear();
730  myCurrentJunction.response.clear();
731  bool ok = true;
732  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
733  if (!ok) {
734  return;
735  }
736  if (id[0] == ':') { // internal node
737  return;
738  }
740  if (ok) {
742  // dead end is a computed status. Reset this to unknown so it will
743  // be corrected if additional connections are loaded
745  } else if (type == SumoXMLNodeType::INTERNAL) {
746  WRITE_WARNINGF("Invalid node type '%' for junction '%' in input network", toString(SumoXMLNodeType::INTERNAL), id);
748  }
749  }
750  Position pos = readPosition(attrs, id, ok);
752  NBNode* node = new NBNode(id, pos, type);
753  if (!myNodeCont.insert(node)) {
754  WRITE_WARNINGF(TL("Junction '%' occurred at least twice in the input."), id);
755  delete node;
756  myLastParameterised.push_back(myNodeCont.retrieve(id));
757  return;
758  } else {
759  myLastParameterised.push_back(node);
760  }
761  myCurrentJunction.node = node;
762  myCurrentJunction.intLanes = attrs.get<std::vector<std::string> >(SUMO_ATTR_INTLANES, nullptr, ok, false);
763  // set optional radius
764  if (attrs.hasAttribute(SUMO_ATTR_RADIUS)) {
765  node->setRadius(attrs.get<double>(SUMO_ATTR_RADIUS, id.c_str(), ok));
766  }
767  // handle custom shape
768  if (attrs.getOpt<bool>(SUMO_ATTR_CUSTOMSHAPE, id.c_str(), ok, false)) {
769  PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
771  node->setCustomShape(shape);
772  }
774  // both types of nodes come without a tlLogic
775  myRailSignals.insert(id);
776  }
777  node->setRightOfWay(attrs.getOpt<RightOfWay>(SUMO_ATTR_RIGHT_OF_WAY, id.c_str(), ok, node->getRightOfWay()));
778  node->setFringeType(attrs.getOpt<FringeType>(SUMO_ATTR_FRINGE, id.c_str(), ok, node->getFringeType()));
779  if (attrs.hasAttribute(SUMO_ATTR_NAME)) {
780  node->setName(attrs.get<std::string>(SUMO_ATTR_NAME, id.c_str(), ok));
781  }
782 }
783 
784 
785 void
787  if (myCurrentJunction.node != nullptr) {
788  bool ok = true;
789  myCurrentJunction.response.push_back(attrs.get<std::string>(SUMO_ATTR_RESPONSE, nullptr, ok));
790  }
791 }
792 
793 
794 void
796  bool ok = true;
797  std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, nullptr, ok);
798  if (myEdges.count(fromID) == 0) {
799  WRITE_ERRORF(TL("Unknown edge '%' given in connection."), fromID);
800  return;
801  }
802  EdgeAttrs* from = myEdges[fromID];
803  if (from->func == SumoXMLEdgeFunc::INTERNAL) {
804  // internal junction connection
805  return;
806  }
807  Connection conn;
808  conn.toEdgeID = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
809  int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, nullptr, ok);
810  conn.toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, nullptr, ok);
811  conn.tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, nullptr, ok, "");
812  conn.mayDefinitelyPass = attrs.getOpt<bool>(SUMO_ATTR_PASS, nullptr, ok, false);
813  conn.keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, nullptr, ok, true);
814  conn.indirectLeft = attrs.getOpt<bool>(SUMO_ATTR_INDIRECT, nullptr, ok, false);
815  conn.edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, nullptr, ok, "");
816  conn.contPos = attrs.getOpt<double>(SUMO_ATTR_CONTPOS, nullptr, ok, NBEdge::UNSPECIFIED_CONTPOS);
818  std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, "", false);
819  std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, "", false);
820  if (allow == "" && disallow == "") {
822  } else {
823  conn.permissions = parseVehicleClasses(allow, disallow, myNetworkVersion);
824  }
825  if (attrs.hasAttribute(SUMO_ATTR_CHANGE_LEFT)) {
826  conn.changeLeft = parseVehicleClasses(attrs.get<std::string>(SUMO_ATTR_CHANGE_LEFT, nullptr, ok), "");
827  } else {
829  }
831  conn.changeRight = parseVehicleClasses(attrs.get<std::string>(SUMO_ATTR_CHANGE_RIGHT, nullptr, ok), "");
832  } else {
834  }
835  if (myChangeLefthand) {
836  std::swap(conn.changeLeft, conn.changeRight);
837  }
838  conn.speed = attrs.getOpt<double>(SUMO_ATTR_SPEED, nullptr, ok, NBEdge::UNSPECIFIED_SPEED);
839  conn.friction = attrs.getOpt<double>(SUMO_ATTR_FRICTION, nullptr, ok, NBEdge::UNSPECIFIED_FRICTION);
840  conn.customLength = attrs.getOpt<double>(SUMO_ATTR_LENGTH, nullptr, ok, NBEdge::UNSPECIFIED_LOADED_LENGTH);
844  if (conn.tlID != "") {
845  conn.tlLinkIndex = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok);
846  conn.tlLinkIndex2 = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX2, nullptr, ok, -1);
847  } else {
849  }
850  if ((int)from->lanes.size() <= fromLaneIdx) {
851  WRITE_ERRORF(TL("Invalid lane index '%' for connection from '%'."), toString(fromLaneIdx), fromID);
852  return;
853  }
854  from->lanes[fromLaneIdx]->connections.push_back(conn);
855  myLastParameterised.push_back(&from->lanes[fromLaneIdx]->connections.back());
856 
857  // determine crossing priority and tlIndex
858  if (myPedestrianCrossings.size() > 0) {
860  // connection from walkingArea to crossing
861  std::vector<Crossing>& crossings = myPedestrianCrossings[SUMOXMLDefinitions::getJunctionIDFromInternalEdge(fromID)];
862  for (std::vector<Crossing>::iterator it = crossings.begin(); it != crossings.end(); ++it) {
863  if (conn.toEdgeID == (*it).edgeID) {
864  if (conn.tlID != "") {
865  (*it).priority = true;
866  (*it).customTLIndex = conn.tlLinkIndex;
867  } else {
868  LinkState state = SUMOXMLDefinitions::LinkStates.get(attrs.get<std::string>(SUMO_ATTR_STATE, nullptr, ok));
869  (*it).priority = state == LINKSTATE_MAJOR;
870  }
871  }
872  }
873  } else if (from->func == SumoXMLEdgeFunc::CROSSING && myEdges[conn.toEdgeID]->func == SumoXMLEdgeFunc::WALKINGAREA) {
874  // connection from crossing to walkingArea (set optional linkIndex2)
876  if (fromID == c.edgeID) {
877  c.customTLIndex2 = attrs.getOpt<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok, -1);
878  }
879  }
880  }
881  }
882  // determine walking area reference edges
883  if (myWACustomShapes.size() > 0) {
884  EdgeAttrs* to = myEdges[conn.toEdgeID];
885  if (from->func == SumoXMLEdgeFunc::WALKINGAREA) {
886  std::map<std::string, WalkingAreaParsedCustomShape>::iterator it = myWACustomShapes.find(fromID);
887  if (it != myWACustomShapes.end()) {
888  if (to->func == SumoXMLEdgeFunc::NORMAL) {
889  // add target sidewalk as reference
890  it->second.toEdges.push_back(conn.toEdgeID);
891  } else if (to->func == SumoXMLEdgeFunc::CROSSING) {
892  // add target crossing edges as reference
894  if (conn.toEdgeID == crossing.edgeID) {
895  it->second.toCrossed.insert(it->second.toCrossed.end(), crossing.crossingEdges.begin(), crossing.crossingEdges.end());
896  }
897  }
898  }
899  }
900  } else if (to->func == SumoXMLEdgeFunc::WALKINGAREA) {
901  std::map<std::string, WalkingAreaParsedCustomShape>::iterator it = myWACustomShapes.find(conn.toEdgeID);
902  if (it != myWACustomShapes.end()) {
903  if (from->func == SumoXMLEdgeFunc::NORMAL) {
904  // add origin sidewalk as reference
905  it->second.fromEdges.push_back(fromID);
906  } else if (from->func == SumoXMLEdgeFunc::CROSSING) {
907  // add origin crossing edges as reference
909  if (fromID == crossing.edgeID) {
910  it->second.fromCrossed.insert(it->second.fromCrossed.end(), crossing.crossingEdges.begin(), crossing.crossingEdges.end());
911  }
912  }
913  }
914  }
915  }
916  }
917 }
918 
919 
920 void
922  bool ok = true;
923  std::string prohibitor = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITOR, nullptr, ok, "");
924  std::string prohibited = attrs.getOpt<std::string>(SUMO_ATTR_PROHIBITED, nullptr, ok, "");
925  if (!ok) {
926  return;
927  }
928  Prohibition p;
931  if (!ok) {
932  return;
933  }
934  myProhibitions.push_back(p);
935 }
936 
937 
940  if (currentTL) {
941  WRITE_ERRORF(TL("Definition of tl-logic '%' was not finished."), currentTL->getID());
942  return nullptr;
943  }
944  bool ok = true;
945  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
946  SUMOTime offset = TIME2STEPS(attrs.get<double>(SUMO_ATTR_OFFSET, id.c_str(), ok));
947  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
948  std::string typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, nullptr, ok);
949  TrafficLightType type;
950  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
952  } else {
953  WRITE_ERRORF(TL("Unknown traffic light type '%' for tlLogic '%'."), typeS, id);
954  return nullptr;
955  }
956  if (ok) {
957  return new NBLoadedSUMOTLDef(id, programID, offset, type);
958  } else {
959  return nullptr;
960  }
961 }
962 
963 
964 void
966  if (!currentTL) {
967  WRITE_ERROR(TL("found phase without tl-logic"));
968  return;
969  }
970  const std::string& id = currentTL->getID();
971  bool ok = true;
972  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, id.c_str(), ok);
973  SUMOTime duration = TIME2STEPS(attrs.get<double>(SUMO_ATTR_DURATION, id.c_str(), ok));
974  if (duration < 0) {
975  WRITE_ERRORF(TL("Phase duration for tl-logic '%/%' must be positive."), id, currentTL->getProgramID());
976  return;
977  }
978  // if the traffic light is an actuated traffic light, try to get the minimum and maximum durations and ends
979  std::vector<int> nextPhases = attrs.getOpt<std::vector<int> >(SUMO_ATTR_NEXT, id.c_str(), ok);
980  const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, nullptr, ok);
981  // Specific from actuated
986  // specific von NEMA
990  if (ok) {
991  currentTL->addPhase(duration, state, minDuration, maxDuration, earliestEnd, latestEnd, vehExt, yellow, red, nextPhases, name);
992  }
993 }
994 
995 
997 NIImporter_SUMO::loadLocation(const SUMOSAXAttributes& attrs, bool setLoaded) {
998  // @todo refactor parsing of location since its duplicated in NLHandler and PCNetProjectionLoader
999  bool ok = true;
1000  GeoConvHelper* result = nullptr;
1001  PositionVector s = attrs.get<PositionVector>(SUMO_ATTR_NET_OFFSET, nullptr, ok);
1002  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, nullptr, ok);
1003  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, nullptr, ok);
1004  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, nullptr, ok);
1005  if (ok) {
1006  Position networkOffset = s[0];
1007  result = new GeoConvHelper(proj, networkOffset, origBoundary, convBoundary);
1008  result->resolveAbstractProjection();
1009  if (setLoaded) {
1010  GeoConvHelper::setLoaded(*result);
1011  }
1012  }
1013  return result;
1014 }
1015 
1016 
1017 Position
1018 NIImporter_SUMO::readPosition(const SUMOSAXAttributes& attrs, const std::string& id, bool& ok) {
1019  const double x = attrs.get<double>(SUMO_ATTR_X, id.c_str(), ok);
1020  const double y = attrs.get<double>(SUMO_ATTR_Y, id.c_str(), ok);
1021  const double z = attrs.getOpt<double>(SUMO_ATTR_Z, id.c_str(), ok, 0.);
1022  return Position(x, y, z);
1023 }
1024 
1025 
1026 void
1027 NIImporter_SUMO::parseProhibitionConnection(const std::string& attr, std::string& from, std::string& to, bool& ok) {
1028  // split from/to
1029  const std::string::size_type div = attr.find("->");
1030  if (div == std::string::npos) {
1031  WRITE_ERRORF(TL("Missing connection divider in prohibition attribute '%'"), attr);
1032  ok = false;
1033  }
1034  from = attr.substr(0, div);
1035  to = attr.substr(div + 2);
1036  // check whether the edges are known
1037  if (myEdges.count(from) == 0) {
1038  WRITE_ERRORF(TL("Unknown edge prohibition '%'"), from);
1039  ok = false;
1040  }
1041  if (myEdges.count(to) == 0) {
1042  WRITE_ERRORF(TL("Unknown edge prohibition '%'"), to);
1043  ok = false;
1044  }
1045 }
1046 
1047 
1048 void
1050  bool ok = true;
1051  const std::vector<std::string>& edgeIDs = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, nullptr, ok);
1052  if (ok) {
1053  myRoundabouts.push_back(edgeIDs);
1054  }
1055 }
1056 
1057 
1058 /****************************************************************************/
long long int SUMOTime
Definition: GUI.h:35
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:296
#define WRITE_ERRORF(...)
Definition: MsgHandler.h:305
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:304
#define PROGRESS_BEGIN_TIME_MESSAGE(msg)
Definition: MsgHandler.h:301
#define TL(string)
Definition: MsgHandler.h:315
#define PROGRESS_TIME_MESSAGE(before)
Definition: MsgHandler.h:302
std::set< NBEdge * > EdgeSet
container for unique edges
Definition: NBCont.h:50
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:35
@ KEEPCLEAR_FALSE
Definition: NBCont.h:59
@ KEEPCLEAR_TRUE
Definition: NBCont.h:60
#define TIME2STEPS(x)
Definition: SUMOTime.h:57
std::set< std::string > deprecatedVehicleClassesSeen
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
@ RIGHT
At the rightmost side of the lane.
TrafficLightType
@ SUMO_TAG_PHASE
a single phase description
@ SUMO_TAG_NET
root element of a network file
@ SUMO_TAG_STOPOFFSET
Information on vClass specific stop offsets at lane end.
@ SUMO_TAG_REQUEST
description of a logic request within the junction
@ SUMO_TAG_PROHIBITION
prohibition of circulation between two edges
@ SUMO_TAG_LOCATION
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_ROUNDABOUT
roundabout defined in junction
@ SUMO_TAG_TLLOGIC
a traffic light logic
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_NEIGH
begin/end of the description of a neighboring lane
@ SUMO_TAG_EDGE
begin/end of the description of an edge
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
FringeType
classifying boundary nodes
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_MAJOR
This is an uncontrolled, major link, may pass.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
RightOfWay
algorithms for computing right of way
@ SUMO_ATTR_JUNCTIONS_MINIMAL_SHAPE
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_CONV_BOUNDARY
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ SUMO_ATTR_NET_OFFSET
@ SUMO_ATTR_ORIG_BOUNDARY
@ SUMO_ATTR_LATEST_END
The maximum time within the cycle for switching (for coordinated actuation)
@ SUMO_ATTR_TLLINKINDEX2
link: the index of the opposite direction link of a pedestrian crossing
@ SUMO_ATTR_RED
red duration of a phase
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_LINKDETAIL
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_CORNERDETAIL
@ SUMO_ATTR_RADIUS
The turning radius at an intersection in m.
@ SUMO_ATTR_INDIRECT
Whether this connection is an indirect (left) turn.
@ SUMO_ATTR_RECTANGULAR_LANE_CUT
@ SUMO_ATTR_Y
@ SUMO_ATTR_FROM_LANE
@ SUMO_ATTR_Z
@ SUMO_ATTR_RESPONSE
@ SUMO_ATTR_LIMIT_TURN_SPEED
@ SUMO_ATTR_CHECKLANEFOES_ROUNDABOUT
@ SUMO_ATTR_OFFSET
@ SUMO_ATTR_X
@ SUMO_ATTR_AVOID_OVERLAP
@ SUMO_ATTR_YELLOW
yellow duration of a phase
@ SUMO_ATTR_CUSTOMSHAPE
whether a given shape is user-defined
@ SUMO_ATTR_INTLANES
@ SUMO_ATTR_VEHICLEEXTENSION
vehicle extension time of a phase
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_FRINGE
Fringe type of node.
@ SUMO_ATTR_BIDI
@ SUMO_ATTR_PROHIBITED
@ SUMO_ATTR_PRIORITY
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_LEFTHAND
@ SUMO_ATTR_NEXT
succesor phase index
@ SUMO_ATTR_CHANGE_LEFT
@ SUMO_ATTR_NAME
@ SUMO_ATTR_ORIG_PROJ
@ SUMO_ATTR_JUNCTIONS_ENDPOINT_SHAPE
@ SUMO_ATTR_CHECKLANEFOES_ALL
@ SUMO_ATTR_SPREADTYPE
The information about how to spread the lanes from the given position.
@ SUMO_ATTR_PASS
@ SUMO_ATTR_ENDOFFSET
@ SUMO_ATTR_HIGHER_SPEED
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_ACCELERATION
@ SUMO_ATTR_CHANGE_RIGHT
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_DISTANCE
@ SUMO_ATTR_TO_LANE
@ SUMO_ATTR_UNCONTROLLED
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_VERSION
@ SUMO_ATTR_ID
@ SUMO_ATTR_MAXDURATION
maximum duration of a phase
@ SUMO_ATTR_RIGHT_OF_WAY
How to compute right of way.
@ SUMO_ATTR_PROGRAMID
@ SUMO_ATTR_FUNCTION
@ SUMO_ATTR_VISIBILITY_DISTANCE
foe visibility distance of a link
@ SUMO_ATTR_PROHIBITOR
@ SUMO_ATTR_DURATION
@ SUMO_ATTR_CONTPOS
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_CROSSING_EDGES
the edges crossed by a pedestrian crossing
@ SUMO_ATTR_TLS_IGNORE_INTERNAL_JUNCTION_JAM
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
@ SUMO_ATTR_MINDURATION
@ SUMO_ATTR_KEY
@ SUMO_ATTR_KEEP_CLEAR
Whether vehicles must keep the junction clear.
@ SUMO_ATTR_INTERNAL_JUNCTIONS_VEHICLE_WIDTH
@ SUMO_ATTR_STATE
The state of a link.
@ SUMO_ATTR_FRICTION
@ SUMO_ATTR_WALKINGAREAS
@ SUMO_ATTR_EARLIEST_END
The minimum time within the cycle for switching (for coordinated actuation)
T MAX2(T a, T b)
Definition: StdDefs.h:82
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:51
void setFileName(const std::string &name)
Sets the current file name.
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:53
void resolveAbstractProjection()
init projString such as 'UTM' in loaded projection
static void setLoaded(const GeoConvHelper &loaded)
sets the coordinate transformation loaded from a location element
static const int InvalidTlIndex
Definition: NBConnection.h:123
void addRoundabout(const EdgeSet &roundabout)
add user specified roundabout
void erase(NBDistrictCont &dc, NBEdge *edge)
Removes the given edge from the container (deleting it)
Definition: NBEdgeCont.cpp:411
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:281
bool ignoreFilterMatch(NBEdge *edge)
Returns true if this edge matches one of the removal criteria.
Definition: NBEdgeCont.cpp:203
void ignore(std::string id)
mark the given edge id as ignored
Definition: NBEdgeCont.h:486
bool wasIgnored(std::string id) const
Returns whether the edge with the id was ignored during parsing.
Definition: NBEdgeCont.h:481
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:182
The representation of a single edge during network building.
Definition: NBEdge.h:92
void setPermittedChanging(int lane, SVCPermissions changeLeft, SVCPermissions changeRight)
set allowed classes for changing to the left and right from the given lane
Definition: NBEdge.cpp:4299
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:4271
void setSpeed(int lane, double speed)
set lane specific speed (negative lane implies set for all lanes)
Definition: NBEdge.cpp:4223
double getLaneWidth() const
Returns the default width of lanes of this edge.
Definition: NBEdge.h:638
Connection & getConnectionRef(int fromLane, const NBEdge *to, int toLane)
Returns reference to the specified connection This method goes through "myConnections" and returns th...
Definition: NBEdge.cpp:1278
static const double UNSPECIFIED_FRICTION
unspecified lane friction
Definition: NBEdge.h:351
static const bool UNSPECIFIED_CONNECTION_UNCONTROLLED
TLS-controlled despite its node controlled not specified.
Definition: NBEdge.h:372
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, KeepClear keepClear=KEEPCLEAR_UNSPECIFIED, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE, double speed=UNSPECIFIED_SPEED, double friction=UNSPECIFIED_FRICTION, double length=myDefaultConnectionLength, const PositionVector &customShape=PositionVector::EMPTY, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED, SVCPermissions permissions=SVC_UNSPECIFIED, const bool indirectLeft=false, const std::string &edgeType="", SVCPermissions changeLeft=SVC_UNSPECIFIED, SVCPermissions changeRight=SVC_UNSPECIFIED, bool postProcess=false)
Adds a connection between the specified this edge's lane and an approached one.
Definition: NBEdge.cpp:1098
void setDistance(double distance)
set kilometrage at start of edge (negative value implies couting down along the edge)
Definition: NBEdge.h:1407
bool setEdgeStopOffset(int lane, const StopOffset &offset, bool overwrite=false)
set lane and vehicle class specific stopOffset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:4193
bool hasLaneSpecificStopOffsets() const
whether lanes differ in stopOffsets
Definition: NBEdge.cpp:2455
const std::string & getID() const
Definition: NBEdge.h:1522
const std::vector< NBEdge::Lane > & getLanes() const
Returns the lane definitions.
Definition: NBEdge.h:726
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:542
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
Definition: NBEdge.h:360
void setLaneWidth(int lane, double width)
set lane specific width (negative lane implies set for all lanes)
Definition: NBEdge.cpp:4094
void setAcceleration(int lane, bool accelRamp)
marks one lane as acceleration lane
Definition: NBEdge.cpp:4255
const StopOffset & getEdgeStopOffset() const
Returns the stopOffset to the end of the edge.
Definition: NBEdge.cpp:4161
void setBidi(bool isBidi)
mark this edge as a bidi edge
Definition: NBEdge.h:1412
void setFriction(int lane, double friction)
set lane specific friction (negative lane implies set for all lanes)
Definition: NBEdge.cpp:4239
static const double UNSPECIFIED_CONTPOS
unspecified internal junction position
Definition: NBEdge.h:354
static const double UNSPECIFIED_VISIBILITY_DISTANCE
unspecified foe visibility for connections
Definition: NBEdge.h:357
bool hasLaneSpecificWidth() const
whether lanes differ in width
Definition: NBEdge.cpp:2422
static const double UNSPECIFIED_SPEED
unspecified lane speed
Definition: NBEdge.h:348
@ VALIDATED
The connection was computed and validated.
bool hasLaneSpecificEndOffset() const
whether lanes differ in offset
Definition: NBEdge.cpp:2444
void setLaneShape(int lane, const PositionVector &shape)
sets a custom lane shape
Definition: NBEdge.cpp:4263
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:342
void declareConnectionsAsLoaded(EdgeBuildingStep step=EdgeBuildingStep::LANES2LANES_USER)
declares connections as fully loaded. This is needed to avoid recomputing connections if an edge has ...
Definition: NBEdge.h:1436
double getEndOffset() const
Returns the offset to the destination node.
Definition: NBEdge.h:685
void setEndOffset(int lane, double offset)
set lane specific end-offset (negative lane implies set for all lanes)
Definition: NBEdge.cpp:4177
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:345
Lane & getLaneStruct(int lane)
Definition: NBEdge.h:1422
void setLoadedLength(double val)
set loaded length
Definition: NBEdge.cpp:4323
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:535
A loaded (complete) traffic light logic.
void addPhase(const SUMOTime duration, const std::string &state, const SUMOTime minDur, const SUMOTime maxDur, const SUMOTime earliestEnd, const SUMOTime latestEnd, const SUMOTime vehExt, const SUMOTime yellow, const SUMOTime red, const std::vector< int > &next, const std::string &name)
Adds a phase to the logic the new phase is inserted at the end of the list of already added phases.
void addConnection(NBEdge *from, NBEdge *to, int fromLane, int toLane, int linkIndex, int linkIndex2, bool reconstruct=true)
Adds a connection and immediately informs the edges.
Instance responsible for building networks.
Definition: NBNetBuilder.h:107
static bool transformCoordinates(PositionVector &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
Definition: NBNetBuilder.h:159
static int addGeometrySegments(PositionVector &from, const PositionVector &cartesian, const double maxLength)
insertion geometry points to ensure maximum segment length between points
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:139
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:87
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:116
Represents a single node (junction) during network building.
Definition: NBNode.h:66
void addWalkingAreaShape(EdgeVector edges, const PositionVector &shape, double width)
add custom shape for walkingArea
Definition: NBNode.cpp:3743
RightOfWay getRightOfWay() const
Returns hint on how to compute right of way.
Definition: NBNode.h:300
NBNode::Crossing * addCrossing(EdgeVector edges, double width, bool priority, int tlIndex=-1, int tlIndex2=-1, const PositionVector &customShape=PositionVector::EMPTY, bool fromSumoNet=false, const Parameterised *params=nullptr)
add a pedestrian crossing to this node
Definition: NBNode.cpp:3809
FringeType getFringeType() const
Returns fringe type.
Definition: NBNode.h:305
SumoXMLNodeType getType() const
Returns the type of this node.
Definition: NBNode.h:285
bool isTrafficLight() const
Definition: NBNode.h:822
void setRightOfWay(RightOfWay rightOfWay)
set method for computing right-of-way
Definition: NBNode.h:569
void setCustomShape(const PositionVector &shape)
set the junction shape
Definition: NBNode.cpp:2611
void addSortedLinkFoes(const NBConnection &mayDrive, const NBConnection &mustStop)
add shorted link FOES
Definition: NBNode.cpp:1877
void setRadius(double radius)
set the turning radius
Definition: NBNode.h:559
void setName(const std::string &name)
set intersection name
Definition: NBNode.h:579
const Position & getPosition() const
Definition: NBNode.h:260
void setFringeType(FringeType fringeType)
set method for computing right-of-way
Definition: NBNode.h:574
const std::string & getProgramID() const
Returns the ProgramID.
static const SUMOTime UNSPECIFIED_DURATION
const std::map< std::string, NBTrafficLightDefinition * > & getPrograms(const std::string &id) const
Returns all programs for the given tl-id.
bool insert(NBTrafficLightDefinition *logic, bool forceInsert=false)
Adds a logic definition to the dictionary.
A connection description.
PositionVector customShape
custom shape connection
std::string tlID
The id of the traffic light that controls this connection.
double speed
custom speed for connection
std::string edgeType
optional edge type
std::string toEdgeID
The id of the target edge.
double customLength
custom length for connection
double contPos
custom position for internal junction on this connection
int toLaneIdx
The index of the target lane.
double friction
custom friction for connection
int tlLinkIndex
The index of this connection within the controlling traffic light.
bool indirectLeft
Whether this connection is an indirect left turn.
double visibility
custom foe visibility for connection
bool mayDefinitelyPass
Information about being definitely free to drive (on-ramps)
SVCPermissions changeLeft
custom lane changing permissions for connection
SVCPermissions changeRight
custom lane changing permissions for connection
bool uncontrolled
if set to true, This connection will not be TLS-controlled despite its node being controlled.
SVCPermissions permissions
custom permissions for connection
Describes the values found in an edge's definition and this edge's lanes.
std::string bidi
the bidi edge
LaneSpreadFunction lsf
The lane spread function.
std::vector< LaneAttrs * > lanes
The friction on this edge.
StopOffset edgeStopOffset
This edge's vehicle specific stop offsets (used for lanes, that do not have a specified stopOffset)
PositionVector shape
This edges's shape.
int priority
This edge's priority.
std::string toNode
The node this edge ends at.
std::string type
This edge's type.
double maxSpeed
The maximum velocity allowed on this edge (!!!)
NBEdge * builtEdge
The built edge.
SumoXMLEdgeFunc func
This edge's function.
std::string streetName
This edge's street name.
std::string fromNode
The node this edge starts at.
double length
The length of the edge if set explicitly.
std::string id
This edge's id.
double distance
The position at the start of this edge (kilometrage/mileage)
Describes the values found in a lane's definition.
double maxSpeed
The maximum velocity allowed on this lane.
double friction
The friction on this lane.
std::string changeRight
This lane's vehicle classes allowed to change right.
double endOffset
This lane's offset from the intersection.
bool accelRamp
Whether this lane is an acceleration lane.
std::string oppositeID
This lane's opposite lane.
std::string type
the type of this lane
std::vector< Connection > connections
This lane's connections.
bool customShape
Whether this lane has a custom shape.
StopOffset laneStopOffset
This lane's vehicle specific stop offsets.
PositionVector shape
This lane's shape (may be custom)
std::string changeLeft
This lane's vehicle classes allowed to change left.
double width
The width of this lane.
std::string disallow
This lane's disallowed vehicle classes.
std::string allow
This lane's allowed vehicle classes.
Importer for networks stored in SUMO format.
GeoConvHelper * myLocation
The coordinate transformation which was used to build the loaded network.
static NBLoadedSUMOTLDef * initTrafficLightLogic(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
begins the reading of a traffic lights logic
void parseProhibitionConnection(const std::string &attr, std::string &from, std::string &to, bool &ok)
parses connection string of a prohibition (very old school)
~NIImporter_SUMO()
Destructor.
NIXMLTypesHandler myTypesHandler
The handler for parsing edge types and restrictions.
int myCornerDetail
the level of corner detail in the loaded network
bool myCheckLaneFoesAll
whether foe-relationships where checked at lane-level
double myLimitTurnSpeed
whether turning speed was limited in the network
std::set< std::string > myRailSignals
list of node id with rail signals (no NBTrafficLightDefinition exists)
bool myGeomAvoidOverlap
overlap option for loaded network
std::map< std::string, std::vector< Crossing > > myPedestrianCrossings
The pedestrian crossings found in the network.
bool myCheckLaneFoesRoundabout
JunctionAttrs myCurrentJunction
The currently parsed junction definition to help in reconstructing crossings.
static GeoConvHelper * loadLocation(const SUMOSAXAttributes &attrs, bool setLoaded=true)
Parses network location description and registers it with GeoConveHelper::setLoaded.
void addJunction(const SUMOSAXAttributes &attrs)
Parses a junction and saves it in the node control.
bool myAmLefthand
whether the loaded network was built for lefthand traffic
bool myRectLaneCut
whether all lanes of an edge should have the same stop line
std::vector< Parameterised * > myLastParameterised
element to receive parameters
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
double myInternalJunctionsVehicleWidth
custom settings for internal junction computation
std::string myDefaultSpreadType
default spreadType defined in the network
bool myJunctionsHigherSpeed
higherSpeed option for loaded network
NBLoadedSUMOTLDef * myCurrentTL
The currently parsed traffic light.
static void loadNetwork(OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given SUMO file.
std::vector< std::vector< std::string > > myRoundabouts
loaded roundabout edges
bool myChangeLefthand
whether the the written network should have a different "handedness" (LHT/RHT) than the loaded networ...
void addConnection(const SUMOSAXAttributes &attrs)
Parses a connection and saves it into the lane's definition stored in "myCurrentLane".
void addEdge(const SUMOSAXAttributes &attrs)
Parses an edge and stores the values in "myCurrentEdge".
LaneAttrs * myCurrentLane
The currently parsed lanes's definition (to add the shape to)
void addLane(const SUMOSAXAttributes &attrs)
Parses a lane and stores the values in "myCurrentLane".
NBNodeCont & myNodeCont
The node container to fill.
EdgeAttrs * myCurrentEdge
The currently parsed edge's definition (to add loaded lanes to)
NBNetBuilder & myNetBuilder
The network builder to fill.
void addRoundabout(const SUMOSAXAttributes &attrs)
Parses a roundabout and stores it in myEdgeCont.
std::vector< Prohibition > myProhibitions
Loaded prohibitions.
MMVersion myNetworkVersion
the loaded network version
void _loadNetwork(OptionsCont &oc)
load the network
void myEndElement(int element)
Called when a closing tag occurs.
bool myTlsIgnoreInternalJunctionJam
whether some right-of-way checks at traffic light junctions should be disabled
bool myJunctionsMinimalShape
custom settings for junction shape computation
void addStopOffsets(const SUMOSAXAttributes &attrs, bool &ok)
parses stop offsets for the current lane or edge
static Position readPosition(const SUMOSAXAttributes &attrs, const std::string &id, bool &ok)
read position from the given attributes, attribute errors to id
static void addPhase(const SUMOSAXAttributes &attrs, NBLoadedSUMOTLDef *currentTL)
adds a phase to the traffic lights logic currently build
int myLinkDetail
the level of geometry detail for internal lanes in the loaded network
std::map< std::string, WalkingAreaParsedCustomShape > myWACustomShapes
Map from walkingArea edge IDs to custom shapes.
bool myWalkingAreas
whether walkingareas must be built
NBTrafficLightLogicCont & myTLLCont
The node container to fill.
NIImporter_SUMO(NBNetBuilder &nb)
Constructor.
void addProhibition(const SUMOSAXAttributes &attrs)
Parses a prohibition and saves it.
void addRequest(const SUMOSAXAttributes &attrs)
Parses a reques and saves selected attributes in myCurrentJunction.
std::set< std::string > myDiscardableParams
list of parameter keys to discard
std::map< std::string, EdgeAttrs * > myEdges
Loaded edge definitions.
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag; Parses edge type information.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A storage for options typed value containers)
Definition: OptionsCont.h:89
bool isWriteable(const std::string &name)
Returns the information whether the named option may be set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool set(const std::string &name, const std::string &value, const bool append=false)
Sets the given value for the named option.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:60
bool isUsableFileList(const std::string &name) const
Checks whether the named option is usable as a file list (with at least a single file)
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
void updateParameters(const Parameterised::Map &mapArg)
Adds or updates all given parameters from the map.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
static const PositionVector EMPTY
empty Vector
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
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.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
SAX-handler base for SUMO-files.
static StringBijection< LaneSpreadFunction > LaneSpreadFunctions
lane spread functions
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
static StringBijection< LinkState > LinkStates
link states
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
return the junction id when given an edge of type internal, crossing or WalkingArea
stop offset
bool isDefined() const
check if stopOffset was defined
T get(const std::string &str) const
static MMVersion toVersion(const std::string &sData)
parse a (network) version string
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false, const bool isExternal=false, const bool catchExceptions=true)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:148
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition: json.hpp:21884
std::string type
the type of this lane
Definition: NBEdge.h:192
std::string oppositeID
An opposite lane ID, if given.
Definition: NBEdge.h:179
Describes a pedestrian crossing.
std::vector< std::string > crossingEdges
std::vector< std::string > response
std::vector< std::string > intLanes
Describes the values found in a prohibition.
Describes custom shape for a walking area during parsing.