Eclipse SUMO - Simulation of Urban MObility
NLHandler.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-2022 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 /****************************************************************************/
23 // The XML-Handler for network loading
24 /****************************************************************************/
25 #include <config.h>
26 
27 #include <string>
28 #include "NLHandler.h"
29 #include "NLEdgeControlBuilder.h"
31 #include "NLDetectorBuilder.h"
32 #include "NLTriggerBuilder.h"
36 #include <utils/common/SUMOTime.h>
39 #include <utils/common/RGBColor.h>
41 #include <microsim/MSGlobals.h>
42 #include <microsim/MSLane.h>
43 #include <microsim/MSJunction.h>
49 #include <mesosim/MESegment.h>
54 #include <utils/shapes/Shape.h>
56 
57 
58 // ===========================================================================
59 // method definitions
60 // ===========================================================================
61 NLHandler::NLHandler(const std::string& file, MSNet& net,
62  NLDetectorBuilder& detBuilder,
63  NLTriggerBuilder& triggerBuilder,
64  NLEdgeControlBuilder& edgeBuilder,
65  NLJunctionControlBuilder& junctionBuilder) :
66  MSRouteHandler(file, true),
67  myNet(net), myActionBuilder(net),
68  myCurrentIsInternalToSkip(false),
69  myDetectorBuilder(detBuilder), myTriggerBuilder(triggerBuilder),
70  myEdgeControlBuilder(edgeBuilder), myJunctionControlBuilder(junctionBuilder),
71  myAmParsingTLLogicOrJunction(false), myCurrentIsBroken(false),
72  myHaveWarnedAboutInvalidTLType(false),
73  myHaveSeenInternalEdge(false),
74  myHaveJunctionHigherSpeeds(false),
75  myHaveSeenDefaultLength(false),
76  myHaveSeenNeighs(false),
77  myHaveSeenAdditionalSpeedRestrictions(false),
78  myHaveSeenMesoEdgeType(false),
79  myNetworkVersion(0),
80  myNetIsLoaded(false) {
81 }
82 
83 
85 
86 
87 void
89  const SUMOSAXAttributes& attrs) {
90  try {
91  switch (element) {
92  case SUMO_TAG_NET: {
93  bool ok;
94  MSGlobals::gLefthand = attrs.getOpt<bool>(SUMO_ATTR_LEFTHAND, nullptr, ok, false);
95  myHaveJunctionHigherSpeeds = attrs.getOpt<bool>(SUMO_ATTR_HIGHER_SPEED, nullptr, ok, false);
96  myNetworkVersion = attrs.get<double>(SUMO_ATTR_VERSION, nullptr, ok, false);
97  break;
98  }
99  case SUMO_TAG_EDGE:
100  beginEdgeParsing(attrs);
101  break;
102  case SUMO_TAG_LANE:
103  addLane(attrs);
104  break;
105  case SUMO_TAG_NEIGH:
108  }
109  myHaveSeenNeighs = true;
110  break;
111  case SUMO_TAG_JUNCTION:
112  openJunction(attrs);
113  initJunctionLogic(attrs);
114  break;
115  case SUMO_TAG_PHASE:
116  addPhase(attrs);
117  break;
118  case SUMO_TAG_CONDITION:
119  addCondition(attrs);
120  break;
121  case SUMO_TAG_CONNECTION:
122  addConnection(attrs);
123  break;
124  case SUMO_TAG_TLLOGIC:
125  initTrafficLightLogic(attrs);
126  break;
127  case SUMO_TAG_REQUEST:
128  addRequest(attrs);
129  break;
130  case SUMO_TAG_WAUT:
131  openWAUT(attrs);
132  break;
134  addWAUTSwitch(attrs);
135  break;
137  addWAUTJunction(attrs);
138  break;
139  case SUMO_TAG_E1DETECTOR:
141  addE1Detector(attrs);
142  break;
143  case SUMO_TAG_E2DETECTOR:
145  addE2Detector(attrs);
146  break;
147  case SUMO_TAG_E3DETECTOR:
149  beginE3Detector(attrs);
150  break;
151  case SUMO_TAG_DET_ENTRY:
152  addE3Entry(attrs);
153  break;
154  case SUMO_TAG_DET_EXIT:
155  addE3Exit(attrs);
156  break;
158  addInstantE1Detector(attrs);
159  break;
160  case SUMO_TAG_VSS:
162  break;
163  case SUMO_TAG_CALIBRATOR:
165  break;
166  case SUMO_TAG_REROUTER:
168  break;
169  case SUMO_TAG_BUS_STOP:
170  case SUMO_TAG_TRAIN_STOP:
174  break;
177  break;
181  break;
182  case SUMO_TAG_ACCESS:
184  break;
188  break;
191  break;
194  break;
197  break;
200  break;
201  case SUMO_TAG_VTYPEPROBE:
202  addVTypeProbeDetector(attrs);
203  break;
204  case SUMO_TAG_ROUTEPROBE:
205  addRouteProbeDetector(attrs);
206  break;
209  break;
212  break;
213  case SUMO_TAG_TIMEDEVENT:
215  break;
216  case SUMO_TAG_VAPORIZER:
218  break;
219  case SUMO_TAG_LOCATION:
220  setLocation(attrs);
221  break;
222  case SUMO_TAG_TAZ:
223  addDistrict(attrs);
224  break;
225  case SUMO_TAG_TAZSOURCE:
226  addDistrictEdge(attrs, true);
227  break;
228  case SUMO_TAG_TAZSINK:
229  addDistrictEdge(attrs, false);
230  break;
231  case SUMO_TAG_ROUNDABOUT:
232  addRoundabout(attrs);
233  break;
234  case SUMO_TAG_TYPE: {
235  bool ok = true;
236  myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
237  break;
238  }
239  case SUMO_TAG_RESTRICTION: {
240  bool ok = true;
241  const SUMOVehicleClass svc = getVehicleClassID(attrs.get<std::string>(SUMO_ATTR_VCLASS, myCurrentTypeID.c_str(), ok));
242  const double speed = attrs.get<double>(SUMO_ATTR_SPEED, myCurrentTypeID.c_str(), ok);
243  if (ok) {
244  myNet.addRestriction(myCurrentTypeID, svc, speed);
245  }
246  if (myNetIsLoaded) {
248  }
249  break;
250  }
251  case SUMO_TAG_MESO: {
252  addMesoEdgeType(attrs);
253  break;
254  }
255  case SUMO_TAG_STOPOFFSET: {
256  bool ok = true;
257  const StopOffset stopOffset(attrs, ok);
258  if (!ok) {
260  } else {
262  }
263  break;
264  }
266  bool ok = true;
267  const std::string signalID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
268  if (!MSNet::getInstance()->getTLSControl().knows(signalID)) {
269  throw InvalidArgument("Rail signal '" + signalID + "' in railSignalConstraints is not known");
270  }
272  if (myConstrainedSignal == nullptr) {
273  throw InvalidArgument("Traffic light '" + signalID + "' is not a rail signal");
274  }
275  break;
276  }
277  case SUMO_TAG_PREDECESSOR: // intended fall-through
280  break;
281  default:
282  break;
283  }
284  } catch (InvalidArgument& e) {
285  myCurrentIsBroken = true;
286  WRITE_ERROR(e.what());
287  }
288  MSRouteHandler::myStartElement(element, attrs);
289  if (element == SUMO_TAG_PARAM && !myCurrentIsBroken) {
290  addParam(attrs);
291  }
292 }
293 
294 
295 void
297  switch (element) {
298  case SUMO_TAG_EDGE:
299  closeEdge();
300  break;
301  case SUMO_TAG_LANE:
304  myLastParameterised.pop_back();
305  }
306  break;
307  case SUMO_TAG_JUNCTION:
308  if (!myCurrentIsBroken) {
309  try {
312  } catch (InvalidArgument& e) {
313  WRITE_ERROR(e.what());
314  }
315  }
317  break;
318  case SUMO_TAG_TLLOGIC:
319  if (!myCurrentIsBroken) {
320  try {
322  } catch (InvalidArgument& e) {
323  WRITE_ERROR(e.what());
324  }
325  }
327  break;
328  case SUMO_TAG_WAUT:
329  closeWAUT();
330  break;
332  myConstrainedSignal = nullptr;
333  break;
334  case SUMO_TAG_E1DETECTOR:
337  case SUMO_TAG_E2DETECTOR:
339  if (!myCurrentIsBroken) {
340  myLastParameterised.pop_back();
341  }
342  break;
343  case SUMO_TAG_E3DETECTOR:
345  endE3Detector();
346  if (!myCurrentIsBroken) {
347  myLastParameterised.pop_back();
348  }
349  break;
352  myLastParameterised.pop_back();
353  break;
354  case SUMO_TAG_BUS_STOP:
355  case SUMO_TAG_TRAIN_STOP:
359  myLastParameterised.pop_back();
360  break;
361  case SUMO_TAG_NET:
362  // build junction graph
363  for (JunctionGraph::iterator it = myJunctionGraph.begin(); it != myJunctionGraph.end(); ++it) {
364  MSEdge* edge = MSEdge::dictionary(it->first);
365  MSJunction* from = myJunctionControlBuilder.retrieve(it->second.first);
366  MSJunction* to = myJunctionControlBuilder.retrieve(it->second.second);
367  if (from == nullptr) {
368  WRITE_ERROR("Unknown from-node '" + it->second.first + "' for edge '" + it->first + "'.");
369  return;
370  }
371  if (to == nullptr) {
372  WRITE_ERROR("Unknown to-node '" + it->second.second + "' for edge '" + it->first + "'.");
373  return;
374  }
375  if (edge != nullptr) {
376  edge->setJunctions(from, to);
377  from->addOutgoing(edge);
378  to->addIncoming(edge);
379  }
380  }
381  myNetIsLoaded = true;
382  break;
383  default:
384  break;
385  }
387 }
388 
389 
390 
391 // ---- the root/edge - element
392 void
394  bool ok = true;
395  myCurrentIsBroken = false;
396  // get the id, report an error if not given or empty...
397  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
398  if (!ok) {
399  myCurrentIsBroken = true;
400  return;
401  }
402  // parse the function
403  const SumoXMLEdgeFunc func = attrs.getEdgeFunc(ok);
404  if (!ok) {
405  WRITE_ERROR("Edge '" + id + "' has an invalid type.");
406  myCurrentIsBroken = true;
407  }
408  // omit internal edges if not wished
409  if (id[0] == ':') {
410  myHaveSeenInternalEdge = true;
413  return;
414  }
415  std::string junctionID = SUMOXMLDefinitions::getJunctionIDFromInternalEdge(id);
416  myJunctionGraph[id] = std::make_pair(junctionID, junctionID);
417  } else {
419  myJunctionGraph[id] = std::make_pair(
420  attrs.get<std::string>(SUMO_ATTR_FROM, id.c_str(), ok),
421  attrs.get<std::string>(SUMO_ATTR_TO, id.c_str(), ok));
422  }
423  if (!ok) {
424  myCurrentIsBroken = true;
425  return;
426  }
428  // get the street name
429  const std::string streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
430  // get the edge type
431  const std::string edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
432  // get the edge priority (only for visualization)
433  const int priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1); // default taken from netbuild/NBFrame option 'default.priority'
434  // get the bidi-edge
435  const std::string bidi = attrs.getOpt<std::string>(SUMO_ATTR_BIDI, id.c_str(), ok, "");
436  // get the kilometrage/mileage (for visualization and output)
437  const double distance = attrs.getOpt<double>(SUMO_ATTR_DISTANCE, id.c_str(), ok, 0);
438 
439  if (!ok) {
440  myCurrentIsBroken = true;
441  return;
442  }
443  //
444  try {
445  myEdgeControlBuilder.beginEdgeParsing(id, func, streetName, edgeType, priority, bidi, distance);
446  } catch (InvalidArgument& e) {
447  WRITE_ERROR(e.what());
448  myCurrentIsBroken = true;
449  }
450 
451  if (func == SumoXMLEdgeFunc::CROSSING) {
452  //get the crossingEdges attribute (to implement the other side of the road pushbutton)
453  const std::string crossingEdges = attrs.getOpt<std::string>(SUMO_ATTR_CROSSING_EDGES, id.c_str(), ok, "");
454  if (!crossingEdges.empty()) {
455  std::vector<std::string> crossingEdgesVector;
456  StringTokenizer edges(crossingEdges);
457  while (edges.hasNext()) {
458  crossingEdgesVector.push_back(edges.next());
459  }
460  myEdgeControlBuilder.addCrossingEdges(crossingEdgesVector);
461  }
462  }
465 }
466 
467 
468 void
470  myLastParameterised.clear();
471  // omit internal edges if not wished and broken edges
473  return;
474  }
475  try {
477  MSEdge::dictionary(e->getID(), e);
479  } catch (InvalidArgument& e) {
480  WRITE_ERROR(e.what());
481  }
482 }
483 
484 
485 // ---- the root/edge/lanes/lane - element
486 void
488  // omit internal edges if not wished and broken edges
490  return;
491  }
492  bool ok = true;
493  // get the id, report an error if not given or empty...
494  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
495  if (!ok) {
496  myCurrentIsBroken = true;
497  return;
498  }
499  const double maxSpeed = attrs.get<double>(SUMO_ATTR_SPEED, id.c_str(), ok);
500  const double length = attrs.get<double>(SUMO_ATTR_LENGTH, id.c_str(), ok);
501  const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "", false);
502  const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
503  const std::string changeLeftS = attrs.getOpt<std::string>(SUMO_ATTR_CHANGE_LEFT, id.c_str(), ok, "");
504  const std::string changeRightS = attrs.getOpt<std::string>(SUMO_ATTR_CHANGE_RIGHT, id.c_str(), ok, "");
505  const double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, SUMO_const_laneWidth);
506  const PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
507  const int index = attrs.get<int>(SUMO_ATTR_INDEX, id.c_str(), ok);
508  const bool isRampAccel = attrs.getOpt<bool>(SUMO_ATTR_ACCELERATION, id.c_str(), ok, false);
509  const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
510  if (shape.size() < 2) {
511  WRITE_ERROR("Shape of lane '" + id + "' is broken.\n Can not build according edge.");
512  myCurrentIsBroken = true;
513  return;
514  }
515  const SVCPermissions permissions = parseVehicleClasses(allow, disallow, myNetworkVersion);
516  SVCPermissions changeLeft = parseVehicleClasses(changeLeftS, "", myNetworkVersion);
517  SVCPermissions changeRight = parseVehicleClasses(changeRightS, "", myNetworkVersion);
518  if (MSGlobals::gLefthand) {
519  // internally, changeLeft always checks for the higher lane index
520  // even though the higher lane index is to the right in a left-hand network
521  std::swap(changeLeft, changeRight);
522  }
523  if (permissions != SVCAll || changeLeft != SVCAll || changeRight != SVCAll) {
525  }
526  myCurrentIsBroken |= !ok;
527  if (!myCurrentIsBroken) {
528  try {
529  MSLane* lane = myEdgeControlBuilder.addLane(id, maxSpeed, length, shape, width, permissions, changeLeft, changeRight, index, isRampAccel, type);
530  // insert the lane into the lane-dictionary, checking
531  if (!MSLane::dictionary(id, lane)) {
532  delete lane;
533  WRITE_ERROR("Another lane with the id '" + id + "' exists.");
534  myCurrentIsBroken = true;
535  myLastParameterised.push_back(nullptr);
536  } else {
537  myLastParameterised.push_back(lane);
538  }
539  } catch (InvalidArgument& e) {
540  WRITE_ERROR(e.what());
541  }
542  }
543 }
544 
545 
546 // ---- the root/junction - element
547 void
549  myCurrentIsBroken = false;
550  bool ok = true;
551  // get the id, report an error if not given or empty...
552  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
553  if (!ok) {
554  myCurrentIsBroken = true;
555  return;
556  }
557  PositionVector shape;
558  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
559  // inner junctions have no shape
560  shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok, PositionVector());
561  if (shape.size() > 2) {
562  shape.closePolygon();
563  }
564  }
565  double x = attrs.get<double>(SUMO_ATTR_X, id.c_str(), ok);
566  double y = attrs.get<double>(SUMO_ATTR_Y, id.c_str(), ok);
567  double z = attrs.getOpt<double>(SUMO_ATTR_Z, id.c_str(), ok, 0);
568  bool typeOK = true;
569  SumoXMLNodeType type = attrs.getNodeType(typeOK);
570  if (!typeOK) {
571  WRITE_ERROR("An unknown or invalid junction type occurred in junction '" + id + "'.");
572  ok = false;
573  }
574  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_KEY, id.c_str(), ok, "");
575  std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
576  // incoming lanes
577  std::vector<MSLane*> incomingLanes;
578  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INCLANES, ""), incomingLanes, ok);
579  // internal lanes
580  std::vector<MSLane*> internalLanes;
582  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INTLANES, ""), internalLanes, ok);
583  }
584  if (!ok) {
585  myCurrentIsBroken = true;
586  } else {
587  try {
588  myJunctionControlBuilder.openJunction(id, key, type, Position(x, y, z), shape, incomingLanes, internalLanes, name);
589  } catch (InvalidArgument& e) {
590  WRITE_ERROR(e.what() + std::string("\n Can not build according junction."));
591  myCurrentIsBroken = true;
592  }
593  }
594 }
595 
596 
597 void
598 NLHandler::parseLanes(const std::string& junctionID,
599  const std::string& def, std::vector<MSLane*>& into, bool& ok) {
600  StringTokenizer st(def, " ");
601  while (ok && st.hasNext()) {
602  std::string laneID = st.next();
603  MSLane* lane = MSLane::dictionary(laneID);
604  if (!MSGlobals::gUsingInternalLanes && laneID[0] == ':') {
605  continue;
606  }
607  if (lane == nullptr) {
608  WRITE_ERROR("An unknown lane ('" + laneID + "') was tried to be set as incoming to junction '" + junctionID + "'.");
609  ok = false;
610  continue;
611  }
612  into.push_back(lane);
613  }
614 }
615 // ----
616 
617 void
619  bool ok = true;
620  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
621  // circumventing empty string test
622  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
623  if (myLastParameterised.size() > 0 && myLastParameterised.back() != nullptr) {
624  myLastParameterised.back()->setParameter(key, val);
625  }
626  // set
627  if (ok && myAmParsingTLLogicOrJunction) {
628  assert(key != "");
629  assert(val != "");
631  }
632 }
633 
634 
635 void
637  myCurrentIsBroken = false;
638  bool ok = true;
639  // get the id, report an error if not given or empty...
640  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
641  if (!ok) {
642  myCurrentIsBroken = true;
643  return;
644  }
645  SUMOTime refTime = attrs.getOptSUMOTimeReporting(SUMO_ATTR_REF_TIME, id.c_str(), ok, 0);
646  SUMOTime period = attrs.getOptSUMOTimeReporting(SUMO_ATTR_PERIOD, id.c_str(), ok, 0);
647  std::string startProg = attrs.get<std::string>(SUMO_ATTR_START_PROG, id.c_str(), ok);
648  if (!ok) {
649  myCurrentIsBroken = true;
650  }
651  if (!myCurrentIsBroken) {
652  myCurrentWAUTID = id;
653  try {
654  myJunctionControlBuilder.getTLLogicControlToUse().addWAUT(refTime, id, startProg, period);
655  } catch (InvalidArgument& e) {
656  WRITE_ERROR(e.what());
657  myCurrentIsBroken = true;
658  }
659  }
660 }
661 
662 
663 void
665  bool ok = true;
667  std::string to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentWAUTID.c_str(), ok);
668  if (!ok) {
669  myCurrentIsBroken = true;
670  }
671  if (!myCurrentIsBroken) {
672  try {
674  } catch (InvalidArgument& e) {
675  WRITE_ERROR(e.what());
676  myCurrentIsBroken = true;
677  }
678  }
679 }
680 
681 
682 void
684  bool ok = true;
685  std::string wautID = attrs.get<std::string>(SUMO_ATTR_WAUT_ID, nullptr, ok);
686  std::string junctionID = attrs.get<std::string>(SUMO_ATTR_JUNCTION_ID, nullptr, ok);
687  std::string procedure = attrs.getOpt<std::string>(SUMO_ATTR_PROCEDURE, nullptr, ok, "");
688  bool synchron = attrs.getOpt<bool>(SUMO_ATTR_SYNCHRON, nullptr, ok, false);
689  if (!ok) {
690  myCurrentIsBroken = true;
691  }
692  try {
693  if (!myCurrentIsBroken) {
694  myJunctionControlBuilder.getTLLogicControlToUse().addWAUTJunction(wautID, junctionID, procedure, synchron);
695  }
696  } catch (InvalidArgument& e) {
697  WRITE_ERROR(e.what());
698  myCurrentIsBroken = true;
699  }
700 }
701 
702 
703 void
705  if (myCurrentIsBroken) {
706  return;
707  }
708  bool ok = true;
709  int request = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
710  bool cont = false;
711  cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, nullptr, ok, false);
712  std::string response = attrs.get<std::string>(SUMO_ATTR_RESPONSE, nullptr, ok);
713  std::string foes = attrs.get<std::string>(SUMO_ATTR_FOES, nullptr, ok);
714  if (!ok) {
715  return;
716  }
717  // store received information
718  if (request >= 0 && response.length() > 0) {
719  try {
720  myJunctionControlBuilder.addLogicItem(request, response, foes, cont);
721  } catch (InvalidArgument& e) {
722  WRITE_ERROR(e.what());
723  }
724  }
725 }
726 
727 
728 void
730  if (myCurrentIsBroken) {
731  return;
732  }
734  bool ok = true;
735  // we either a have a junction or a legacy network with ROWLogic
736  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
737  if (ok) {
739  }
740 }
741 
742 
743 void
745  myCurrentIsBroken = false;
747  bool ok = true;
748  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
749  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
751  std::string typeS;
752  if (myJunctionControlBuilder.getTLLogicControlToUse().get(id, programID) == nullptr) {
753  // SUMO_ATTR_TYPE is not needed when only modifying the offset of an
754  // existing program
755  typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok);
756  if (!ok) {
757  myCurrentIsBroken = true;
758  return;
759  }
760  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
762  } else {
763  WRITE_ERROR("Traffic light '" + id + "' has unknown type '" + typeS + "'.");
764  }
767  WRITE_WARNING("Traffic light type '" + toString(type) + "' cannot be used in mesoscopic simulation. Using '" + toString(TrafficLightType::STATIC) + "' as fallback.");
769  }
771  }
772  }
773  //
774  const SUMOTime offset = attrs.getOptSUMOTimeReporting(SUMO_ATTR_OFFSET, id.c_str(), ok, 0);
775  if (!ok) {
776  myCurrentIsBroken = true;
777  return;
778  }
779  myJunctionControlBuilder.initTrafficLightLogic(id, programID, type, offset);
780 }
781 
782 
783 void
785  // try to get the phase definition
786  bool ok = true;
787  const std::string& id = myJunctionControlBuilder.getActiveKey();
789 
791  const std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, nullptr, ok);
792  if (duration == 0) {
794  + " for tlLogic '" + myJunctionControlBuilder.getActiveKey()
795  + "' program '" + myJunctionControlBuilder.getActiveSubKey() + "' is zero.");
796  return;
797  }
798  if (!ok) {
799  return;
800  }
801  MSPhaseDefinition* phase = new MSPhaseDefinition(duration, state);
802 
803  // if the traffic light is an actuated traffic light, try to get
804  // the minimum and maximum durations
805  phase->minDuration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_MINDURATION, id.c_str(), ok, duration);
806  phase->maxDuration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_MAXDURATION, id.c_str(), ok, duration);
807  phase->earliestEnd = attrs.getOptSUMOTimeReporting(SUMO_ATTR_EARLIEST_END, id.c_str(), ok, tDefault);
808  phase->latestEnd = attrs.getOptSUMOTimeReporting(SUMO_ATTR_LATEST_END, id.c_str(), ok, tDefault);
809  phase->nextPhases = attrs.getOptIntVector(SUMO_ATTR_NEXT, id.c_str(), ok);
810  phase->earlyTarget = attrs.getOpt<std::string>(SUMO_ATTR_EARLY_TARGET, id.c_str(), ok, "");
811  phase->finalTarget = attrs.getOpt<std::string>(SUMO_ATTR_FINAL_TARGET, id.c_str(), ok, "");
812  phase->name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
813 
814  phase->vehext = attrs.getOptSUMOTimeReporting(SUMO_ATTR_VEHICLEEXTENSION, id.c_str(), ok, tDefault);
815  phase->yellow = attrs.getOptSUMOTimeReporting(SUMO_ATTR_YELLOW, id.c_str(), ok, tDefault);
816  phase->red = attrs.getOptSUMOTimeReporting(SUMO_ATTR_RED, id.c_str(), ok, tDefault);
817 
818  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
819  //SOTL attributes
820  //If the type attribute is not present, the parsed phase is of type "undefined" (MSPhaseDefinition constructor),
821  //in this way SOTL traffic light logic can recognize the phase as unsuitable or decides other
822  //behaviors. See SOTL traffic light logic implementations.
823  std::string phaseTypeString;
824  try {
825  phaseTypeString = attrs.get<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, false);
826  } catch (EmptyData&) {
827  MsgHandler::getWarningInstance()->inform("Empty type definition. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
828  phase->myTransientNotDecisional = false;
829  }
830  if (phaseTypeString.find("decisional") != std::string::npos) {
831  phase->myTransientNotDecisional = false;
832  } else if (phaseTypeString.find("transient") != std::string::npos) {
833  phase->myTransientNotDecisional = true;
834  } else {
835  MsgHandler::getWarningInstance()->inform("SOTL_ATTL_TYPE_DECISIONAL nor SOTL_ATTL_TYPE_TRANSIENT. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
836  phase->myTransientNotDecisional = false;
837  }
838  phase->myCommit = (phaseTypeString.find("commit") != std::string::npos);
839 
840  if (phaseTypeString.find("target") != std::string::npos) {
841  std::string delimiter(" ,;");
842  //Phase declared as target, getting targetLanes attribute
843  try {
845  } catch (EmptyData&) {
846  MsgHandler::getErrorInstance()->inform("Missing targetLane definition for the target phase.");
847  delete phase;
848  return;
849  }
850  }
851  }
852 
853  if (phase->maxDuration < phase->minDuration) {
854  WRITE_WARNINGF("maxDur % should not be smaller than minDir % in phase of tlLogic %", phase->maxDuration, phase->minDuration, id);
855  phase->maxDuration = phase->duration;
856  }
857 
858  phase->myLastSwitch = string2time(OptionsCont::getOptions().getString("begin")) - 1; // SUMOTime-option
860 }
861 
862 
863 void
865  bool ok = true;
866  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
867  const std::string value = attrs.get<std::string>(SUMO_ATTR_VALUE, id.c_str(), ok);
868  if (!myJunctionControlBuilder.addCondition(id, value)) {
869  WRITE_ERROR("Duplicate condition '" + id + "' in tlLogic '" + myJunctionControlBuilder.getActiveKey() + "'");
870  }
871 }
872 
873 
874 void
876  myCurrentIsBroken = false;
877  bool ok = true;
878  // get the id, report an error if not given or empty...
879  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
880  if (!ok) {
881  myCurrentIsBroken = true;
882  return;
883  }
884  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
885  const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), ok);
886  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
887  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
888  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
889  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
890  const std::string detectPersonsString = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, id.c_str(), ok, "");
891  int detectPersons = 0;
892  for (std::string mode : StringTokenizer(detectPersonsString).getVector()) {
893  if (SUMOXMLDefinitions::PersonModeValues.hasString(mode)) {
894  detectPersons |= (int)SUMOXMLDefinitions::PersonModeValues.get(mode);
895  } else {
896  WRITE_ERROR("Invalid person mode '" + mode + "' in E1 detector definition '" + id + "'");
897  myCurrentIsBroken = true;
898  return;
899  }
900  }
901  if (!ok) {
902  myCurrentIsBroken = true;
903  return;
904  }
905  try {
906  Parameterised* det = myDetectorBuilder.buildInductLoop(id, lane, position, frequency,
908  friendlyPos, vTypes, detectPersons);
909  myLastParameterised.push_back(det);
910  } catch (InvalidArgument& e) {
911  myCurrentIsBroken = true;
912  WRITE_ERROR(e.what());
913  } catch (IOError& e) {
914  myCurrentIsBroken = true;
915  WRITE_ERROR(e.what());
916  }
917 }
918 
919 
920 void
922  myCurrentIsBroken = false;
923  bool ok = true;
924  // get the id, report an error if not given or empty...
925  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
926  if (!ok) {
927  myCurrentIsBroken = true;
928  return;
929  }
930  const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), ok);
931  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
932  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
933  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
934  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
935  if (!ok) {
936  myCurrentIsBroken = true;
937  return;
938  }
939  try {
940  Parameterised* det = myDetectorBuilder.buildInstantInductLoop(id, lane, position, FileHelpers::checkForRelativity(file, getFileName()), friendlyPos, vTypes);
941  myLastParameterised.push_back(det);
942  } catch (InvalidArgument& e) {
943  WRITE_ERROR(e.what());
944  } catch (IOError& e) {
945  WRITE_ERROR(e.what());
946  }
947  myCurrentIsBroken = true;
948 }
949 
950 
951 void
953  WRITE_WARNING("VTypeProbes are deprecated. Use fcd-output devices (assigned to the vType) instead.");
954  bool ok = true;
955  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
956  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
957  std::string type = attrs.getStringSecure(SUMO_ATTR_TYPE, "");
958  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
959  if (!ok) {
960  return;
961  }
962  try {
964  } catch (InvalidArgument& e) {
965  WRITE_ERROR(e.what());
966  } catch (IOError& e) {
967  WRITE_ERROR(e.what());
968  }
969 }
970 
971 
972 void
974  bool ok = true;
975  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
976  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
977  SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, -1);
978  std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
979  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
980  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
981  if (!ok) {
982  return;
983  }
984  try {
985  myDetectorBuilder.buildRouteProbe(id, edge, frequency, begin,
987  } catch (InvalidArgument& e) {
988  WRITE_ERROR(e.what());
989  } catch (IOError& e) {
990  WRITE_ERROR(e.what());
991  }
992 }
993 
994 
995 
996 void
998  myCurrentIsBroken = false;
999  // check whether this is a detector connected to a tls and optionally to a link
1000  bool ok = true;
1001  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
1002  const std::string lsaid = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), ok, "");
1003  const std::string toLane = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "");
1004  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
1005  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
1006  const double jamDistThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, 10.0f);
1007  double position = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), ok, std::numeric_limits<double>::max());
1008  const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), ok, std::numeric_limits<double>::max());
1009  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
1010  const bool showDetector = attrs.getOpt<bool>(SUMO_ATTR_SHOW_DETECTOR, id.c_str(), ok, true);
1011  const std::string contStr = attrs.getOpt<std::string>(SUMO_ATTR_CONT, id.c_str(), ok, "");
1012  if (contStr != "") {
1013  WRITE_WARNING("Ignoring deprecated argument 'cont' for E2 detector '" + id + "'");
1014  }
1015  std::string lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, "");
1016  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
1017  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
1018 
1019  double endPosition = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, std::numeric_limits<double>::max());
1020  const std::string lanes = attrs.getOpt<std::string>(SUMO_ATTR_LANES, id.c_str(), ok, ""); // lanes has priority to lane
1021  const std::string detectPersonsString = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, id.c_str(), ok, "");
1022  int detectPersons = 0;
1023  for (std::string mode : StringTokenizer(detectPersonsString).getVector()) {
1024  if (SUMOXMLDefinitions::PersonModeValues.hasString(mode)) {
1025  detectPersons |= (int)SUMOXMLDefinitions::PersonModeValues.get(mode);
1026  } else {
1027  WRITE_ERROR("Invalid person mode '" + mode + "' in E2 detector definition '" + id + "'");
1028  myCurrentIsBroken = true;
1029  return;
1030  }
1031  }
1032  if (!ok) {
1033  myCurrentIsBroken = true;
1034  return;
1035  }
1036 
1037  bool lanesGiven = lanes != "";
1038  bool laneGiven = lane != "";
1039  if (!(lanesGiven || laneGiven)) {
1040  // in absence of any lane-specification assume specification by id
1041  WRITE_WARNING("Trying to specify detector's lane by the given id since the argument 'lane' is missing.")
1042  lane = id;
1043  laneGiven = true;
1044  }
1045  bool lengthGiven = length != std::numeric_limits<double>::max();
1046  bool posGiven = position != std::numeric_limits<double>::max();
1047  bool endPosGiven = endPosition != std::numeric_limits<double>::max();
1048  bool lsaGiven = lsaid != "";
1049  bool toLaneGiven = toLane != "";
1050 
1051  MSLane* clane = nullptr;
1052  std::vector<MSLane*> clanes;
1053  if (lanesGiven) {
1054  // If lanes is given, endPos and startPos are required. lane, and length are ignored
1055  std::string seps = " ,\t\n";
1056  StringTokenizer st = StringTokenizer(lanes, seps, true);
1057 // std::cout << "Parsing lanes..." << std::endl;
1058  while (st.hasNext()) {
1059  std::string nextLaneID = st.next();
1060 // std::cout << "Next: " << nextLaneID << std::endl;
1061  if (nextLaneID.find_first_of(seps) != nextLaneID.npos) {
1062  continue;
1063  }
1064  clane = myDetectorBuilder.getLaneChecking(nextLaneID, SUMO_TAG_E2DETECTOR, id);
1065  clanes.push_back(clane);
1066  }
1067  if (clanes.size() == 0) {
1068  throw InvalidArgument("Malformed argument 'lanes' for E2Detector '" + id + "'.\nSpecify 'lanes' as a sequence of lane-IDs seperated by whitespace or comma (',')");
1069  }
1070  if (laneGiven) {
1071  WRITE_WARNING("Ignoring argument 'lane' for E2Detector '" + id + "' since argument 'lanes' was given.\n"
1072  "Usage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]");
1073  }
1074  if (lengthGiven) {
1075  WRITE_WARNING("Ignoring argument 'length' for E2Detector '" + id + "' since argument 'lanes' was given.\n"
1076  "Usage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]");
1077  }
1078  if (!posGiven) {
1079  // assuming start pos == lane start
1080  position = 0;
1081  WRITE_WARNING("Missing argument 'pos' for E2Detector '" + id + "'. Assuming detector start == lane start of lane '" + clanes[0]->getID() + "'.");
1082  }
1083  if (!endPosGiven) {
1084  // assuming end pos == lane end
1085  endPosition = clanes[clanes.size() - 1]->getLength();
1086  WRITE_WARNING("Missing argument 'endPos' for E2Detector '" + id + "'. Assuming detector end == lane end of lane '" + clanes[clanes.size() - 1]->getID() + "'.");
1087  }
1088 
1089  } else {
1090  if (!laneGiven) {
1091  std::stringstream ss;
1092  ss << "Missing argument 'lane' for E2Detector '" << id << "'."
1093  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
1094  throw InvalidArgument(ss.str());
1095  }
1097 
1098  if (posGiven) {
1099  // start pos is given
1100  if (endPosGiven && lengthGiven) {
1101  std::stringstream ss;
1102  ss << "Ignoring argument 'endPos' for E2Detector '" << id << "' since argument 'pos' was given."
1103  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
1104  WRITE_WARNING(ss.str());
1105  endPosition = std::numeric_limits<double>::max();
1106  }
1107  if (!lengthGiven && !endPosGiven) {
1108  std::stringstream ss;
1109  ss << "Missing arguments 'length'/'endPos' for E2Detector '" << id << "'. Assuming detector end == lane end of lane '" << lane << "'.";
1110  WRITE_WARNING(ss.str());
1111  endPosition = clane->getLength();
1112  }
1113  } else if (endPosGiven) {
1114  // endPos is given, pos is not given
1115  if (!lengthGiven) {
1116  std::stringstream ss;
1117  ss << "Missing arguments 'length'/'pos' for E2Detector '" << id << "'. Assuming detector start == lane start of lane '" << lane << "'.";
1118  WRITE_WARNING(ss.str());
1119  }
1120  } else {
1121  std::stringstream ss;
1122  if (lengthGiven && fabs(length - clane->getLength()) > NUMERICAL_EPS) {
1123  ss << "Incomplete positional specification for E2Detector '" << id << "'."
1124  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
1125  throw InvalidArgument(ss.str());
1126  }
1127  endPosition = clane->getLength();
1128  position = 0;
1129  ss << "Missing arguments 'pos'/'endPos' for E2Detector '" << id << "'. Assuming that the detector covers the whole lane '" << lane << "'.";
1130  WRITE_WARNING(ss.str());
1131  }
1132  }
1133 
1134  // Frequency
1135 
1136  SUMOTime frequency;
1137  if (!lsaGiven) {
1138  frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
1139  if (!ok) {
1140  myCurrentIsBroken = true;
1141  return;
1142  }
1143  } else {
1144  frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, false);
1145  }
1146 
1147  // TLS
1148  MSTLLogicControl::TLSLogicVariants* tlls = nullptr;
1149  if (lsaGiven) {
1150  tlls = &myJunctionControlBuilder.getTLLogic(lsaid);
1151  if (tlls->getActive() == nullptr) {
1152  throw InvalidArgument("The detector '" + id + "' refers to an unknown lsa '" + lsaid + "'.");
1153  }
1154  if (frequency != -1) {
1155  WRITE_WARNING("Ignoring argument 'frequency' for E2Detector '" + id + "' since argument 'tl' was given.");
1156  frequency = -1;
1157  }
1158  }
1159 
1160  // Link
1161  MSLane* cToLane = nullptr;
1162  if (toLaneGiven) {
1163  cToLane = myDetectorBuilder.getLaneChecking(toLane, SUMO_TAG_E2DETECTOR, id);
1164  }
1165 
1166  // File
1167  std::string filename;
1168  try {
1169  filename = FileHelpers::checkForRelativity(file, getFileName());
1170  } catch (IOError& e) {
1171  WRITE_ERROR(e.what());
1172  }
1173 
1174  Parameterised* det;
1175  // Build detector
1176  if (lanesGiven) {
1177  // specification by a lane sequence
1178  det = myDetectorBuilder.buildE2Detector(id, clanes, position, endPosition, filename, frequency,
1179  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
1180  vTypes, detectPersons, friendlyPos, showDetector,
1181  tlls, cToLane);
1182  } else {
1183  // specification by start or end lane
1184  det = myDetectorBuilder.buildE2Detector(id, clane, position, endPosition, length, filename, frequency,
1185  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
1186  vTypes, detectPersons, friendlyPos, showDetector,
1187  tlls, cToLane);
1188  }
1189  myLastParameterised.push_back(det);
1190 }
1191 
1192 
1193 void
1195  myCurrentIsBroken = false;
1196  bool ok = true;
1197  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
1198  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
1199  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
1200  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
1201  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
1202  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
1203  const bool openEntry = attrs.getOpt<bool>(SUMO_ATTR_OPEN_ENTRY, id.c_str(), ok, false);
1204  const std::string detectPersonsString = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, id.c_str(), ok, "");
1205  int detectPersons = 0;
1206  for (std::string mode : StringTokenizer(detectPersonsString).getVector()) {
1207  if (SUMOXMLDefinitions::PersonModeValues.hasString(mode)) {
1208  detectPersons |= (int)SUMOXMLDefinitions::PersonModeValues.get(mode);
1209  } else {
1210  WRITE_ERROR("Invalid person mode '" + mode + "' in E3 detector definition '" + id + "'");
1211  myCurrentIsBroken = true;
1212  return;
1213  }
1214  }
1215  if (!ok) {
1216  myCurrentIsBroken = true;
1217  return;
1218  }
1219  try {
1222  frequency, haltingSpeedThreshold, haltingTimeThreshold, vTypes, detectPersons, openEntry);
1223  myLastParameterised.push_back(det);
1224  } catch (InvalidArgument& e) {
1225  myCurrentIsBroken = true;
1226  WRITE_ERROR(e.what());
1227  } catch (IOError& e) {
1228  myCurrentIsBroken = true;
1229  WRITE_ERROR(e.what());
1230  }
1231 }
1232 
1233 
1234 void
1236  bool ok = true;
1237  const double position = attrs.get<double>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1238  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
1239  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1240  if (!ok) {
1241  return;
1242  }
1243  myDetectorBuilder.addE3Entry(lane, position, friendlyPos);
1244 }
1245 
1246 
1247 void
1249  bool ok = true;
1250  const double position = attrs.get<double>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1251  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
1252  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1253  if (!ok) {
1254  return;
1255  }
1256  myDetectorBuilder.addE3Exit(lane, position, friendlyPos);
1257 }
1258 
1259 
1260 void
1261 NLHandler::addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype) {
1262  bool ok = true;
1263  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
1264  const double maxTravelTime = attrs.getOpt<double>(SUMO_ATTR_MAX_TRAVELTIME, id.c_str(), ok, 100000);
1265  const double minSamples = attrs.getOpt<double>(SUMO_ATTR_MIN_SAMPLES, id.c_str(), ok, 0);
1266  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, POSITION_EPS);
1267  const std::string excludeEmpty = attrs.getOpt<std::string>(SUMO_ATTR_EXCLUDE_EMPTY, id.c_str(), ok, "false");
1268  const bool withInternal = attrs.getOpt<bool>(SUMO_ATTR_WITH_INTERNAL, id.c_str(), ok, false);
1269  const bool trackVehicles = attrs.getOpt<bool>(SUMO_ATTR_TRACK_VEHICLES, id.c_str(), ok, false);
1270  const std::string detectPersonsString = attrs.getOpt<std::string>(SUMO_ATTR_DETECT_PERSONS, id.c_str(), ok, "");
1271  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
1272  const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "performance");
1273  std::string vtypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
1274  const std::string writeAttributes = attrs.getOpt<std::string>(SUMO_ATTR_WRITE_ATTRIBUTES, id.c_str(), ok, "");
1275  const SUMOTime frequency = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, -1);
1276  const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("begin")));
1277  const SUMOTime end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("end")));
1278  if (!ok) {
1279  return;
1280  }
1281  int detectPersons = 0;
1282  for (std::string mode : StringTokenizer(detectPersonsString).getVector()) {
1283  if (SUMOXMLDefinitions::PersonModeValues.hasString(mode)) {
1284  detectPersons |= (int)SUMOXMLDefinitions::PersonModeValues.get(mode);
1285  } else {
1286  WRITE_ERROR("Invalid person mode '" + mode + "' in edgeData definition '" + id + "'");
1287  return;
1288  }
1289  }
1290  try {
1291  myDetectorBuilder.createEdgeLaneMeanData(id, frequency, begin, end,
1292  type, objecttype == SUMO_TAG_MEANDATA_LANE,
1293  // equivalent to TplConvert::_2bool used in SUMOSAXAttributes::getBool
1294  excludeEmpty[0] != 't' && excludeEmpty[0] != 'T' && excludeEmpty[0] != '1' && excludeEmpty[0] != 'x',
1295  excludeEmpty == "defaults", withInternal, trackVehicles, detectPersons,
1296  maxTravelTime, minSamples, haltingSpeedThreshold, vtypes, writeAttributes,
1298  } catch (InvalidArgument& e) {
1299  WRITE_ERROR(e.what());
1300  } catch (IOError& e) {
1301  WRITE_ERROR(e.what());
1302  }
1303 }
1304 
1305 
1306 void
1308  bool ok = true;
1309  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, nullptr, ok);
1310  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
1311  if (!MSGlobals::gUsingInternalLanes && (fromID[0] == ':' || toID[0] == ':')) {
1312  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, nullptr, ok, "");
1313  if (tlID != "") {
1314  int tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok);
1316  }
1317  return;
1318  }
1319 
1320  MSLink* link = nullptr;
1321  try {
1322  const int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, nullptr, ok);
1323  const int toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, nullptr, ok);
1324  LinkDirection dir = parseLinkDir(attrs.get<std::string>(SUMO_ATTR_DIR, nullptr, ok));
1325  LinkState state = parseLinkState(attrs.get<std::string>(SUMO_ATTR_STATE, nullptr, ok));
1326  const double foeVisibilityDistance = attrs.getOpt<double>(SUMO_ATTR_VISIBILITY_DISTANCE, nullptr, ok, state == LINKSTATE_ZIPPER ? 100 : 4.5);
1327  const bool keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, nullptr, ok, true);
1328  const bool indirect = attrs.getOpt<bool>(SUMO_ATTR_INDIRECT, nullptr, ok, false);
1329  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, nullptr, ok, "");
1330  std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, nullptr, ok, "");
1331 
1332  MSEdge* from = MSEdge::dictionary(fromID);
1333  if (from == nullptr) {
1334  WRITE_ERROR("Unknown from-edge '" + fromID + "' in connection.");
1335  return;
1336  }
1337  MSEdge* to = MSEdge::dictionary(toID);
1338  if (to == nullptr) {
1339  WRITE_ERROR("Unknown to-edge '" + toID + "' in connection.");
1340  return;
1341  }
1342  if (fromLaneIdx < 0 || fromLaneIdx >= (int)from->getLanes().size() ||
1343  toLaneIdx < 0 || toLaneIdx >= (int)to->getLanes().size()) {
1344  WRITE_ERROR("Invalid lane index in connection from '" + from->getID() + "' to '" + to->getID() + "'.");
1345  return;
1346  }
1347  MSLane* fromLane = from->getLanes()[fromLaneIdx];
1348  MSLane* toLane = to->getLanes()[toLaneIdx];
1349  assert(fromLane);
1350  assert(toLane);
1351 
1352  MSTrafficLightLogic* logic = nullptr;
1353  int tlLinkIdx = -1;
1354  if (tlID != "") {
1355  tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok);
1356  // make sure that the index is in range
1358  if ((tlLinkIdx < 0 || tlLinkIdx >= (int)logic->getCurrentPhaseDef().getState().size())
1359  && logic->getLogicType() != TrafficLightType::RAIL_SIGNAL
1360  && logic->getLogicType() != TrafficLightType::RAIL_CROSSING) {
1361  WRITE_ERROR("Invalid " + toString(SUMO_ATTR_TLLINKINDEX) + " '" + toString(tlLinkIdx) +
1362  "' in connection controlled by '" + tlID + "'");
1363  return;
1364  }
1365  if (!ok) {
1366  return;
1367  }
1368  }
1369  double length;
1370  // build the link
1371  MSLane* via = nullptr;
1372  if (viaID != "" && MSGlobals::gUsingInternalLanes) {
1373  via = MSLane::dictionary(viaID);
1374  if (via == nullptr) {
1375  WRITE_ERROR("An unknown lane ('" + viaID +
1376  "') should be set as a via-lane for lane '" + toLane->getID() + "'.");
1377  return;
1378  }
1379  length = via->getLength();
1380  } else if (toLane->getEdge().isCrossing()) {
1381  length = toLane->getLength();
1382  } else {
1383  length = fromLane->getShape()[-1].distanceTo(toLane->getShape()[0]);
1384  }
1385  link = new MSLink(fromLane, toLane, via, dir, state, length, foeVisibilityDistance, keepClear, logic, tlLinkIdx, indirect);
1386  if (via != nullptr) {
1387  via->addIncomingLane(fromLane, link);
1388  } else {
1389  toLane->addIncomingLane(fromLane, link);
1390  }
1391  toLane->addApproachingLane(fromLane, myNetworkVersion < 0.25);
1392 
1393  // if a traffic light is responsible for it, inform the traffic light
1394  // check whether this link is controlled by a traffic light
1395  // we can not reuse logic here because it might be an inactive one
1396  if (tlID != "") {
1397  myJunctionControlBuilder.getTLLogic(tlID).addLink(link, fromLane, tlLinkIdx);
1398  }
1399  // add the link
1400  fromLane->addLink(link);
1401 
1402  } catch (InvalidArgument& e) {
1403  WRITE_ERROR(e.what());
1404  }
1405 }
1406 
1407 
1409 NLHandler::parseLinkDir(const std::string& dir) {
1410  if (SUMOXMLDefinitions::LinkDirections.hasString(dir)) {
1412  } else {
1413  throw InvalidArgument("Unrecognised link direction '" + dir + "'.");
1414  }
1415 }
1416 
1417 
1418 LinkState
1419 NLHandler::parseLinkState(const std::string& state) {
1420  if (SUMOXMLDefinitions::LinkStates.hasString(state)) {
1421  return SUMOXMLDefinitions::LinkStates.get(state);
1422  } else {
1423  if (state == "t") { // legacy networks
1424  // WRITE_WARNING("Obsolete link state 't'. Use 'o' instead");
1426  } else {
1427  throw InvalidArgument("Unrecognised link state '" + state + "'.");
1428  }
1429  }
1430 }
1431 
1432 
1433 // ----------------------------------
1434 void
1436  if (myNetIsLoaded) {
1437  //WRITE_WARNING("POIs and Polygons should be loaded using option --po-files")
1438  return;
1439  }
1440  bool ok = true;
1441  PositionVector s = attrs.get<PositionVector>(SUMO_ATTR_NET_OFFSET, nullptr, ok);
1442  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, nullptr, ok);
1443  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, nullptr, ok);
1444  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, nullptr, ok);
1445  if (ok) {
1446  Position networkOffset = s[0];
1447  GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
1448  if (OptionsCont::getOptions().getBool("fcd-output.geo") && !GeoConvHelper::getFinal().usingGeoProjection()) {
1449  WRITE_WARNING("no valid geo projection loaded from network. fcd-output.geo will not work");
1450  }
1451  }
1452 }
1453 
1454 
1455 void
1457  bool ok = true;
1458  myCurrentIsBroken = false;
1459  // get the id, report an error if not given or empty...
1460  myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
1461  if (!ok) {
1462  myCurrentIsBroken = true;
1463  return;
1464  }
1465  try {
1467  if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) {
1468  delete sink;
1469  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists.");
1470  }
1471  sink->initialize(new std::vector<MSLane*>());
1473  if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) {
1474  delete source;
1475  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists.");
1476  }
1477  source->initialize(new std::vector<MSLane*>());
1478  sink->setOtherTazConnector(source);
1479  source->setOtherTazConnector(sink);
1480  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1481  std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES);
1482  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
1483  MSEdge* edge = MSEdge::dictionary(*i);
1484  // check whether the edge exists
1485  if (edge == nullptr) {
1486  throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known.");
1487  }
1488  source->addSuccessor(edge);
1489  edge->addSuccessor(sink);
1490  }
1491  }
1492  RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, myCurrentDistrictID.c_str(), ok, RGBColor::parseColor("1.0,.33,.33"));
1493  const std::string name = attrs.getOpt<std::string>(SUMO_ATTR_NAME, myCurrentDistrictID.c_str(), ok, "");
1494  source->setParameter("tazColor", toString(color));
1495  sink->setParameter("tazColor", toString(color));
1496 
1497  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
1499  const bool fill = attrs.getOpt<bool>(SUMO_ATTR_FILL, myCurrentDistrictID.c_str(), ok, false);
1500  if (shape.size() != 0) {
1501  if (!myNet.getShapeContainer().addPolygon(myCurrentDistrictID, "taz", color, 0, 0, "", false, shape, false, fill, 1.0, false, name)) {
1502  WRITE_WARNING("Skipping visualization of taz '" + myCurrentDistrictID + "', polygon already exists.");
1503  }
1504  }
1505  }
1506  } catch (InvalidArgument& e) {
1507  WRITE_ERROR(e.what());
1508  myCurrentIsBroken = true;
1509  }
1510 }
1511 
1512 
1513 void
1514 NLHandler::addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource) {
1515  if (myCurrentIsBroken) {
1516  // earlier error
1517  return;
1518  }
1519  bool ok = true;
1520  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentDistrictID.c_str(), ok);
1521  MSEdge* succ = MSEdge::dictionary(id);
1522  if (succ != nullptr) {
1523  // connect edge
1524  if (isSource) {
1525  MSEdge::dictionary(myCurrentDistrictID + "-source")->addSuccessor(succ);
1526  } else {
1527  succ->addSuccessor(MSEdge::dictionary(myCurrentDistrictID + "-sink"));
1528  }
1529  } else {
1530  WRITE_ERROR("At district '" + myCurrentDistrictID + "': succeeding edge '" + id + "' does not exist.");
1531  }
1532 }
1533 
1534 
1535 void
1537  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1538  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
1539  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
1540  MSEdge* edge = MSEdge::dictionary(*it);
1541  if (edge == nullptr) {
1542  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
1543  } else {
1544  edge->markAsRoundabout();
1545  }
1546  }
1547  } else {
1548  WRITE_ERROR("Empty edges in roundabout.");
1549  }
1550 }
1551 
1552 
1553 void
1555  bool ok = true;
1556  MESegment::MesoEdgeType edgeType = myNet.getMesoType(""); // init defaults
1557  edgeType.tauff = attrs.getOptSUMOTimeReporting(SUMO_ATTR_MESO_TAUFF, myCurrentTypeID.c_str(), ok, edgeType.tauff);
1558  edgeType.taufj = attrs.getOptSUMOTimeReporting(SUMO_ATTR_MESO_TAUFJ, myCurrentTypeID.c_str(), ok, edgeType.taufj);
1559  edgeType.taujf = attrs.getOptSUMOTimeReporting(SUMO_ATTR_MESO_TAUJF, myCurrentTypeID.c_str(), ok, edgeType.taujf);
1560  edgeType.taujj = attrs.getOptSUMOTimeReporting(SUMO_ATTR_MESO_TAUJJ, myCurrentTypeID.c_str(), ok, edgeType.taujj);
1561  edgeType.jamThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, myCurrentTypeID.c_str(), ok, edgeType.jamThreshold);
1562  edgeType.junctionControl = attrs.getOpt<bool>(SUMO_ATTR_MESO_JUNCTION_CONTROL, myCurrentTypeID.c_str(), ok, edgeType.junctionControl);
1563  edgeType.tlsPenalty = attrs.getOpt<double>(SUMO_ATTR_MESO_TLS_PENALTY, myCurrentTypeID.c_str(), ok, edgeType.tlsPenalty);
1564  edgeType.tlsFlowPenalty = attrs.getOpt<double>(SUMO_ATTR_MESO_TLS_FLOW_PENALTY, myCurrentTypeID.c_str(), ok, edgeType.tlsFlowPenalty);
1566  edgeType.overtaking = attrs.getOpt<bool>(SUMO_ATTR_MESO_OVERTAKING, myCurrentTypeID.c_str(), ok, edgeType.overtaking);
1567 
1568  if (ok) {
1569  myNet.addMesoType(myCurrentTypeID, edgeType);
1570  }
1571  if (myNetIsLoaded) {
1572  myHaveSeenMesoEdgeType = true;
1573  }
1574 }
1575 
1576 // ----------------------------------
1577 void
1579  try {
1581  } catch (InvalidArgument& e) {
1582  WRITE_ERROR(e.what());
1583  }
1584 }
1585 
1586 
1587 void
1589  if (!myCurrentIsBroken) {
1590  try {
1592  } catch (InvalidArgument& e) {
1593  WRITE_ERROR(e.what());
1594  myCurrentIsBroken = true;
1595  }
1596  }
1597  myCurrentWAUTID = "";
1598 }
1599 
1600 
1601 Position
1602 NLShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, bool friendlyPos, double lanePosLat) {
1603  MSLane* lane = MSLane::dictionary(laneID);
1604  if (lane == nullptr) {
1605  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1606  return Position::INVALID;
1607  }
1608  if (lanePos < 0) {
1609  lanePos = lane->getLength() + lanePos;
1610  }
1611  if ((lanePos < 0) && friendlyPos) {
1612  lanePos = 0;
1613  }
1614  if ((lanePos > lane->getLength()) && friendlyPos) {
1615  lanePos = lane->getLength();
1616  }
1617  if (lanePos < 0 || lanePos > lane->getLength()) {
1618  WRITE_WARNING("lane position " + toString(lanePos) + " for poi '" + poiID + "' is not valid.");
1619  }
1620  return lane->geometryPositionAtOffset(lanePos, -lanePosLat);
1621 }
1622 
1623 
1624 void
1626  if (rs == nullptr) {
1627  throw InvalidArgument("Rail signal '" + toString((SumoXMLTag)element) + "' constraint must occur within a railSignalConstraints element");
1628  }
1629  bool ok = true;
1630  const std::string tripId = attrs.get<std::string>(SUMO_ATTR_TRIP_ID, nullptr, ok);
1631  const std::string signalID = attrs.get<std::string>(SUMO_ATTR_TLID, nullptr, ok);
1632  const std::string foesString = attrs.get<std::string>(SUMO_ATTR_FOES, nullptr, ok);
1633  const std::vector<std::string> foes = StringTokenizer(foesString).getVector();
1634  const int limit = attrs.getOpt<int>(SUMO_ATTR_LIMIT, nullptr, ok, (int)foes.size());
1635 
1636  if (!MSNet::getInstance()->getTLSControl().knows(signalID)) {
1637  throw InvalidArgument("Rail signal '" + signalID + "' in railSignalConstraints is not known");
1638  }
1639  MSRailSignal* signal = dynamic_cast<MSRailSignal*>(MSNet::getInstance()->getTLSControl().get(signalID).getDefault());
1640  if (signal == nullptr) {
1641  throw InvalidArgument("Traffic light '" + signalID + "' is not a rail signal");
1642  }
1643  if (ok) {
1644  for (const std::string& foe : foes) {
1645  MSRailSignalConstraint* c = new MSRailSignalConstraint_Predecessor(signal, foe, limit);
1646  if (element == SUMO_TAG_PREDECESSOR) {
1647  rs->addConstraint(tripId, c);
1648  } else if (element == SUMO_TAG_INSERTION_PREDECESSOR) {
1649  rs->addInsertionConstraint(tripId, c);
1650  } else {
1651  throw InvalidArgument("Unsupported rail signal constraint '" + toString((SumoXMLTag)element) + "'");
1652  }
1653  }
1654  }
1655 }
1656 
1657 
1658 /****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:281
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define TIME2STEPS(x)
Definition: SUMOTime.h:55
long long int SUMOTime
Definition: SUMOTime.h:32
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
const SVCPermissions SVCAll
all VClasses are allowed
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
TrafficLightType
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_TRACTION_SUBSTATION
A traction substation.
@ SUMO_TAG_PHASE
a single phase description
@ SUMO_TAG_RAILSIGNAL_CONSTRAINTS
Constraints on switching a rail signal.
@ SUMO_TAG_NET
root element of a network file
@ SUMO_TAG_REROUTER
A rerouter.
@ SUMO_TAG_INSERTION_PREDECESSOR
Predecessor constraint on insertion before rail signal.
@ SUMO_TAG_STOPOFFSET
Information on vClass specific stop offsets at lane end.
@ SUMO_TAG_WAUT_JUNCTION
@ SUMO_TAG_REQUEST
description of a logic request within the junction
@ SUMO_TAG_WAUT_SWITCH
@ SUMO_TAG_ROUTEPROBE
a routeprobe detector
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_TIMEDEVENT
The definition of a periodic event.
@ SUMO_TAG_E2DETECTOR
an e2 detector
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ SUMO_TAG_CONDITION
a condition for phase switching
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_MESO
edge-specific meso settings
@ SUMO_TAG_MEANDATA_LANE
a lane based mean data detector
@ SUMO_TAG_LOCATION
@ SUMO_TAG_RESTRICTION
begin/end of the description of an edge restriction
@ SUMO_TAG_OVERHEAD_WIRE_CLAMP
An overhead wire clamp (connection of wires in opposite directions)
@ SUMO_TAG_CONNECTION
connectio between two lanes
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_ROUNDABOUT
roundabout defined in junction
@ SUMO_TAG_DET_ENTRY
an e3 entry point
@ SUMO_TAG_TLLOGIC
a traffic light logic
@ SUMO_TAG_PARKING_SPACE
A parking space for a single vehicle within a parking area.
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_MEANDATA_EDGE
an edge based mean data detector
@ SUMO_TAG_OVERHEAD_WIRE_SECTION
An overhead wire section.
@ SUMO_TAG_VTYPEPROBE
a vtypeprobe detector
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_INSTANT_INDUCTION_LOOP
An instantenous induction loop.
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_E1DETECTOR
an e1 detector
@ SUMO_TAG_DET_EXIT
an e3 exit point
@ SUMO_TAG_TYPE
type (edge)
@ SUMO_TAG_VAPORIZER
vaporizer of vehicles
@ SUMO_TAG_LANE_AREA_DETECTOR
alternative tag for e2 detector
@ SUMO_TAG_WAUT
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ SUMO_TAG_NEIGH
begin/end of the description of a neighboring lane
@ SUMO_TAG_INDUCTION_LOOP
alternative tag for e1 detector
@ SUMO_TAG_CALIBRATOR
A calibrator placed over edge.
@ SUMO_TAG_ENTRY_EXIT_DETECTOR
alternative tag for e3 detector
@ SUMO_TAG_E3DETECTOR
an e3 detector
@ SUMO_TAG_VSS
A variable speed sign.
@ SUMO_TAG_PREDECESSOR
Predecessor constraint on switching a rail signal.
@ SUMO_TAG_EDGE
begin/end of the description of an edge
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)....
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_ZIPPER
This is an uncontrolled, zipper-merge link.
@ LINKSTATE_TL_OFF_BLINKING
The link is controlled by a tls which is off and blinks, has to brake.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_CONV_BOUNDARY
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ SUMO_ATTR_NET_OFFSET
@ SUMO_ATTR_CONT
@ SUMO_ATTR_ORIG_BOUNDARY
@ SUMO_ATTR_MESO_TLS_FLOW_PENALTY
@ SUMO_ATTR_LATEST_END
The maximum time within the cycle for switching (for coordinated actuation)
@ SUMO_ATTR_MESO_JUNCTION_CONTROL
@ SUMO_ATTR_RED
red duration of a phase
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_VIA
@ SUMO_ATTR_FILE
@ SUMO_ATTR_PROCEDURE
@ SUMO_ATTR_INDIRECT
Whether this connection is an indirect (left) turn.
@ SUMO_ATTR_Y
@ SUMO_ATTR_FROM_LANE
@ SUMO_ATTR_Z
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_JAM_DIST_THRESHOLD
@ SUMO_ATTR_MESO_OVERTAKING
@ SUMO_ATTR_TRACK_VEHICLES
@ SUMO_ATTR_RESPONSE
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_TARGETLANE
@ SUMO_ATTR_OFFSET
@ SUMO_ATTR_X
@ SUMO_ATTR_WAUT_ID
@ SUMO_ATTR_YELLOW
yellow duration of a phase
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_INTLANES
@ SUMO_ATTR_VEHICLEEXTENSION
vehicle extension time of a phase
@ SUMO_ATTR_WITH_INTERNAL
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_START_PROG
@ SUMO_ATTR_BIDI
@ SUMO_ATTR_HALTING_TIME_THRESHOLD
@ SUMO_ATTR_LIMIT
@ SUMO_ATTR_PRIORITY
@ SUMO_ATTR_MESO_TAUFF
@ SUMO_ATTR_LANES
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_LEFTHAND
@ SUMO_ATTR_NEXT
succesor phase index
@ SUMO_ATTR_MAX_TRAVELTIME
@ SUMO_ATTR_MESO_MINOR_PENALTY
@ SUMO_ATTR_INCLANES
@ SUMO_ATTR_CHANGE_LEFT
@ SUMO_ATTR_INDEX
@ SUMO_ATTR_FILL
Fill the polygon.
@ SUMO_ATTR_NAME
@ SUMO_ATTR_ORIG_PROJ
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_FINAL_TARGET
The condition expression for switching into this phase when the active phase must end.
@ SUMO_ATTR_HALTING_SPEED_THRESHOLD
@ SUMO_ATTR_FREQUENCY
@ SUMO_ATTR_HIGHER_SPEED
@ SUMO_ATTR_TRIP_ID
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ACCELERATION
@ SUMO_ATTR_CHANGE_RIGHT
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_VCLASS
@ SUMO_ATTR_DISTANCE
@ SUMO_ATTR_EARLY_TARGET
The condition expression for an early switch into this phase.
@ SUMO_ATTR_MESO_TAUJF
@ SUMO_ATTR_SHOW_DETECTOR
@ SUMO_ATTR_FOES
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_TO_LANE
@ SUMO_ATTR_MIN_SAMPLES
@ SUMO_ATTR_JUNCTION_ID
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_VERSION
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_ATTR_ID
@ SUMO_ATTR_MAXDURATION
maximum duration of a phase
@ SUMO_ATTR_PROGRAMID
@ SUMO_ATTR_MESO_TAUFJ
@ SUMO_ATTR_VISIBILITY_DISTANCE
foe visibility distance of a link
@ SUMO_ATTR_OPEN_ENTRY
@ SUMO_ATTR_MESO_TAUJJ
@ SUMO_ATTR_DURATION
@ SUMO_ATTR_WIDTH
@ SUMO_ATTR_CROSSING_EDGES
the edges crossed by a pedestrian crossing
@ SUMO_ATTR_SYNCHRON
@ SUMO_ATTR_DIR
The abstract direction of a link.
@ SUMO_ATTR_TLLINKINDEX
link: the index of the link within the traffic light
@ SUMO_ATTR_MINDURATION
@ SUMO_ATTR_MESO_TLS_PENALTY
@ SUMO_ATTR_KEY
@ SUMO_ATTR_REF_TIME
@ SUMO_ATTR_KEEP_CLEAR
Whether vehicles must keep the junction clear.
@ SUMO_ATTR_POSITION
@ SUMO_ATTR_STATE
The state of a link.
@ SUMO_ATTR_TIME
trigger: the time of the step
@ SUMO_ATTR_WRITE_ATTRIBUTES
@ SUMO_ATTR_DETECT_PERSONS
@ SUMO_ATTR_EXCLUDE_EMPTY
@ SUMO_ATTR_EARLIEST_END
The minimum time within the cycle for switching (for coordinated actuation)
const double SUMO_const_laneWidth
Definition: StdDefs.h:48
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 std::string checkForRelativity(const std::string &filename, const std::string &basePath)
Returns the path from a configuration so that it is accessable from the current working directory.
const std::string & getFileName() const
returns the current file name
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
A road/street connecting two junctions.
Definition: MSEdge.h:77
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition: MSEdge.h:267
void setOtherTazConnector(const MSEdge *edge)
Definition: MSEdge.h:289
void setJunctions(MSJunction *from, MSJunction *to)
Definition: MSEdge.cpp:1144
void addSuccessor(MSEdge *edge, const MSEdge *via=nullptr)
Adds an edge to the list of edges which may be reached from this edge and to the incoming of the othe...
Definition: MSEdge.cpp:1069
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:99
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition: MSEdge.cpp:885
void markAsRoundabout()
Definition: MSEdge.h:689
static bool gUseMesoSim
Definition: MSGlobals.h:94
static bool gLefthand
Whether lefthand-drive is being simulated.
Definition: MSGlobals.h:157
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:72
The base class for an intersection.
Definition: MSJunction.h:58
void addOutgoing(MSEdge *edge)
Definition: MSJunction.h:125
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:121
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:2316
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:2306
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:250
double getLength() const
Returns the lane's length.
Definition: MSLane.h:541
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1991
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:674
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:478
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:505
The simulated network and simulation perfomer.
Definition: MSNet.h:88
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:449
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:499
void setPermissionsFound()
Labels the network to contain vehicle class permissions.
Definition: MSNet.h:215
void addMesoType(const std::string &typeID, const MESegment::MesoEdgeType &edgeType)
Adds edge type specific meso parameters.
Definition: MSNet.cpp:349
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition: MSNet.cpp:334
const MESegment::MesoEdgeType & getMesoType(const std::string &typeID)
Returns edge type specific meso parameters if no type specific parameters have been loaded,...
Definition: MSNet.cpp:354
The definition of a single phase of a tls logic.
std::string name
Optional name or description for the current phase.
std::vector< std::string > myTargetLaneSet
SUMOTime maxDuration
The maximum duration of the phase.
bool myCommit
the phase is a commit, compulsory directive for SOTL policies
static const SUMOTime UNSPECIFIED_DURATION
SUMOTime vehext
for NEMA phase
SUMOTime latestEnd
The maximum time within the cycle for switching (for coordinated actuation)
bool myTransientNotDecisional
the phase is a transient one or a decisional one, compulsory directive for SOTL policies
SUMOTime minDuration
The minimum duration of the phase.
SUMOTime yellow
for NEMA phase
SUMOTime red
for NEMA phase
SUMOTime myLastSwitch
Stores the timestep of the last on-switched of the phase.
SUMOTime duration
The duration of the phase.
std::vector< int > nextPhases
The index of the phase that suceeds this one (or -1)
std::string finalTarget
The condition expression for switching into this phase when the active phase must end.
std::string earlyTarget
The condition expression for an early switch into this phase.
SUMOTime earliestEnd
The minimum time within the cycle for switching (for coordinated actuation)
A base class for constraints.
A signal for rails.
Definition: MSRailSignal.h:46
void addConstraint(const std::string &tripId, MSRailSignalConstraint *constraint)
register contraint for signal switching
void addInsertionConstraint(const std::string &tripId, MSRailSignalConstraint *constraint)
register contraint for vehicle insertion
Parser and container for routes during their loading.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Storage for all programs of a single tls.
void addLink(MSLink *link, MSLane *lane, int pos)
MSTrafficLightLogic * getActive() const
MSTrafficLightLogic * getDefault() const
return the default program (that last used program except TRACI_PROGRAM)
void addWAUTJunction(const std::string &wautid, const std::string &tls, const std::string &proc, bool synchron)
Adds a tls to the list of tls to be switched by the named WAUT.
void addWAUT(SUMOTime refTime, const std::string &id, const std::string &startProg, SUMOTime period)
Adds a WAUT definition.
bool knows(const std::string &id) const
Returns the information whether the named tls is stored.
void addWAUTSwitch(const std::string &wautid, SUMOTime when, const std::string &to)
Adds a WAUT switch step to a previously built WAUT.
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
void closeWAUT(const std::string &wautid)
Closes loading of a WAUT.
The parent class for traffic light logics.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:80
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:117
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:67
Builds detectors for microsim.
void endE3Detector()
Builds of an e3 detector using collected values.
Parameterised * buildInductLoop(const std::string &id, const std::string &lane, double pos, SUMOTime splInterval, const std::string &device, bool friendlyPos, const std::string &vTypes, int detectPersons)
Builds an e1 detector and adds it to the net.
MSLane * getLaneChecking(const std::string &laneID, SumoXMLTag type, const std::string &detid)
Returns the named lane.
Parameterised * buildE2Detector(const std::string &id, MSLane *lane, double pos, double endPos, double length, const std::string &device, SUMOTime frequency, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string &vTypes, int detectPersons, bool friendlyPos, bool showDetector, MSTLLogicControl::TLSLogicVariants *tlls=0, MSLane *toLane=0)
Builds a new E2 detector and adds it to the net's detector control. Also performs some consistency ch...
void buildVTypeProbe(const std::string &id, const std::string &vtype, SUMOTime frequency, const std::string &device)
Builds a vTypeProbe and adds it to the net.
void addE3Exit(const std::string &lane, double pos, bool friendlyPos)
Builds an exit point of an e3 detector.
Parameterised * beginE3Detector(const std::string &id, const std::string &device, SUMOTime splInterval, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, int detectPersons, bool openEntry)
Stores temporary the initial information about an e3 detector to build.
void createEdgeLaneMeanData(const std::string &id, SUMOTime frequency, SUMOTime begin, SUMOTime end, const std::string &type, const bool useLanes, const bool withEmpty, const bool printDefaults, const bool withInternal, const bool trackVehicles, const int detectPersons, const double maxTravelTime, const double minSamples, const double haltSpeed, const std::string &vTypes, const std::string &writeAttributes, const std::string &device)
Creates edge based mean data collector using the given specification.
void buildRouteProbe(const std::string &id, const std::string &edge, SUMOTime frequency, SUMOTime begin, const std::string &device, const std::string &vTypes)
Builds a routeProbe and adds it to the net.
void addE3Entry(const std::string &lane, double pos, bool friendlyPos)
Builds an entry point of an e3 detector.
Parameterised * buildInstantInductLoop(const std::string &id, const std::string &lane, double pos, const std::string &device, bool friendlyPos, const std::string &vTypes)
Builds an instantenous induction and adds it to the net.
std::string getCurrentE3ID() const
Returns the id of the currently built e3 detector.
void addAction(const SUMOSAXAttributes &attrs, const std::string &basePath)
Builds an action and saves it for further use.
Interface for building edges.
virtual MSEdge * closeEdge()
Closes the building of an edge; The edge is completely described by now and may not be opened again.
virtual void addNeigh(const std::string id)
Adds a neighbor to the current lane.
void closeLane()
Closes the building of a lane; The edge is completely described by now and may not be opened again.
std::string reportCurrentEdgeOrLane() const
Return info about currently processed edge or lane.
void beginEdgeParsing(const std::string &id, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, int priority, const std::string &bidi, double distance)
Begins building of an MSEdge.
virtual MSLane * addLane(const std::string &id, double maxSpeed, double length, const PositionVector &shape, double width, SVCPermissions permissions, SVCPermissions changeLeft, SVCPermissions changeRight, int index, bool isRampAccel, const std::string &type)
Adds a lane to the current edge.
virtual void addCrossingEdges(const std::vector< std::string > &)
add the crossingEdges in a crossing edge if present
void addStopOffsets(const StopOffset &stopOffsets)
process a stopOffset element (originates either from the active edge or lane).
virtual MSEdge * buildEdge(const std::string &id, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, const int priority, const double distance)
Builds an edge instance (MSEdge in this case)
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:704
bool myHaveSeenMesoEdgeType
whether edge type specific meso paramters were loaded
Definition: NLHandler.h:362
std::vector< Parameterised * > myLastParameterised
Definition: NLHandler.h:344
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:997
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1536
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:664
virtual void addMesoEdgeType(const SUMOSAXAttributes &attrs)
Loads edge type specific meso parameters.
Definition: NLHandler.cpp:1554
bool myCurrentIsBroken
Definition: NLHandler.h:339
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:1235
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Definition: NLHandler.cpp:393
bool myHaveSeenAdditionalSpeedRestrictions
whether additional files contained type-specific speed limits
Definition: NLHandler.h:359
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:322
void addPhase(const SUMOSAXAttributes &attrs)
adds a phase to the traffic lights logic currently build
Definition: NLHandler.cpp:784
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:331
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:952
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1514
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:328
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:598
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:487
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:729
Parameterised myLastEdgeParameters
Definition: NLHandler.h:343
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: NLHandler.cpp:296
bool myHaveSeenDefaultLength
whether the loaded network contains edges with default lengths
Definition: NLHandler.h:353
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:313
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:921
virtual void openJunction(const SUMOSAXAttributes &attrs)
opens a junction for processing
Definition: NLHandler.cpp:548
virtual void endE3Detector()
Builds of an e3 detector using collected values.
Definition: NLHandler.cpp:1578
bool myAmParsingTLLogicOrJunction
internal information whether a tls-logic is currently read
Definition: NLHandler.h:325
JunctionGraph myJunctionGraph
Definition: NLHandler.h:375
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:365
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1456
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:306
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:316
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:744
void closeWAUT()
Definition: NLHandler.cpp:1588
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:347
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:61
void addCondition(const SUMOSAXAttributes &attrs)
adds a switching condition to the traffic lights logic currently build
Definition: NLHandler.cpp:864
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1435
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:88
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:356
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:636
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
Definition: NLHandler.cpp:1419
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:303
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:310
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:319
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:875
static void addPredecessorConstraint(int element, const SUMOSAXAttributes &attrs, MSRailSignal *rs)
Definition: NLHandler.cpp:1625
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:84
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:1248
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:1194
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:469
bool myHaveJunctionHigherSpeeds
Whether the network was built with higher speed on junctions.
Definition: NLHandler.h:350
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:223
MSRailSignal * myConstrainedSignal
rail signal for which constraints are being loaded
Definition: NLHandler.h:371
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1409
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:368
void addWAUTJunction(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:683
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:973
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:1261
bool myHaveWarnedAboutInvalidTLType
Definition: NLHandler.h:341
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:618
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:1307
Builder of microsim-junctions and tls.
void closeJunctionLogic()
Ends the building of a junction logic (row-logic)
MSTLLogicControl::TLSLogicVariants & getTLLogic(const std::string &id) const
Returns a previously build tls logic.
MSJunction * retrieve(const std::string id)
try to retrieve junction by id
int getNumberOfLoadedPhases() const
return the number of phases loaded so far (for error reporting)
void addPhase(MSPhaseDefinition *phase)
Adds a phase to the currently built traffic lights logic.
MSTLLogicControl & getTLLogicControlToUse() const
Returns the used tls control.
const std::string & getActiveSubKey() const
Returns the active sub key.
bool addCondition(const std::string &id, const std::string &value)
Adds a condition to the currently built traffic lights logic.
void openJunction(const std::string &id, const std::string &key, const SumoXMLNodeType type, const Position pos, const PositionVector &shape, const std::vector< MSLane * > &incomingLanes, const std::vector< MSLane * > &internalLanes, const std::string &name)
Begins the processing of the named junction.
void addParam(const std::string &key, const std::string &value)
Adds a parameter.
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
void initTrafficLightLogic(const std::string &id, const std::string &programID, TrafficLightType type, SUMOTime offset)
Begins the reading of a traffic lights logic.
const std::string & getActiveKey() const
Returns the active key.
void addLogicItem(int request, const std::string &response, const std::string &foes, bool cont)
Adds a logic item.
void closeJunction(const std::string &basePath)
Closes (ends) the processing of the current junction.
virtual void closeTrafficLightLogic(const std::string &basePath)
Ends the building of a traffic lights logic.
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, bool friendlyPos, double lanePosLat)
get position for a given laneID (Has to be implemented in all child)
Definition: NLHandler.cpp:1602
Builds trigger objects for microsim.
void parseAndBuildTractionSubstation(MSNet &net, const SUMOSAXAttributes &attrs)
Parses its values and builds a traction substation.
void addAccess(MSNet &net, const SUMOSAXAttributes &attrs)
Parses the values and adds an access point to the currently parsed stopping place.
void parseAndBuildOverheadWireSegment(MSNet &net, const SUMOSAXAttributes &attrs)
Parses its values and builds an overhead wire segment.
void parseAndBuildCalibrator(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a mesoscopic or microscopic calibrator.
virtual void endParkingArea()
End a parking area.
void parseAndBuildLaneSpeedTrigger(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a lane speed trigger.
void parseAndAddLotEntry(const SUMOSAXAttributes &attrs)
Parses his values and adds a lot entry to current parking area.
void buildVaporizer(const SUMOSAXAttributes &attrs)
Builds a vaporization.
void parseAndBuildOverheadWireSection(MSNet &net, const SUMOSAXAttributes &attrs)
Parses its values and builds an overhead wire section.
void parseAndBuildChargingStation(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a charging station.
void parseAndBuildOverheadWireClamp(MSNet &net, const SUMOSAXAttributes &attrs)
Parses its values and builds an overhead wire clamp.
void parseAndBuildRerouter(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a rerouter.
virtual void endStoppingPlace()
End a stopping place.
MSStoppingPlace * getCurrentStop()
void parseAndBuildStoppingPlace(MSNet &net, const SUMOSAXAttributes &attrs, const SumoXMLTag element)
Parses the values and builds a stopping places for busses, trains or container vehicles.
void parseAndBeginParkingArea(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a parking area.
const std::string & getID() const
Returns the id.
Definition: Named.h:74
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
void clearParameter()
Clears the parameter map.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
void updateParameters(const std::map< std::string, std::string > &mapArg)
Adds or updates all given parameters from the map.
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:293
A list of positions.
void closePolygon()
ensures that the last position equals the first
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:236
virtual void myEndElement(int element)
Called when a closing tag occurs.
Encapsulated SAX-Attributes.
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.
const std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
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.
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
const std::vector< int > getOptIntVector(int attr, const char *objectid, bool &ok, bool report=true) const
convenience function to avoid the default argument and the template stuff at getOpt<>
virtual SumoXMLNodeType getNodeType(bool &ok) const =0
Returns the value of the named attribute.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
virtual SumoXMLEdgeFunc getEdgeFunc(bool &ok) const =0
Returns the value of the named attribute.
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
static StringBijection< PersonMode > PersonModeValues
person modes
static StringBijection< LinkState > LinkStates
link states
static StringBijection< LinkDirection > LinkDirections
link directions
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
return the junction id when given an edge of type internal, crossing or WalkingArea
virtual bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, const PositionVector &shape, bool geo, bool fill, double lineWidth, bool ignorePruning=false, const std::string &name=Shape::DEFAULT_NAME)
Builds a polygon using the given values and adds it to the container.
stop offset
T get(const std::string &str) const
std::vector< std::string > getVector()
return vector of strings
bool hasNext()
returns the information whether further substrings exist
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
edge type specific meso parameters
Definition: MESegment.h:55