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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
20 // The XML-Handler for network loading
21 /****************************************************************************/
22 // ===========================================================================
23 // included modules
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>
50 #include <utils/shapes/Shape.h>
52 
53 
54 // ===========================================================================
55 // method definitions
56 // ===========================================================================
57 NLHandler::NLHandler(const std::string& file, MSNet& net,
58  NLDetectorBuilder& detBuilder,
59  NLTriggerBuilder& triggerBuilder,
60  NLEdgeControlBuilder& edgeBuilder,
61  NLJunctionControlBuilder& junctionBuilder) :
62  MSRouteHandler(file, true),
63  myNet(net), myActionBuilder(net),
64  myCurrentIsInternalToSkip(false),
65  myDetectorBuilder(detBuilder), myTriggerBuilder(triggerBuilder),
66  myEdgeControlBuilder(edgeBuilder), myJunctionControlBuilder(junctionBuilder),
67  myAmParsingTLLogicOrJunction(false), myCurrentIsBroken(false),
68  myHaveWarnedAboutDeprecatedLanes(false),
69  myHaveSeenInternalEdge(false),
70  myHaveSeenNeighs(false),
71  myHaveSeenAdditionalSpeedRestrictions(false),
72  myLefthand(false),
73  myNetworkVersion(0),
74  myNetIsLoaded(false) {
75 }
76 
77 
79 
80 void
82  const SUMOSAXAttributes& attrs) {
83  try {
84  switch (element) {
85  case SUMO_TAG_NET: {
86  bool ok;
87  myLefthand = attrs.getOpt<bool>(SUMO_ATTR_LEFTHAND, nullptr, ok, false);
88  myNetworkVersion = attrs.get<double>(SUMO_ATTR_VERSION, nullptr, ok, false);
89  break;
90  }
91  case SUMO_TAG_EDGE:
92  beginEdgeParsing(attrs);
93  break;
94  case SUMO_TAG_LANE:
95  addLane(attrs);
96  break;
97  case SUMO_TAG_NEIGH:
99  myHaveSeenNeighs = true;
100  break;
101  case SUMO_TAG_JUNCTION:
102  openJunction(attrs);
103  initJunctionLogic(attrs);
104  break;
105  case SUMO_TAG_PHASE:
106  addPhase(attrs);
107  break;
108  case SUMO_TAG_CONNECTION:
109  addConnection(attrs);
110  break;
111  case SUMO_TAG_TLLOGIC:
112  initTrafficLightLogic(attrs);
113  break;
114  case SUMO_TAG_REQUEST:
115  addRequest(attrs);
116  break;
117  case SUMO_TAG_WAUT:
118  openWAUT(attrs);
119  break;
121  addWAUTSwitch(attrs);
122  break;
124  addWAUTJunction(attrs);
125  break;
126  case SUMO_TAG_E1DETECTOR:
128  addE1Detector(attrs);
129  break;
130  case SUMO_TAG_E2DETECTOR:
132  addE2Detector(attrs);
133  break;
134  case SUMO_TAG_E3DETECTOR:
136  beginE3Detector(attrs);
137  break;
138  case SUMO_TAG_DET_ENTRY:
139  addE3Entry(attrs);
140  break;
141  case SUMO_TAG_DET_EXIT:
142  addE3Exit(attrs);
143  break;
145  addInstantE1Detector(attrs);
146  break;
147  case SUMO_TAG_VSS:
149  break;
150  case SUMO_TAG_CALIBRATOR:
152  break;
153  case SUMO_TAG_REROUTER:
155  break;
156  case SUMO_TAG_BUS_STOP:
157  case SUMO_TAG_TRAIN_STOP:
160  break;
163  break;
166  break;
167  case SUMO_TAG_ACCESS:
169  break;
172  break;
173  case SUMO_TAG_VTYPEPROBE:
174  addVTypeProbeDetector(attrs);
175  break;
176  case SUMO_TAG_ROUTEPROBE:
177  addRouteProbeDetector(attrs);
178  break;
181  break;
184  break;
185  case SUMO_TAG_TIMEDEVENT:
187  break;
188  case SUMO_TAG_VAPORIZER:
190  break;
191  case SUMO_TAG_LOCATION:
192  setLocation(attrs);
193  break;
194  case SUMO_TAG_TAZ:
195  addDistrict(attrs);
196  break;
197  case SUMO_TAG_TAZSOURCE:
198  addDistrictEdge(attrs, true);
199  break;
200  case SUMO_TAG_TAZSINK:
201  addDistrictEdge(attrs, false);
202  break;
203  case SUMO_TAG_ROUNDABOUT:
204  addRoundabout(attrs);
205  break;
206  case SUMO_TAG_TYPE: {
207  bool ok = true;
208  myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
209  break;
210  }
211  case SUMO_TAG_RESTRICTION: {
212  bool ok = true;
213  const SUMOVehicleClass svc = getVehicleClassID(attrs.get<std::string>(SUMO_ATTR_VCLASS, myCurrentTypeID.c_str(), ok));
214  const double speed = attrs.get<double>(SUMO_ATTR_SPEED, myCurrentTypeID.c_str(), ok);
215  if (ok) {
216  myNet.addRestriction(myCurrentTypeID, svc, speed);
217  }
218  if (myNetIsLoaded) {
220  }
221  break;
222  }
223  case SUMO_TAG_STOPOFFSET: {
224  bool ok = true;
225  std::map<SVCPermissions, double> stopOffsets = parseStopOffsets(attrs, ok);
226  if (!ok) {
228  } else {
230  }
231  break;
232  }
233  default:
234  break;
235  }
236  } catch (InvalidArgument& e) {
237  WRITE_ERROR(e.what());
238  }
239  MSRouteHandler::myStartElement(element, attrs);
240  if (element == SUMO_TAG_PARAM && !myCurrentIsBroken) {
241  addParam(attrs);
242  }
243 }
244 
245 
246 void
248  switch (element) {
249  case SUMO_TAG_EDGE:
250  closeEdge();
251  break;
252  case SUMO_TAG_LANE:
255  myLastParameterised.pop_back();
256  }
257  break;
258  case SUMO_TAG_JUNCTION:
259  if (!myCurrentIsBroken) {
260  try {
263  } catch (InvalidArgument& e) {
264  WRITE_ERROR(e.what());
265  }
266  }
268  break;
269  case SUMO_TAG_TLLOGIC:
270  if (!myCurrentIsBroken) {
271  try {
273  } catch (InvalidArgument& e) {
274  WRITE_ERROR(e.what());
275  }
276  }
277  myAmParsingTLLogicOrJunction = false;
278  break;
279  case SUMO_TAG_WAUT:
280  closeWAUT();
281  break;
282  case SUMO_TAG_E3DETECTOR:
284  endE3Detector();
285  break;
288  break;
289  case SUMO_TAG_BUS_STOP:
290  case SUMO_TAG_TRAIN_STOP:
293  break;
294  case SUMO_TAG_NET:
295  // build junction graph
296  for (JunctionGraph::iterator it = myJunctionGraph.begin(); it != myJunctionGraph.end(); ++it) {
297  MSEdge* edge = MSEdge::dictionary(it->first);
298  MSJunction* from = myJunctionControlBuilder.retrieve(it->second.first);
299  MSJunction* to = myJunctionControlBuilder.retrieve(it->second.second);
300  if (from == nullptr) {
301  WRITE_ERROR("Unknown from-node '" + it->second.first + "' for edge '" + it->first + "'.");
302  return;
303  }
304  if (to == nullptr) {
305  WRITE_ERROR("Unknown to-node '" + it->second.second + "' for edge '" + it->first + "'.");
306  return;
307  }
308  if (edge != nullptr) {
309  edge->setJunctions(from, to);
310  from->addOutgoing(edge);
311  to->addIncoming(edge);
312  }
313  }
314  myNetIsLoaded = true;
315  break;
316  default:
317  break;
318  }
320 }
321 
322 
323 
324 // ---- the root/edge - element
325 void
327  bool ok = true;
328  myCurrentIsBroken = false;
329  // get the id, report an error if not given or empty...
330  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
331  if (!ok) {
332  myCurrentIsBroken = true;
333  return;
334  }
335  // omit internal edges if not wished
336  if (id[0] == ':') {
337  myHaveSeenInternalEdge = true;
340  return;
341  }
342  std::string junctionID = SUMOXMLDefinitions::getJunctionIDFromInternalEdge(id);
343  myJunctionGraph[id] = std::make_pair(junctionID, junctionID);
344  } else {
345  myJunctionGraph[id] = std::make_pair(
346  attrs.get<std::string>(SUMO_ATTR_FROM, id.c_str(), ok),
347  attrs.get<std::string>(SUMO_ATTR_TO, id.c_str(), ok));
348  if (!ok) {
349  myCurrentIsBroken = true;
350  return;
351  }
352  }
354  // parse the function
355  const SumoXMLEdgeFunc func = attrs.getEdgeFunc(ok);
356  if (!ok) {
357  WRITE_ERROR("Edge '" + id + "' has an invalid type.");
358  myCurrentIsBroken = true;
359  return;
360  }
361  // get the street name
362  const std::string streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
363  // get the edge type
364  const std::string edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
365  // get the edge priority (only for visualization)
366  const int priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1); // default taken from netbuild/NBFrame option 'default.priority'
367  // get the bidi-edge
368  const std::string bidi = attrs.getOpt<std::string>(SUMO_ATTR_BIDI, id.c_str(), ok, "");
369  if (!ok) {
370  myCurrentIsBroken = true;
371  return;
372  }
373  //
374  try {
375  myEdgeControlBuilder.beginEdgeParsing(id, func, streetName, edgeType, priority, bidi);
376  } catch (InvalidArgument& e) {
377  WRITE_ERROR(e.what());
378  myCurrentIsBroken = true;
379  }
380 
381  if (func == EDGEFUNC_CROSSING) {
382  //get the crossingEdges attribute (to implement the other side of the road pushbutton)
383  const std::string crossingEdges = attrs.getOpt<std::string>(SUMO_ATTR_CROSSING_EDGES, id.c_str(), ok, "");
384  if (!crossingEdges.empty()) {
385  std::vector<std::string> crossingEdgesVector;
386  StringTokenizer edges(crossingEdges);
387  while (edges.hasNext()) {
388  crossingEdgesVector.push_back(edges.next());
389  }
390  myEdgeControlBuilder.addCrossingEdges(crossingEdgesVector);
391  }
392  }
395 }
396 
397 
398 void
400  myLastParameterised.clear();
401  // omit internal edges if not wished and broken edges
403  return;
404  }
405  try {
407  MSEdge::dictionary(e->getID(), e);
409  } catch (InvalidArgument& e) {
410  WRITE_ERROR(e.what());
411  }
412 }
413 
414 
415 // ---- the root/edge/lanes/lane - element
416 void
418  // omit internal edges if not wished and broken edges
420  return;
421  }
422  bool ok = true;
423  // get the id, report an error if not given or empty...
424  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
425  if (!ok) {
426  myCurrentIsBroken = true;
427  return;
428  }
429  const double maxSpeed = attrs.get<double>(SUMO_ATTR_SPEED, id.c_str(), ok);
430  const double length = attrs.get<double>(SUMO_ATTR_LENGTH, id.c_str(), ok);
431  const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "", false);
432  const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
433  const double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, SUMO_const_laneWidth);
434  const PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
435  const int index = attrs.get<int>(SUMO_ATTR_INDEX, id.c_str(), ok);
436  const bool isRampAccel = attrs.getOpt<bool>(SUMO_ATTR_ACCELERATION, id.c_str(), ok, false);
437  if (shape.size() < 2) {
438  WRITE_ERROR("Shape of lane '" + id + "' is broken.\n Can not build according edge.");
439  myCurrentIsBroken = true;
440  return;
441  }
442  const SVCPermissions permissions = parseVehicleClasses(allow, disallow);
443  if (permissions != SVCAll) {
445  }
446  myCurrentIsBroken |= !ok;
447  if (!myCurrentIsBroken) {
448  try {
449  MSLane* lane = myEdgeControlBuilder.addLane(id, maxSpeed, length, shape, width, permissions, index, isRampAccel);
450  // insert the lane into the lane-dictionary, checking
451  if (!MSLane::dictionary(id, lane)) {
452  delete lane;
453  WRITE_ERROR("Another lane with the id '" + id + "' exists.");
454  myCurrentIsBroken = true;
455  myLastParameterised.push_back(nullptr);
456  } else {
457  myLastParameterised.push_back(lane);
458  }
459  } catch (InvalidArgument& e) {
460  WRITE_ERROR(e.what());
461  }
462  }
463 }
464 
465 
466 // ---- the root/junction - element
467 void
469  myCurrentIsBroken = false;
470  bool ok = true;
471  // get the id, report an error if not given or empty...
472  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
473  if (!ok) {
474  myCurrentIsBroken = true;
475  return;
476  }
477  PositionVector shape;
478  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
479  // inner junctions have no shape
480  shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok, PositionVector());
481  if (shape.size() > 2) {
482  shape.closePolygon();
483  }
484  }
485  double x = attrs.get<double>(SUMO_ATTR_X, id.c_str(), ok);
486  double y = attrs.get<double>(SUMO_ATTR_Y, id.c_str(), ok);
487  double z = attrs.getOpt<double>(SUMO_ATTR_Z, id.c_str(), ok, 0);
488  bool typeOK = true;
489  SumoXMLNodeType type = attrs.getNodeType(typeOK);
490  if (!typeOK) {
491  WRITE_ERROR("An unknown or invalid junction type occurred in junction '" + id + "'.");
492  ok = false;
493  }
494  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_KEY, id.c_str(), ok, "");
495  // incoming lanes
496  std::vector<MSLane*> incomingLanes;
497  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INCLANES, ""), incomingLanes, ok);
498  // internal lanes
499  std::vector<MSLane*> internalLanes;
501  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INTLANES, ""), internalLanes, ok);
502  }
503  if (!ok) {
504  myCurrentIsBroken = true;
505  } else {
506  try {
507  myJunctionControlBuilder.openJunction(id, key, type, Position(x, y, z), shape, incomingLanes, internalLanes);
508  } catch (InvalidArgument& e) {
509  WRITE_ERROR(e.what() + std::string("\n Can not build according junction."));
510  myCurrentIsBroken = true;
511  }
512  }
513 }
514 
515 
516 void
517 NLHandler::parseLanes(const std::string& junctionID,
518  const std::string& def, std::vector<MSLane*>& into, bool& ok) {
519  StringTokenizer st(def);
520  while (ok && st.hasNext()) {
521  std::string laneID = st.next();
522  MSLane* lane = MSLane::dictionary(laneID);
523  if (!MSGlobals::gUsingInternalLanes && laneID[0] == ':') {
524  continue;
525  }
526  if (lane == nullptr) {
527  WRITE_ERROR("An unknown lane ('" + laneID + "') was tried to be set as incoming to junction '" + junctionID + "'.");
528  ok = false;
529  continue;
530  }
531  into.push_back(lane);
532  }
533 }
534 // ----
535 
536 void
538  bool ok = true;
539  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
540  // circumventing empty string test
541  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
542  if (myLastParameterised.size() > 0 && myLastParameterised.back() != nullptr) {
543  myLastParameterised.back()->setParameter(key, val);
544  }
545  // set
546  if (ok && myAmParsingTLLogicOrJunction) {
547  assert(key != "");
548  assert(val != "");
550  }
551 }
552 
553 
554 void
556  myCurrentIsBroken = false;
557  bool ok = true;
558  // get the id, report an error if not given or empty...
559  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
560  if (!ok) {
561  myCurrentIsBroken = true;
562  return;
563  }
564  SUMOTime t = attrs.getOptSUMOTimeReporting(SUMO_ATTR_REF_TIME, id.c_str(), ok, 0);
565  std::string pro = attrs.get<std::string>(SUMO_ATTR_START_PROG, id.c_str(), ok);
566  if (!ok) {
567  myCurrentIsBroken = true;
568  }
569  if (!myCurrentIsBroken) {
570  myCurrentWAUTID = id;
571  try {
573  } catch (InvalidArgument& e) {
574  WRITE_ERROR(e.what());
575  myCurrentIsBroken = true;
576  }
577  }
578 }
579 
580 
581 void
583  bool ok = true;
585  std::string to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentWAUTID.c_str(), ok);
586  if (!ok) {
587  myCurrentIsBroken = true;
588  }
589  if (!myCurrentIsBroken) {
590  try {
592  } catch (InvalidArgument& e) {
593  WRITE_ERROR(e.what());
594  myCurrentIsBroken = true;
595  }
596  }
597 }
598 
599 
600 void
602  bool ok = true;
603  std::string wautID = attrs.get<std::string>(SUMO_ATTR_WAUT_ID, nullptr, ok);
604  std::string junctionID = attrs.get<std::string>(SUMO_ATTR_JUNCTION_ID, nullptr, ok);
605  std::string procedure = attrs.getOpt<std::string>(SUMO_ATTR_PROCEDURE, nullptr, ok, "");
606  bool synchron = attrs.getOpt<bool>(SUMO_ATTR_SYNCHRON, nullptr, ok, false);
607  if (!ok) {
608  myCurrentIsBroken = true;
609  }
610  try {
611  if (!myCurrentIsBroken) {
612  myJunctionControlBuilder.getTLLogicControlToUse().addWAUTJunction(wautID, junctionID, procedure, synchron);
613  }
614  } catch (InvalidArgument& e) {
615  WRITE_ERROR(e.what());
616  myCurrentIsBroken = true;
617  }
618 }
619 
620 
621 void
623  if (myCurrentIsBroken) {
624  return;
625  }
626  bool ok = true;
627  int request = attrs.get<int>(SUMO_ATTR_INDEX, nullptr, ok);
628  bool cont = false;
629  cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, nullptr, ok, false);
630  std::string response = attrs.get<std::string>(SUMO_ATTR_RESPONSE, nullptr, ok);
631  std::string foes = attrs.get<std::string>(SUMO_ATTR_FOES, nullptr, ok);
632  if (!ok) {
633  return;
634  }
635  // store received information
636  if (request >= 0 && response.length() > 0) {
637  try {
638  myJunctionControlBuilder.addLogicItem(request, response, foes, cont);
639  } catch (InvalidArgument& e) {
640  WRITE_ERROR(e.what());
641  }
642  }
643 }
644 
645 
646 void
648  if (myCurrentIsBroken) {
649  return;
650  }
652  bool ok = true;
653  // we either a have a junction or a legacy network with ROWLogic
654  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
655  if (ok) {
657  }
658 }
659 
660 
661 void
663  myCurrentIsBroken = false;
665  bool ok = true;
666  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
667  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
669  std::string typeS;
670  if (myJunctionControlBuilder.getTLLogicControlToUse().get(id, programID) == nullptr) {
671  // SUMO_ATTR_TYPE is not needed when only modifying the offset of an
672  // existing program
673  typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok);
674  if (!ok) {
675  myCurrentIsBroken = true;
676  return;
677  }
678  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
680  } else {
681  WRITE_ERROR("Traffic light '" + id + "' has unknown type '" + typeS + "'.");
682  }
683  }
684  //
685  const SUMOTime offset = attrs.getOptSUMOTimeReporting(SUMO_ATTR_OFFSET, id.c_str(), ok, 0);
686  if (!ok) {
687  myCurrentIsBroken = true;
688  return;
689  }
690  myJunctionControlBuilder.initTrafficLightLogic(id, programID, type, offset);
691 }
692 
693 
694 void
696  // try to get the phase definition
697  bool ok = true;
698  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, nullptr, ok);
699  if (!ok) {
700  return;
701  }
702  // try to get the phase duration
704  if (duration == 0) {
706  + " for tlLogic '" + myJunctionControlBuilder.getActiveKey()
707  + "' program '" + myJunctionControlBuilder.getActiveSubKey() + "' is zero.");
708  return;
709  }
710  // if the traffic light is an actuated traffic light, try to get
711  // the minimum and maximum durations
712  SUMOTime minDuration = attrs.getOptSUMOTimeReporting(
714  SUMOTime maxDuration = attrs.getOptSUMOTimeReporting(
716 
717 
718  int nextPhase = attrs.getOpt<int>(SUMO_ATTR_NEXT, nullptr, ok, -1);
719 
720  //SOTL attributes
721  //If the type attribute is not present, the parsed phase is of type "undefined" (MSPhaseDefinition constructor),
722  //in this way SOTL traffic light logic can recognize the phase as unsuitable or decides other
723  //behaviors. See SOTL traffic light logic implementations.
724  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
725  bool ok = true;
726  std::string phaseTypeString;
727  bool transient_notdecisional_bit;
728  bool commit_bit;
729  MSPhaseDefinition::LaneIdVector laneIdVector;
730  try {
731  phaseTypeString = attrs.get<std::string>(SUMO_ATTR_TYPE, "phase", ok, false);
732  } catch (EmptyData&) {
733  MsgHandler::getWarningInstance()->inform("Empty type definition. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
734  transient_notdecisional_bit = false;
735  }
736  if (phaseTypeString.find("decisional") != std::string::npos) {
737  transient_notdecisional_bit = false;
738  } else if (phaseTypeString.find("transient") != std::string::npos) {
739  transient_notdecisional_bit = true;
740  } else {
741  MsgHandler::getWarningInstance()->inform("SOTL_ATTL_TYPE_DECISIONAL nor SOTL_ATTL_TYPE_TRANSIENT. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
742  transient_notdecisional_bit = false;
743  }
744  commit_bit = (phaseTypeString.find("commit") != std::string::npos);
745 
746  if (phaseTypeString.find("target") != std::string::npos) {
747  std::string delimiter(" ,;");
748  //Phase declared as target, getting targetLanes attribute
749  try {
751  std::string targetLanesString = attrs.getStringSecure(SUMO_ATTR_TARGETLANE, "");
752  //TOKENIZING
753  MSPhaseDefinition::LaneIdVector targetLanesVector;
754  //Skip delimiters at the beginning
755  std::string::size_type firstPos = targetLanesString.find_first_not_of(delimiter, 0);
756  //Find first "non-delimiter".
757  std::string::size_type pos = targetLanesString.find_first_of(delimiter, firstPos);
758 
759  while (std::string::npos != pos || std::string::npos != firstPos) {
760  //Found a token, add it to the vector
761  targetLanesVector.push_back(targetLanesString.substr(firstPos, pos - firstPos));
762 
763  //Skip delimiters
764  firstPos = targetLanesString.find_first_not_of(delimiter, pos);
765 
766  //Find next "non-delimiter"
767  pos = targetLanesString.find_first_of(delimiter, firstPos);
768  }
769  //Adding the SOTL parsed phase to have a new MSPhaseDefinition that is SOTL compliant for target phases
770  myJunctionControlBuilder.addPhase(duration, state, nextPhase, minDuration, maxDuration, transient_notdecisional_bit, commit_bit, targetLanesVector);
771  } catch (EmptyData&) {
772  MsgHandler::getErrorInstance()->inform("Missing targetLane definition for the target phase.");
773  return;
774  }
775  } else {
776  //Adding the SOTL parsed phase to have a new MSPhaseDefinition that is SOTL compliant for non target phases
777  myJunctionControlBuilder.addPhase(duration, state, nextPhase, minDuration, maxDuration, transient_notdecisional_bit, commit_bit);
778  }
779  } else {
780  //Adding the standard parsed phase to have a new MSPhaseDefinition
781 
782  myJunctionControlBuilder.addPhase(duration, state, nextPhase, minDuration, maxDuration);
783  }
784 }
785 
786 
787 void
789  bool ok = true;
790  // get the id, report an error if not given or empty...
791  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
792  if (!ok) {
793  return;
794  }
795  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
796  const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), ok);
797  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
798  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
799  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
800  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
801  if (!ok) {
802  return;
803  }
804  try {
805  myDetectorBuilder.buildInductLoop(id, lane, position, frequency,
807  friendlyPos, vTypes);
808  } catch (InvalidArgument& e) {
809  WRITE_ERROR(e.what());
810  } catch (IOError& e) {
811  WRITE_ERROR(e.what());
812  }
813 }
814 
815 
816 void
818  bool ok = true;
819  // get the id, report an error if not given or empty...
820  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
821  if (!ok) {
822  return;
823  }
824  const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), ok);
825  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
826  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
827  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
828  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
829  if (!ok) {
830  return;
831  }
832  try {
833  myDetectorBuilder.buildInstantInductLoop(id, lane, position, FileHelpers::checkForRelativity(file, getFileName()), friendlyPos, vTypes);
834  } catch (InvalidArgument& e) {
835  WRITE_ERROR(e.what());
836  } catch (IOError& e) {
837  WRITE_ERROR(e.what());
838  }
839 }
840 
841 
842 void
844  WRITE_WARNING("VTypeProbes are deprecated. Use fcd-output devices (assigned to the vType) instead.");
845  bool ok = true;
846  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
847  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
848  std::string type = attrs.getStringSecure(SUMO_ATTR_TYPE, "");
849  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
850  if (!ok) {
851  return;
852  }
853  try {
855  } catch (InvalidArgument& e) {
856  WRITE_ERROR(e.what());
857  } catch (IOError& e) {
858  WRITE_ERROR(e.what());
859  }
860 }
861 
862 
863 void
865  bool ok = true;
866  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
867  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
868  SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, -1);
869  std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
870  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
871  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
872  if (!ok) {
873  return;
874  }
875  try {
876  myDetectorBuilder.buildRouteProbe(id, edge, frequency, begin,
878  } catch (InvalidArgument& e) {
879  WRITE_ERROR(e.what());
880  } catch (IOError& e) {
881  WRITE_ERROR(e.what());
882  }
883 }
884 
885 
886 
887 void
889 
890  // check whether this is a detector connected to a tls and optionally to a link
891  bool ok = true;
892  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
893  const std::string lsaid = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), ok, "");
894  const std::string toLane = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "");
895  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
896  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
897  const double jamDistThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, 10.0f);
898  double position = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), ok, std::numeric_limits<double>::max());
899  const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), ok, std::numeric_limits<double>::max());
900  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
901  const bool showDetector = attrs.getOpt<bool>(SUMO_ATTR_SHOW_DETECTOR, id.c_str(), ok, true);
902  const std::string contStr = attrs.getOpt<std::string>(SUMO_ATTR_CONT, id.c_str(), ok, "");
903  if (contStr != "") {
904  WRITE_WARNING("Ignoring deprecated argument 'cont' for E2 detector '" + id + "'");
905  }
906  std::string lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, "");
907  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
908  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
909 
910  double endPosition = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, std::numeric_limits<double>::max());
911  const std::string lanes = attrs.getOpt<std::string>(SUMO_ATTR_LANES, id.c_str(), ok, ""); // lanes has priority to lane
912  if (!ok) {
913  return;
914  }
915 
916  bool lanesGiven = lanes != "";
917  bool laneGiven = lane != "";
918  if (!(lanesGiven || laneGiven)) {
919  // in absence of any lane-specification assume specification by id
920  WRITE_WARNING("Trying to specify detector's lane by the given id since the argument 'lane' is missing.")
921  lane = id;
922  laneGiven = true;
923  }
924  bool lengthGiven = length != std::numeric_limits<double>::max();
925  bool posGiven = position != std::numeric_limits<double>::max();
926  bool endPosGiven = endPosition != std::numeric_limits<double>::max();
927  bool lsaGiven = lsaid != "";
928  bool toLaneGiven = toLane != "";
929 
930  MSLane* clane = nullptr;
931  std::vector<MSLane*> clanes;
932  if (lanesGiven) {
933  // If lanes is given, endPos and startPos are required. lane, and length are ignored
934  std::string seps = " ,\t\n";
935  StringTokenizer st = StringTokenizer(lanes, seps, true);
936 // std::cout << "Parsing lanes..." << std::endl;
937  while (st.hasNext()) {
938  std::string nextLaneID = st.next();
939 // std::cout << "Next: " << nextLaneID << std::endl;
940  if (nextLaneID.find_first_of(seps) != nextLaneID.npos) {
941  continue;
942  }
943  clane = myDetectorBuilder.getLaneChecking(nextLaneID, SUMO_TAG_E2DETECTOR, id);
944  clanes.push_back(clane);
945  }
946  if (clanes.size() == 0) {
947  throw InvalidArgument("Malformed argument 'lanes' for E2Detector '" + id + "'.\nSpecify 'lanes' as a sequence of lane-IDs seperated by whitespace or comma (',')");
948  }
949  if (laneGiven) {
950  WRITE_WARNING("Ignoring argument 'lane' for E2Detector '" + id + "' since argument 'lanes' was given.\n"
951  "Usage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]");
952  }
953  if (lengthGiven) {
954  WRITE_WARNING("Ignoring argument 'length' for E2Detector '" + id + "' since argument 'lanes' was given.\n"
955  "Usage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]");
956  }
957  if (!posGiven) {
958  // assuming start pos == lane start
959  position = 0;
960  WRITE_WARNING("Missing argument 'pos' for E2Detector '" + id + "'. Assuming detector start == lane start of lane '" + clanes[0]->getID() + "'.");
961  }
962  if (!endPosGiven) {
963  // assuming end pos == lane end
964  endPosition = clanes[clanes.size() - 1]->getLength();
965  WRITE_WARNING("Missing argument 'endPos' for E2Detector '" + id + "'. Assuming detector end == lane end of lane '" + clanes[clanes.size() - 1]->getID() + "'.");
966  }
967 
968  } else {
969  if (!laneGiven) {
970  std::stringstream ss;
971  ss << "Missing argument 'lane' for E2Detector '" << id << "'."
972  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
973  throw InvalidArgument(ss.str());
974  }
976 
977  if (posGiven) {
978  // start pos is given
979  if (endPosGiven && lengthGiven) {
980  std::stringstream ss;
981  ss << "Ignoring argument 'endPos' for E2Detector '" << id << "' since argument 'pos' was given."
982  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
983  WRITE_WARNING(ss.str());
984  endPosition = std::numeric_limits<double>::max();
985  }
986  if (!lengthGiven && !endPosGiven) {
987  std::stringstream ss;
988  ss << "Missing arguments 'length'/'endPos' for E2Detector '" << id << "'. Assuming detector end == lane end of lane '" << lane << "'.";
989  WRITE_WARNING(ss.str());
990  endPosition = clane->getLength();
991  }
992  } else if (endPosGiven) {
993  // endPos is given, pos is not given
994  if (!lengthGiven) {
995  std::stringstream ss;
996  ss << "Missing arguments 'length'/'pos' for E2Detector '" << id << "'. Assuming detector start == lane start of lane '" << lane << "'.";
997  WRITE_WARNING(ss.str());
998  }
999  } else {
1000  std::stringstream ss;
1001  if (lengthGiven && fabs(length - clane->getLength()) > NUMERICAL_EPS) {
1002  ss << "Incomplete positional specification for E2Detector '" << id << "'."
1003  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
1004  throw InvalidArgument(ss.str());
1005  }
1006  endPosition = clane->getLength();
1007  position = 0;
1008  ss << "Missing arguments 'pos'/'endPos' for E2Detector '" << id << "'. Assuming that the detector covers the whole lane '" << lane << "'.";
1009  WRITE_WARNING(ss.str());
1010  }
1011  }
1012 
1013  // Frequency
1014 
1015  SUMOTime frequency;
1016  if (!lsaGiven) {
1017  frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
1018  if (!ok) {
1019  return;
1020  }
1021  } else {
1022  frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, false);
1023  }
1024 
1025  // TLS
1026  MSTLLogicControl::TLSLogicVariants* tlls = nullptr;
1027  if (lsaGiven) {
1028  tlls = &myJunctionControlBuilder.getTLLogic(lsaid);
1029  if (tlls->getActive() == nullptr) {
1030  throw InvalidArgument("The detector '" + id + "' refers to an unknown lsa '" + lsaid + "'.");
1031  }
1032  if (frequency != -1) {
1033  WRITE_WARNING("Ignoring argument 'frequency' for E2Detector '" + id + "' since argument 'tl' was given.");
1034  frequency = -1;
1035  }
1036  }
1037 
1038  // Link
1039  MSLane* cToLane = nullptr;
1040  if (toLaneGiven) {
1041  cToLane = myDetectorBuilder.getLaneChecking(toLane, SUMO_TAG_E2DETECTOR, id);
1042  }
1043 
1044  // File
1045  std::string filename;
1046  try {
1047  filename = FileHelpers::checkForRelativity(file, getFileName());
1048  } catch (IOError& e) {
1049  WRITE_ERROR(e.what());
1050  }
1051 
1052  // Build detector
1053  if (lanesGiven) {
1054  // specification by a lane sequence
1055  myDetectorBuilder.buildE2Detector(id, clanes, position, endPosition, filename, frequency,
1056  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
1057  vTypes, friendlyPos, showDetector,
1058  tlls, cToLane);
1059  } else {
1060  // specification by start or end lane
1061  myDetectorBuilder.buildE2Detector(id, clane, position, endPosition, length, filename, frequency,
1062  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
1063  vTypes, friendlyPos, showDetector,
1064  tlls, cToLane);
1065  }
1066 
1067 }
1068 
1069 
1070 void
1072  bool ok = true;
1073  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
1074  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
1075  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
1076  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
1077  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
1078  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
1079  const bool openEntry = attrs.getOpt<bool>(SUMO_ATTR_OPEN_ENTRY, id.c_str(), ok, false);
1080  if (!ok) {
1081  return;
1082  }
1083  try {
1086  frequency, haltingSpeedThreshold, haltingTimeThreshold, vTypes, openEntry);
1087  } catch (InvalidArgument& e) {
1088  WRITE_ERROR(e.what());
1089  } catch (IOError& e) {
1090  WRITE_ERROR(e.what());
1091  }
1092 }
1093 
1094 
1095 void
1097  bool ok = true;
1098  const double position = attrs.get<double>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1099  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
1100  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1101  if (!ok) {
1102  return;
1103  }
1104  myDetectorBuilder.addE3Entry(lane, position, friendlyPos);
1105 }
1106 
1107 
1108 void
1110  bool ok = true;
1111  const double position = attrs.get<double>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1112  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
1113  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1114  if (!ok) {
1115  return;
1116  }
1117  myDetectorBuilder.addE3Exit(lane, position, friendlyPos);
1118 }
1119 
1120 
1121 void
1122 NLHandler::addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype) {
1123  bool ok = true;
1124  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
1125  const double maxTravelTime = attrs.getOpt<double>(SUMO_ATTR_MAX_TRAVELTIME, id.c_str(), ok, 100000);
1126  const double minSamples = attrs.getOpt<double>(SUMO_ATTR_MIN_SAMPLES, id.c_str(), ok, 0);
1127  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, POSITION_EPS);
1128  const std::string excludeEmpty = attrs.getOpt<std::string>(SUMO_ATTR_EXCLUDE_EMPTY, id.c_str(), ok, "false");
1129  const bool withInternal = attrs.getOpt<bool>(SUMO_ATTR_WITH_INTERNAL, id.c_str(), ok, false);
1130  const bool trackVehicles = attrs.getOpt<bool>(SUMO_ATTR_TRACK_VEHICLES, id.c_str(), ok, false);
1131  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
1132  const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "performance");
1133  std::string vtypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
1134  const SUMOTime frequency = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, -1);
1135  const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("begin")));
1136  const SUMOTime end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("end")));
1137  if (!ok) {
1138  return;
1139  }
1140  try {
1141  myDetectorBuilder.createEdgeLaneMeanData(id, frequency, begin, end,
1142  type, objecttype == SUMO_TAG_MEANDATA_LANE,
1143  // equivalent to TplConvert::_2bool used in SUMOSAXAttributes::getBool
1144  excludeEmpty[0] != 't' && excludeEmpty[0] != 'T' && excludeEmpty[0] != '1' && excludeEmpty[0] != 'x',
1145  excludeEmpty == "defaults", withInternal, trackVehicles,
1146  maxTravelTime, minSamples, haltingSpeedThreshold, vtypes,
1148  } catch (InvalidArgument& e) {
1149  WRITE_ERROR(e.what());
1150  } catch (IOError& e) {
1151  WRITE_ERROR(e.what());
1152  }
1153 }
1154 
1155 
1156 void
1158  bool ok = true;
1159  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, nullptr, ok);
1160  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
1161  if (!MSGlobals::gUsingInternalLanes && (fromID[0] == ':' || toID[0] == ':')) {
1162  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, nullptr, ok, "");
1163  if (tlID != "") {
1164  int tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok);
1166  }
1167  return;
1168  }
1169 
1170  MSLink* link = nullptr;
1171  try {
1172  bool ok = true;
1173  const int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, nullptr, ok);
1174  const double foeVisibilityDistance = attrs.getOpt<double>(SUMO_ATTR_VISIBILITY_DISTANCE, nullptr, ok, 4.5);
1175  const int toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, nullptr, ok);
1176  LinkDirection dir = parseLinkDir(attrs.get<std::string>(SUMO_ATTR_DIR, nullptr, ok));
1177  LinkState state = parseLinkState(attrs.get<std::string>(SUMO_ATTR_STATE, nullptr, ok));
1178  bool keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, nullptr, ok, true);
1179  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, nullptr, ok, "");
1180  std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, nullptr, ok, "");
1181 
1182  MSEdge* from = MSEdge::dictionary(fromID);
1183  if (from == nullptr) {
1184  WRITE_ERROR("Unknown from-edge '" + fromID + "' in connection.");
1185  return;
1186  }
1187  MSEdge* to = MSEdge::dictionary(toID);
1188  if (to == nullptr) {
1189  WRITE_ERROR("Unknown to-edge '" + toID + "' in connection.");
1190  return;
1191  }
1192  if (fromLaneIdx < 0 || fromLaneIdx >= (int)from->getLanes().size() ||
1193  toLaneIdx < 0 || toLaneIdx >= (int)to->getLanes().size()) {
1194  WRITE_ERROR("Invalid lane index in connection from '" + from->getID() + "' to '" + to->getID() + "'.");
1195  return;
1196  }
1197  MSLane* fromLane = from->getLanes()[fromLaneIdx];
1198  MSLane* toLane = to->getLanes()[toLaneIdx];
1199  assert(fromLane);
1200  assert(toLane);
1201 
1202  MSTrafficLightLogic* logic = nullptr;
1203  int tlLinkIdx = -1;
1204  if (tlID != "") {
1205  tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, nullptr, ok);
1206  // make sure that the index is in range
1208  if ((tlLinkIdx < 0 || tlLinkIdx >= (int)logic->getCurrentPhaseDef().getState().size())
1209  && logic->getLogicType() != TLTYPE_RAIL_SIGNAL
1210  && logic->getLogicType() != TLTYPE_RAIL_CROSSING) {
1211  WRITE_ERROR("Invalid " + toString(SUMO_ATTR_TLLINKINDEX) + " '" + toString(tlLinkIdx) +
1212  "' in connection controlled by '" + tlID + "'");
1213  return;
1214  }
1215  if (!ok) {
1216  return;
1217  }
1218  }
1219  double length;
1220  // build the link
1221  MSLane* via = nullptr;
1222  if (viaID != "" && MSGlobals::gUsingInternalLanes) {
1223  via = MSLane::dictionary(viaID);
1224  if (via == nullptr) {
1225  WRITE_ERROR("An unknown lane ('" + viaID +
1226  "') should be set as a via-lane for lane '" + toLane->getID() + "'.");
1227  return;
1228  }
1229  length = via->getLength();
1230  } else {
1231  length = fromLane->getShape()[-1].distanceTo(toLane->getShape()[0]);
1232  }
1233  link = new MSLink(fromLane, toLane, via, dir, state, length, foeVisibilityDistance, keepClear, logic, tlLinkIdx);
1234  if (via != nullptr) {
1235  via->addIncomingLane(fromLane, link);
1236  } else {
1237  toLane->addIncomingLane(fromLane, link);
1238  }
1239  toLane->addApproachingLane(fromLane, myNetworkVersion < 0.25);
1240 
1241  // if a traffic light is responsible for it, inform the traffic light
1242  // check whether this link is controlled by a traffic light
1243  // we can not reuse logic here because it might be an inactive one
1244  if (tlID != "") {
1245  myJunctionControlBuilder.getTLLogic(tlID).addLink(link, fromLane, tlLinkIdx);
1246  }
1247  // add the link
1248  fromLane->addLink(link);
1249 
1250  } catch (InvalidArgument& e) {
1251  WRITE_ERROR(e.what());
1252  }
1253 }
1254 
1255 
1257 NLHandler::parseLinkDir(const std::string& dir) {
1258  if (SUMOXMLDefinitions::LinkDirections.hasString(dir)) {
1260  } else {
1261  throw InvalidArgument("Unrecognised link direction '" + dir + "'.");
1262  }
1263 }
1264 
1265 
1266 LinkState
1267 NLHandler::parseLinkState(const std::string& state) {
1268  if (SUMOXMLDefinitions::LinkStates.hasString(state)) {
1269  return SUMOXMLDefinitions::LinkStates.get(state);
1270  } else {
1271  if (state == "t") { // legacy networks
1272  // WRITE_WARNING("Obsolete link state 't'. Use 'o' instead");
1274  } else {
1275  throw InvalidArgument("Unrecognised link state '" + state + "'.");
1276  }
1277  }
1278 }
1279 
1280 
1281 // ----------------------------------
1282 void
1284  if (myNetIsLoaded) {
1285  //WRITE_WARNING("POIs and Polygons should be loaded using option --po-files")
1286  return;
1287  }
1288  bool ok = true;
1289  PositionVector s = attrs.get<PositionVector>(SUMO_ATTR_NET_OFFSET, nullptr, ok);
1290  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, nullptr, ok);
1291  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, nullptr, ok);
1292  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, nullptr, ok);
1293  if (ok) {
1294  Position networkOffset = s[0];
1295  GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
1296  if (OptionsCont::getOptions().getBool("fcd-output.geo") && !GeoConvHelper::getFinal().usingGeoProjection()) {
1297  WRITE_WARNING("no valid geo projection loaded from network. fcd-output.geo will not work");
1298  }
1299  }
1300 }
1301 
1302 
1303 void
1305  bool ok = true;
1306  myCurrentIsBroken = false;
1307  // get the id, report an error if not given or empty...
1308  myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
1309  if (!ok) {
1310  myCurrentIsBroken = true;
1311  return;
1312  }
1313  try {
1315  if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) {
1316  delete sink;
1317  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists.");
1318  }
1319  sink->initialize(new std::vector<MSLane*>());
1320  MSEdge* source = myEdgeControlBuilder.buildEdge(myCurrentDistrictID + "-source", EDGEFUNC_CONNECTOR, "", "", -1);
1321  if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) {
1322  delete source;
1323  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists.");
1324  }
1325  source->initialize(new std::vector<MSLane*>());
1326  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1327  std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES);
1328  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
1329  MSEdge* edge = MSEdge::dictionary(*i);
1330  // check whether the edge exists
1331  if (edge == nullptr) {
1332  throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known.");
1333  }
1334  source->addSuccessor(edge);
1335  edge->addSuccessor(sink);
1336  }
1337  }
1338  RGBColor color = attrs.getOpt<RGBColor>(SUMO_ATTR_COLOR, myCurrentDistrictID.c_str(), ok, RGBColor::parseColor("1.0,.33,.33"));
1339  source->setParameter("tazColor", toString(color));
1340  sink->setParameter("tazColor", toString(color));
1341 
1342  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
1344  if (shape.size() != 0) {
1345  if (!myNet.getShapeContainer().addPolygon(myCurrentDistrictID, "taz", color, 0, 0, "", false, shape, false, false, 1.0)) {
1346  WRITE_WARNING("Skipping visualization of taz '" + myCurrentDistrictID + "', polygon already exists.");
1347  }
1348  }
1349  }
1350  } catch (InvalidArgument& e) {
1351  WRITE_ERROR(e.what());
1352  myCurrentIsBroken = true;
1353  }
1354 }
1355 
1356 
1357 void
1358 NLHandler::addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource) {
1359  if (myCurrentIsBroken) {
1360  // earlier error
1361  return;
1362  }
1363  bool ok = true;
1364  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentDistrictID.c_str(), ok);
1365  MSEdge* succ = MSEdge::dictionary(id);
1366  if (succ != nullptr) {
1367  // connect edge
1368  if (isSource) {
1369  MSEdge::dictionary(myCurrentDistrictID + "-source")->addSuccessor(succ);
1370  } else {
1371  succ->addSuccessor(MSEdge::dictionary(myCurrentDistrictID + "-sink"));
1372  }
1373  } else {
1374  WRITE_ERROR("At district '" + myCurrentDistrictID + "': succeeding edge '" + id + "' does not exist.");
1375  }
1376 }
1377 
1378 
1379 void
1381  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1382  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
1383  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
1384  MSEdge* edge = MSEdge::dictionary(*it);
1385  if (edge == nullptr) {
1386  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
1387  } else {
1388  edge->markAsRoundabout();
1389  }
1390  }
1391  } else {
1392  WRITE_ERROR("Empty edges in roundabout.");
1393  }
1394 }
1395 
1396 
1397 // ----------------------------------
1398 void
1400  try {
1402  } catch (InvalidArgument& e) {
1403  WRITE_ERROR(e.what());
1404  }
1405 }
1406 
1407 
1408 void
1410  if (!myCurrentIsBroken) {
1411  try {
1413  } catch (InvalidArgument& e) {
1414  WRITE_ERROR(e.what());
1415  myCurrentIsBroken = true;
1416  }
1417  }
1418  myCurrentWAUTID = "";
1419 }
1420 
1421 
1422 Position
1423 NLShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat) {
1424  MSLane* lane = MSLane::dictionary(laneID);
1425  if (lane == nullptr) {
1426  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1427  return Position::INVALID;
1428  }
1429  if (lanePos < 0) {
1430  lanePos = lane->getLength() + lanePos;
1431  }
1432  if (lanePos < 0 || lanePos > lane->getLength()) {
1433  WRITE_WARNING("lane position " + toString(lanePos) + " for poi '" + poiID + "' is not valid.");
1434  }
1435  return lane->geometryPositionAtOffset(lanePos, -lanePosLat);
1436 }
1437 /****************************************************************************/
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
void parseAndAddLotEntry(const SUMOSAXAttributes &attrs)
Parses his values and adds a lot entry to current parking area.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:67
void parseAndBuildCalibrator(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a mesoscopic or microscopic calibrator.
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:1071
void initTrafficLightLogic(const std::string &id, const std::string &programID, TrafficLightType type, SUMOTime offset)
Begins the reading of a traffic lights logic.
SumoXMLTag
Numbers representing SUMO-XML - element names.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:76
void addWAUTJunction(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:601
Builds detectors for microsim.
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:888
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:177
a routeprobe detector
long long int SUMOTime
Definition: SUMOTime.h:36
alternative tag for e1 detector
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:297
Whether vehicles must keep the junction clear.
a source within a district (connection road)
void addAccess(MSNet &net, const SUMOSAXAttributes &attrs)
Parses the values and adds an access point to the currently parsed stopping place.
Storage for all programs of a single tls.
std::string next()
void 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.
MSLane * getLaneChecking(const std::string &laneID, SumoXMLTag type, const std::string &detid)
Returns the named lane.
root element of a network file
begin/end of the description of a junction
virtual MSEdge * closeEdge()
Closes the building of an edge; The edge is completely described by now and may not be opened again...
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 double maxTravelTime, const double minSamples, const double haltSpeed, const std::string &vTypes, const std::string &device)
Creates edge based mean data collector using the given specification.
begin/end of the description of a single lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:555
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:966
bool myCurrentIsBroken
Definition: NLHandler.h:330
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:118
A calibrator placed over edge.
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)
Begins the processing of the named junction.
a traffic assignment zone
connectio between two lanes
The base class for an intersection.
Definition: MSJunction.h:61
void addE3Entry(const std::string &lane, double pos, bool friendlyPos)
Builds an entry point of an e3 detector.
const double SUMO_const_laneWidth
Definition: StdDefs.h:51
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
return the junction id when given an edge of type internal, crossing or WalkingArea ...
const std::string & getFileName() const
returns the current file name
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:216
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:843
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1380
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:301
void parseAndBuildChargingStation(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a charging station.
foe visibility distance of a link
void parseAndBuildRerouter(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a rerouter.
void closeJunctionLogic()
Ends the building of a junction logic (row-logic)
weights: time range begin
link,node: the traffic light id responsible for this link
void addStopOffsets(const std::map< SVCPermissions, double > &stopOffsets)
process a stopOffset element (originates either from the active edge or lane).
std::map< SVCPermissions, double > parseStopOffsets(const SUMOSAXAttributes &attrs, bool &ok)
Extract stopOffsets from attributes of stopOffset element.
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:2069
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:162
void addPhase(SUMOTime duration, const std::string &state, int nextPhase, SUMOTime min, SUMOTime max)
Adds a phase to the currently built traffic lights logic.
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.
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:514
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:456
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:788
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:788
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:57
void initialize(const std::vector< MSLane *> *lanes)
Initialize the edge.
Definition: MSEdge.cpp:105
void addLink(MSLink *link, MSLane *lane, int pos)
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Definition: NLHandler.cpp:326
maximum duration of a phase
const std::string & getID() const
Returns the id.
Definition: Named.h:78
#define TIME2STEPS(x)
Definition: SUMOTime.h:60
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)
Builds a polygon using the given values and adds it to the container.
const std::string & getActiveSubKey() const
Returns the active sub key.
virtual MSEdge * buildEdge(const std::string &id, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, const int priority)
Builds an edge instance (MSEdge in this case)
static StringBijection< LinkState > LinkStates
link states
const SVCPermissions SVCAll
all VClasses are allowed
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:313
begin/end of the description of an edge restriction
A parking space for a single vehicle within a parking area.
void closeWAUT(const std::string &wautid)
Closes loading of a WAUT.
void parseAndBeginParkingArea(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a parking area.
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.
virtual void endE3Detector()
Builds of an e3 detector using collected values.
Definition: NLHandler.cpp:1399
void endE3Detector()
Builds of an e3 detector using collected values.
bool myAmParsingTLLogicOrJunction
internal information whether a tls-logic is currently read
Definition: NLHandler.h:316
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
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.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:241
The simulated network and simulation perfomer.
Definition: MSNet.h:84
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
int getNumberOfLoadedPhases() const
return the number of phases loaded so far (for error reporting)
an e3 entry point
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane *> &into, bool &ok)
Definition: NLHandler.cpp:517
void closeJunction(const std::string &basePath)
Closes (ends) the processing of the current junction.
MSTLLogicControl::TLSLogicVariants & getTLLogic(const std::string &id) const
Returns a previously build tls logic.
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
bool myHaveSeenAdditionalSpeedRestrictions
whether additional files contained type-specific speed limits
Definition: NLHandler.h:344
void closeWAUT()
Definition: NLHandler.cpp:1409
void addE3Exit(const std::string &lane, double pos, bool friendlyPos)
Builds an exit point of an e3 detector.
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:537
an edge based mean data detector
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1304
The state of a link.
static StringBijection< LinkDirection > LinkDirections
link directions
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:2079
A road/street connecting two junctions.
Definition: MSEdge.h:75
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1283
void beginEdgeParsing(const std::string &id, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, int priority, const std::string &bidi)
Begins building of an MSEdge.
The definition of a periodic event.
virtual void openJunction(const SUMOSAXAttributes &attrs)
opens a junction for processing
Definition: NLHandler.cpp:468
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:307
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
void updateParameter(const std::map< std::string, std::string > &mapArg)
Adds or updates all given parameters from the map.
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:1096
Encapsulated SAX-Attributes.
An instantenous induction loop.
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:1109
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
Builder of microsim-junctions and tls.
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:439
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
virtual void endParkingArea()
End a parking area.
parameter associated to a certain key
an e3 exit point
A list of positions.
virtual void closeTrafficLightLogic(const std::string &basePath)
Ends the building of a traffic lights logic.
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:582
JunctionGraph myJunctionGraph
Definition: NLHandler.h:357
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:622
void setPermissionsFound()
Labels the network to contain vehicle class permissions.
Definition: MSNet.h:183
T get(const std::string &str) const
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, double lanePosLat)
get position for a given laneID
Definition: NLHandler.cpp:1423
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:1157
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:322
void parseAndBuildLaneSpeedTrigger(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a lane speed trigger.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
void addAction(const SUMOSAXAttributes &attrs, const std::string &basePath)
Builds an action and saves it for further use.
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:42
roundabout defined in junction
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:81
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition: MSNet.cpp:296
void parseAndBuildStoppingPlace(MSNet &net, const SUMOSAXAttributes &attrs, const SumoXMLTag element)
Parses the values and builds a stopping places for busses, trains or container vehicles.
MSJunction * retrieve(const std::string id)
try to retrieve junction by id
std::string reportCurrentEdgeOrLane() const
Return info about currently processed edge or lane.
#define POSITION_EPS
Definition: config.h:172
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
edge: the shape in xml-definition
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:338
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1257
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:69
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
void addParam(const std::string &key, const std::string &value)
Adds a parameter.
begin/end of the description of a neighboring lane
std::string getCurrentE3ID() const
Returns the id of the currently built e3 detector.
virtual SumoXMLNodeType getNodeType(bool &ok) const =0
Returns the value of the named attribute.
void buildInductLoop(const std::string &id, const std::string &lane, double pos, SUMOTime splInterval, const std::string &device, bool friendlyPos, const std::string &vTypes)
Builds an e1 detector and adds it to the net.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
virtual void addNeigh(const std::string id)
Adds a neighbor to the current lane.
void addOutgoing(MSEdge *edge)
Definition: MSJunction.h:122
description of a logic request within the junction
MSTLLogicControl & getTLLogicControlToUse() const
Returns the used tls control.
begin/end of the description of an edge
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.
succesor phase index
virtual std::vector< std::string > getStringVector(int attr) const =0
Tries to read given attribute assuming it is a string vector.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:247
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:319
virtual void myEndElement(int element)
Called when a closing tag occurs.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1730
a lane based mean data detector
trigger: the time of the step
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:817
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
std::vector< std::string > LaneIdVector
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:399
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:864
virtual void endStoppingPlace()
End a stopping place.
A train stop (alias for bus stop)
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:417
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:341
void closeLane()
Closes the building of a lane; The edge is completely described by now and may not be opened again...
a sink within a district (connection road)
the edges crossed by a pedestrian crossing
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:78
void beginE3Detector(const std::string &id, const std::string &device, SUMOTime splInterval, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Stores temporary the initial information about an e3 detector to build.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:304
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:350
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
The link is controlled by a tls which is off and blinks, has to brake.
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...
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:353
void addWAUT(SUMOTime refTime, const std::string &id, const std::string &startProg)
Adds a WAUT definition.
std::vector< Parameterised * > myLastParameterised
Definition: NLHandler.h:335
weights: time range end
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.
a vtypeprobe detector
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:113
virtual MSLane * addLane(const std::string &id, double maxSpeed, double length, const PositionVector &shape, double width, SVCPermissions permissions, int index, bool isRampAccel)
Adds a lane to the current edge.
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
void addPhase(const SUMOSAXAttributes &attrs)
adds a phase to the traffic lights logic currently build
Definition: NLHandler.cpp:695
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:478
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1358
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:210
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
vaporizer of vehicles
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
Definition: NLHandler.cpp:1267
The abstract direction of a link.
void setJunctions(MSJunction *from, MSJunction *to)
Definition: MSEdge.cpp:1060
void 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, bool friendlyPos, bool showDetector, MSTLLogicControl::TLSLogicVariants *tlls=0, MSLane *toLane=0)
Builds a new E2 detector and adds it to the net&#39;s detector control. Also performs some consistency ch...
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
The parent class for traffic light logics.
A variable speed sign.
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:294
void addWAUTSwitch(const std::string &wautid, SUMOTime when, const std::string &to)
Adds a WAUT switch step to a previously built WAUT.
link: the index of the link within the traffic light
#define NUMERICAL_EPS
Definition: config.h:148
Parameterised myLastEdgeParameters
Definition: NLHandler.h:334
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
virtual void addCrossingEdges(const std::vector< std::string > &)
add the crossingEdges in a crossing edge if present
a traffic light logic
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: NLHandler.cpp:247
MSTrafficLightLogic * getActive() const
void markAsRoundabout()
Definition: MSEdge.h:623
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:1122
Builds trigger objects for microsim.
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:647
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:347
An access point for a train stop.
void closePolygon()
ensures that the last position equals the first
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
void buildVaporizer(const SUMOSAXAttributes &attrs)
Builds a vaporization.
A color information.
a single phase description
alternative tag for e3 detector
const std::string & getActiveKey() const
Returns the active key.
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:310
alternative tag for e2 detector
Parser and container for routes during their loading.
TrafficLightType
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:662
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:285
Interface for building edges.
void addLogicItem(int request, const std::string &response, const std::string &foes, bool cont)
Adds a logic item.
void clearParameter()
Clears the parameter map.
Information on vClass specific stop offsets at lane end.