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