SUMO - Simulation of Urban MObility
NLHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
12 // The XML-Handler for network loading
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
15 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include "NLHandler.h"
36 #include "NLEdgeControlBuilder.h"
38 #include "NLDetectorBuilder.h"
39 #include "NLTriggerBuilder.h"
43 #include <utils/common/SUMOTime.h>
46 #include <utils/common/RGBColor.h>
48 #include <microsim/MSGlobals.h>
49 #include <microsim/MSLane.h>
50 #include <microsim/MSJunction.h>
57 #include <utils/shapes/Shape.h>
59 
60 
61 // ===========================================================================
62 // method definitions
63 // ===========================================================================
64 NLHandler::NLHandler(const std::string& file, MSNet& net,
65  NLDetectorBuilder& detBuilder,
66  NLTriggerBuilder& triggerBuilder,
67  NLEdgeControlBuilder& edgeBuilder,
68  NLJunctionControlBuilder& junctionBuilder) :
69  MSRouteHandler(file, true),
70  myNet(net), myActionBuilder(net),
71  myCurrentIsInternalToSkip(false),
72  myDetectorBuilder(detBuilder), myTriggerBuilder(triggerBuilder),
73  myEdgeControlBuilder(edgeBuilder), myJunctionControlBuilder(junctionBuilder),
74  myAmInTLLogicMode(false), myCurrentIsBroken(false),
75  myHaveWarnedAboutDeprecatedLanes(false),
76  myLastParameterised(0),
77  myHaveSeenInternalEdge(false),
78  myHaveSeenNeighs(false),
79  myHaveSeenAdditionalSpeedRestrictions(false),
80  myLefthand(false),
81  myNetworkVersion(0),
82  myNetIsLoaded(false) {
83 }
84 
85 
87 
88 
89 void
91  const SUMOSAXAttributes& attrs) {
92  try {
93  switch (element) {
94  case SUMO_TAG_NET: {
95  bool ok;
96  myLefthand = attrs.getOpt<bool>(SUMO_ATTR_LEFTHAND, 0, ok, false);
97  myNetworkVersion = attrs.get<double>(SUMO_ATTR_VERSION, 0, ok, false);
98  break;
99  }
100  case SUMO_TAG_EDGE:
101  beginEdgeParsing(attrs);
102  break;
103  case SUMO_TAG_LANE:
104  addLane(attrs);
105  break;
106  case SUMO_TAG_NEIGH:
108  myHaveSeenNeighs = true;
109  break;
110  case SUMO_TAG_JUNCTION:
111  openJunction(attrs);
112  initJunctionLogic(attrs);
113  break;
114  case SUMO_TAG_PHASE:
115  addPhase(attrs);
116  break;
117  case SUMO_TAG_CONNECTION:
118  addConnection(attrs);
119  break;
120  case SUMO_TAG_TLLOGIC:
121  initTrafficLightLogic(attrs);
122  break;
123  case SUMO_TAG_REQUEST:
124  addRequest(attrs);
125  break;
126  case SUMO_TAG_WAUT:
127  openWAUT(attrs);
128  break;
130  addWAUTSwitch(attrs);
131  break;
133  addWAUTJunction(attrs);
134  break;
135  case SUMO_TAG_E1DETECTOR:
137  addE1Detector(attrs);
138  break;
139  case SUMO_TAG_E2DETECTOR:
141  addE2Detector(attrs);
142  break;
143  case SUMO_TAG_E3DETECTOR:
145  beginE3Detector(attrs);
146  break;
147  case SUMO_TAG_DET_ENTRY:
148  addE3Entry(attrs);
149  break;
150  case SUMO_TAG_DET_EXIT:
151  addE3Exit(attrs);
152  break;
154  addInstantE1Detector(attrs);
155  break;
156  case SUMO_TAG_VSS:
158  break;
159  case SUMO_TAG_CALIBRATOR:
161  break;
162  case SUMO_TAG_REROUTER:
164  break;
165  case SUMO_TAG_BUS_STOP:
166  case SUMO_TAG_TRAIN_STOP:
169  break;
172  break;
175  break;
176  case SUMO_TAG_ACCESS:
178  break;
181  break;
182  case SUMO_TAG_VTYPEPROBE:
183  addVTypeProbeDetector(attrs);
184  break;
185  case SUMO_TAG_ROUTEPROBE:
186  addRouteProbeDetector(attrs);
187  break;
190  break;
193  break;
194  case SUMO_TAG_TIMEDEVENT:
196  break;
197  case SUMO_TAG_VAPORIZER:
199  break;
200  case SUMO_TAG_LOCATION:
201  setLocation(attrs);
202  break;
203  case SUMO_TAG_TAZ:
204  addDistrict(attrs);
205  break;
206  case SUMO_TAG_TAZSOURCE:
207  addDistrictEdge(attrs, true);
208  break;
209  case SUMO_TAG_TAZSINK:
210  addDistrictEdge(attrs, false);
211  break;
212  case SUMO_TAG_ROUNDABOUT:
213  addRoundabout(attrs);
214  break;
215  case SUMO_TAG_TYPE: {
216  bool ok = true;
217  myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
218  break;
219  }
220  case SUMO_TAG_RESTRICTION: {
221  bool ok = true;
222  const SUMOVehicleClass svc = getVehicleClassID(attrs.get<std::string>(SUMO_ATTR_VCLASS, myCurrentTypeID.c_str(), ok));
223  const double speed = attrs.get<double>(SUMO_ATTR_SPEED, myCurrentTypeID.c_str(), ok);
224  if (ok) {
225  myNet.addRestriction(myCurrentTypeID, svc, speed);
226  }
227  if (myNetIsLoaded) {
229  }
230  break;
231  }
232  default:
233  break;
234  }
235  } catch (InvalidArgument& e) {
236  WRITE_ERROR(e.what());
237  }
238  MSRouteHandler::myStartElement(element, attrs);
239  if (element == SUMO_TAG_PARAM && !myCurrentIsBroken) {
240  addParam(attrs);
241  }
242 }
243 
244 
245 void
247  switch (element) {
248  case SUMO_TAG_EDGE:
249  closeEdge();
250  break;
251  case SUMO_TAG_JUNCTION:
252  if (!myCurrentIsBroken) {
253  try {
256  } catch (InvalidArgument& e) {
257  WRITE_ERROR(e.what());
258  }
259  }
260  break;
261  case SUMO_TAG_TLLOGIC:
262  if (!myCurrentIsBroken) {
263  try {
265  } catch (InvalidArgument& e) {
266  WRITE_ERROR(e.what());
267  }
268  }
269  myAmInTLLogicMode = 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  bool typeOK = true;
472  SumoXMLNodeType type = attrs.getNodeType(typeOK);
473  if (!typeOK) {
474  WRITE_ERROR("An unknown or invalid junction type occured in junction '" + id + "'.");
475  ok = false;
476  }
477  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_KEY, id.c_str(), ok, "");
478  // incoming lanes
479  std::vector<MSLane*> incomingLanes;
480  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INCLANES, ""), incomingLanes, ok);
481  // internal lanes
482  std::vector<MSLane*> internalLanes;
484  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INTLANES, ""), internalLanes, ok);
485  }
486  if (!ok) {
487  myCurrentIsBroken = true;
488  } else {
489  try {
490  myJunctionControlBuilder.openJunction(id, key, type, x, y, shape, incomingLanes, internalLanes);
491  } catch (InvalidArgument& e) {
492  WRITE_ERROR(e.what() + std::string("\n Can not build according junction."));
493  myCurrentIsBroken = true;
494  }
495  }
496 }
497 
498 
499 void
500 NLHandler::parseLanes(const std::string& junctionID,
501  const std::string& def, std::vector<MSLane*>& into, bool& ok) {
502  StringTokenizer st(def);
503  while (ok && st.hasNext()) {
504  std::string laneID = st.next();
505  MSLane* lane = MSLane::dictionary(laneID);
506  if (!MSGlobals::gUsingInternalLanes && laneID[0] == ':') {
507  continue;
508  }
509  if (lane == 0) {
510  WRITE_ERROR("An unknown lane ('" + laneID + "') was tried to be set as incoming to junction '" + junctionID + "'.");
511  ok = false;
512  continue;
513  }
514  into.push_back(lane);
515  }
516 }
517 // ----
518 
519 void
521  bool ok = true;
522  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, 0, ok);
523  // circumventing empty string test
524  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
525  if (myLastParameterised != 0) {
527  }
528  // set
529  if (ok && myAmInTLLogicMode) {
530  assert(key != "");
531  assert(val != "");
533  }
534 }
535 
536 
537 void
539  myCurrentIsBroken = false;
540  bool ok = true;
541  // get the id, report an error if not given or empty...
542  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
543  if (!ok) {
544  myCurrentIsBroken = true;
545  return;
546  }
547  SUMOTime t = attrs.getOptSUMOTimeReporting(SUMO_ATTR_REF_TIME, id.c_str(), ok, 0);
548  std::string pro = attrs.get<std::string>(SUMO_ATTR_START_PROG, id.c_str(), ok);
549  if (!ok) {
550  myCurrentIsBroken = true;
551  }
552  if (!myCurrentIsBroken) {
553  myCurrentWAUTID = id;
554  try {
556  } catch (InvalidArgument& e) {
557  WRITE_ERROR(e.what());
558  myCurrentIsBroken = true;
559  }
560  }
561 }
562 
563 
564 void
566  bool ok = true;
568  std::string to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentWAUTID.c_str(), ok);
569  if (!ok) {
570  myCurrentIsBroken = true;
571  }
572  if (!myCurrentIsBroken) {
573  try {
575  } catch (InvalidArgument& e) {
576  WRITE_ERROR(e.what());
577  myCurrentIsBroken = true;
578  }
579  }
580 }
581 
582 
583 void
585  bool ok = true;
586  std::string wautID = attrs.get<std::string>(SUMO_ATTR_WAUT_ID, 0, ok);
587  std::string junctionID = attrs.get<std::string>(SUMO_ATTR_JUNCTION_ID, 0, ok);
588  std::string procedure = attrs.getOpt<std::string>(SUMO_ATTR_PROCEDURE, 0, ok, "");
589  bool synchron = attrs.getOpt<bool>(SUMO_ATTR_SYNCHRON, 0, ok, false);
590  if (!ok) {
591  myCurrentIsBroken = true;
592  }
593  try {
594  if (!myCurrentIsBroken) {
595  myJunctionControlBuilder.getTLLogicControlToUse().addWAUTJunction(wautID, junctionID, procedure, synchron);
596  }
597  } catch (InvalidArgument& e) {
598  WRITE_ERROR(e.what());
599  myCurrentIsBroken = true;
600  }
601 }
602 
603 
604 void
606  if (myCurrentIsBroken) {
607  return;
608  }
609  bool ok = true;
610  int request = attrs.get<int>(SUMO_ATTR_INDEX, 0, ok);
611  bool cont = false;
612  cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, 0, ok, false);
613  std::string response = attrs.get<std::string>(SUMO_ATTR_RESPONSE, 0, ok);
614  std::string foes = attrs.get<std::string>(SUMO_ATTR_FOES, 0, ok);
615  if (!ok) {
616  return;
617  }
618  // store received information
619  if (request >= 0 && response.length() > 0) {
620  try {
621  myJunctionControlBuilder.addLogicItem(request, response, foes, cont);
622  } catch (InvalidArgument& e) {
623  WRITE_ERROR(e.what());
624  }
625  }
626 }
627 
628 
629 void
631  if (myCurrentIsBroken) {
632  return;
633  }
634  bool ok = true;
635  // we either a have a junction or a legacy network with ROWLogic
636  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
637  if (ok) {
639  }
640 }
641 
642 
643 void
645  myCurrentIsBroken = false;
646  myAmInTLLogicMode = true;
647  bool ok = true;
648  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
649  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
651  std::string typeS;
652  if (myJunctionControlBuilder.getTLLogicControlToUse().get(id, programID) == 0) {
653  // SUMO_ATTR_TYPE is not needed when only modifying the offset of an
654  // existing program
655  typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok);
656  if (!ok) {
657  myCurrentIsBroken = true;
658  return;
659  }
660  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
662  } else {
663  WRITE_ERROR("Traffic light '" + id + "' has unknown type '" + typeS + "'.");
664  }
665  }
666  //
667  const SUMOTime offset = attrs.getOptSUMOTimeReporting(SUMO_ATTR_OFFSET, id.c_str(), ok, 0);
668  if (!ok) {
669  myCurrentIsBroken = true;
670  return;
671  }
672  myJunctionControlBuilder.initTrafficLightLogic(id, programID, type, offset);
673 }
674 
675 
676 void
678  // try to get the phase definition
679  bool ok = true;
680  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok);
681  if (!ok) {
682  return;
683  }
684  // try to get the phase duration
686  if (duration == 0) {
688  + " for tlLogic '" + myJunctionControlBuilder.getActiveKey()
689  + "' program '" + myJunctionControlBuilder.getActiveSubKey() + "' is zero.");
690  return;
691  }
692  // if the traffic light is an actuated traffic light, try to get
693  // the minimum and maximum durations
694  SUMOTime minDuration = attrs.getOptSUMOTimeReporting(
696  SUMOTime maxDuration = attrs.getOptSUMOTimeReporting(
698 
699 
700  //SOTL attributes
701  //If the type attribute is not present, the parsed phase is of type "undefined" (MSPhaseDefinition constructor),
702  //in this way SOTL traffic light logic can recognize the phase as unsuitable or decides other
703  //behaviors. See SOTL traffic light logic implementations.
704  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
705  bool ok = true;
706  std::string phaseTypeString;
707  bool transient_notdecisional_bit;
708  bool commit_bit;
709  MSPhaseDefinition::LaneIdVector laneIdVector;
710  try {
711  phaseTypeString = attrs.get<std::string>(SUMO_ATTR_TYPE, "phase", ok, false);
712  } catch (EmptyData&) {
713  MsgHandler::getWarningInstance()->inform("Empty type definition. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
714  transient_notdecisional_bit = false;
715  }
716  if (phaseTypeString.find("decisional") != std::string::npos) {
717  transient_notdecisional_bit = false;
718  } else if (phaseTypeString.find("transient") != std::string::npos) {
719  transient_notdecisional_bit = true;
720  } else {
721  MsgHandler::getWarningInstance()->inform("SOTL_ATTL_TYPE_DECISIONAL nor SOTL_ATTL_TYPE_TRANSIENT. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
722  transient_notdecisional_bit = false;
723  }
724  commit_bit = (phaseTypeString.find("commit") != std::string::npos);
725 
726  if (phaseTypeString.find("target") != std::string::npos) {
727  std::string delimiter(" ,;");
728  //Phase declared as target, getting targetLanes attribute
729  try {
731  std::string targetLanesString = attrs.getStringSecure(SUMO_ATTR_TARGETLANE, "");
732  //TOKENIZING
733  MSPhaseDefinition::LaneIdVector targetLanesVector;
734  //Skip delimiters at the beginning
735  std::string::size_type firstPos = targetLanesString.find_first_not_of(delimiter, 0);
736  //Find first "non-delimiter".
737  std::string::size_type pos = targetLanesString.find_first_of(delimiter, firstPos);
738 
739  while (std::string::npos != pos || std::string::npos != firstPos) {
740  //Found a token, add it to the vector
741  targetLanesVector.push_back(targetLanesString.substr(firstPos, pos - firstPos));
742 
743  //Skip delimiters
744  firstPos = targetLanesString.find_first_not_of(delimiter, pos);
745 
746  //Find next "non-delimiter"
747  pos = targetLanesString.find_first_of(delimiter, firstPos);
748  }
749  //Adding the SOTL parsed phase to have a new MSPhaseDefinition that is SOTL compliant for target phases
750  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration, transient_notdecisional_bit, commit_bit, targetLanesVector);
751  } catch (EmptyData&) {
752  MsgHandler::getErrorInstance()->inform("Missing targetLane definition for the target phase.");
753  return;
754  }
755  } else {
756  //Adding the SOTL parsed phase to have a new MSPhaseDefinition that is SOTL compliant for non target phases
757  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration, transient_notdecisional_bit, commit_bit);
758  }
759  } else {
760  //Adding the standard parsed phase to have a new MSPhaseDefinition
761 
762  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration);
763  }
764 }
765 
766 
767 void
769  bool ok = true;
770  // get the id, report an error if not given or empty...
771  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
772  if (!ok) {
773  return;
774  }
775  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
776  const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), ok);
777  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
778  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
779  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
780  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
781  if (!ok) {
782  return;
783  }
784  try {
785  myDetectorBuilder.buildInductLoop(id, lane, position, frequency,
787  friendlyPos, vTypes);
788  } catch (InvalidArgument& e) {
789  WRITE_ERROR(e.what());
790  } catch (IOError& e) {
791  WRITE_ERROR(e.what());
792  }
793 }
794 
795 
796 void
798  bool ok = true;
799  // get the id, report an error if not given or empty...
800  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
801  if (!ok) {
802  return;
803  }
804  const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), ok);
805  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
806  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
807  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
808  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
809  if (!ok) {
810  return;
811  }
812  try {
813  myDetectorBuilder.buildInstantInductLoop(id, lane, position, FileHelpers::checkForRelativity(file, getFileName()), friendlyPos, vTypes);
814  } catch (InvalidArgument& e) {
815  WRITE_ERROR(e.what());
816  } catch (IOError& e) {
817  WRITE_ERROR(e.what());
818  }
819 }
820 
821 
822 void
824  bool ok = true;
825  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
826  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
827  std::string type = attrs.getStringSecure(SUMO_ATTR_TYPE, "");
828  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
829  if (!ok) {
830  return;
831  }
832  try {
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  bool ok = true;
845  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
846  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
847  SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, -1);
848  std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
849  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
850  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
851  if (!ok) {
852  return;
853  }
854  try {
855  myDetectorBuilder.buildRouteProbe(id, edge, frequency, begin,
857  } catch (InvalidArgument& e) {
858  WRITE_ERROR(e.what());
859  } catch (IOError& e) {
860  WRITE_ERROR(e.what());
861  }
862 }
863 
864 
865 
866 void
868 
869  // check whether this is a detector connected to a tls and optionally to a link
870  bool ok = true;
871  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
872  const std::string lsaid = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), ok, "");
873  const std::string toLane = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "");
874  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
875  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
876  const double jamDistThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, 10.0f);
877  double position = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), ok, std::numeric_limits<double>::max());
878  const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), ok, std::numeric_limits<double>::max());
879  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
880  // const bool showDetector = attrs.getOpt<bool>(SUMO_ATTR_SHOW_DETECTOR, id.c_str(), ok, true);
881  // TODO: introduce show-detector attribute
882  const bool showDetector = true;
883  const std::string contStr = attrs.getOpt<std::string>(SUMO_ATTR_CONT, id.c_str(), ok, "");
884  if (contStr != "") {
885  WRITE_WARNING("Ignoring deprecated argument 'cont' for E2 detector '" + id + "'");
886  }
887  std::string lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, "");
888  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
889  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
890 
891  double endPosition = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, std::numeric_limits<double>::max());
892  const std::string lanes = attrs.getOpt<std::string>(SUMO_ATTR_LANES, id.c_str(), ok, ""); // lanes has priority to lane
893  if (!ok) {
894  return;
895  }
896 
897  bool lanesGiven = lanes != "";
898  bool laneGiven = lane != "";
899  if (!(lanesGiven || laneGiven)) {
900  // in absence of any lane-specification assume specification by id
901  WRITE_WARNING("Trying to specify detector's lane by the given id since the argument 'lane' is missing.")
902  lane = id;
903  laneGiven = true;
904  }
905  bool lengthGiven = length != std::numeric_limits<double>::max();
906  bool posGiven = position != std::numeric_limits<double>::max();
907  bool endPosGiven = endPosition != std::numeric_limits<double>::max();
908  bool lsaGiven = lsaid != "";
909  bool toLaneGiven = toLane != "";
910 
911  MSLane* clane = 0;
912  std::vector<MSLane*> clanes;
913  if (lanesGiven) {
914  // If lanes is given, endPos and startPos are required. lane, and length are ignored
915  std::string seps = " ,\t\n";
916  StringTokenizer st = StringTokenizer(lanes, seps, true);
917 // std::cout << "Parsing lanes..." << std::endl;
918  while (st.hasNext()) {
919  std::string nextLaneID = st.next();
920 // std::cout << "Next: " << nextLaneID << std::endl;
921  if (nextLaneID.find_first_of(seps) != nextLaneID.npos) {
922  continue;
923  }
924  clane = myDetectorBuilder.getLaneChecking(nextLaneID, SUMO_TAG_E2DETECTOR, id);
925  clanes.push_back(clane);
926  }
927  if (clanes.size() == 0) {
928  throw InvalidArgument("Malformed argument 'lanes' for E2Detector '" + id + "'.\nSpecify 'lanes' as a sequence of lane-IDs seperated by whitespace or comma (',')");
929  }
930  if (laneGiven) {
931  WRITE_WARNING("Ignoring argument 'lane' for E2Detector '" + id + "' since argument 'lanes' was given.\n"
932  "Usage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]");
933  }
934  if (lengthGiven) {
935  WRITE_WARNING("Ignoring argument 'length' for E2Detector '" + id + "' since argument 'lanes' was given.\n"
936  "Usage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]");
937  }
938  if (!posGiven) {
939  // assuming start pos == lane start
940  position = 0;
941  WRITE_WARNING("Missing argument 'pos' for E2Detector '" + id + "'. Assuming detector start == lane start of lane '" + clanes[0]->getID() + "'.");
942  }
943  if (!endPosGiven) {
944  // assuming end pos == lane end
945  endPosition = clanes[clanes.size() - 1]->getLength();
946  WRITE_WARNING("Missing argument 'endPos' for E2Detector '" + id + "'. Assuming detector end == lane end of lane '" + clanes[clanes.size() - 1]->getID() + "'.");
947  }
948 
949  } else {
950  if (!laneGiven) {
951  std::stringstream ss;
952  ss << "Missing argument 'lane' for E2Detector '" << id << "'."
953  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
954  throw InvalidArgument(ss.str());
955  }
957 
958  if (posGiven) {
959  // start pos is given
960  if (endPosGiven && lengthGiven) {
961  std::stringstream ss;
962  ss << "Ignoring argument 'endPos' for E2Detector '" << id << "' since argument 'pos' was given."
963  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
964  WRITE_WARNING(ss.str());
965  endPosition = std::numeric_limits<double>::max();
966  }
967  if (!lengthGiven && !endPosGiven) {
968  std::stringstream ss;
969  ss << "Missing arguments 'length'/'endPos' for E2Detector '" << id << "'. Assuming detector end == lane end of lane '" << lane << "'.";
970  WRITE_WARNING(ss.str());
971  endPosition = clane->getLength();
972  }
973  } else if (endPosGiven) {
974  // endPos is given, pos is not given
975  if (!lengthGiven) {
976  std::stringstream ss;
977  ss << "Missing arguments 'length'/'pos' for E2Detector '" << id << "'. Assuming detector start == lane start of lane '" << lane << "'.";
978  WRITE_WARNING(ss.str());
979  }
980  } else {
981  std::stringstream ss;
982  if (lengthGiven && fabs(length - clane->getLength()) > NUMERICAL_EPS) {
983  ss << "Incomplete positional specification for E2Detector '" << id << "'."
984  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
985  throw InvalidArgument(ss.str());
986  }
987  endPosition = clane->getLength();
988  position = 0;
989  ss << "Missing arguments 'pos'/'endPos' for E2Detector '" << id << "'. Assuming that the detector covers the whole lane '" << lane << "'.";
990  WRITE_WARNING(ss.str());
991  }
992  }
993 
994  // Frequency
995 
996  SUMOTime frequency;
997  if (!lsaGiven) {
998  frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
999  if (!ok) {
1000  return;
1001  }
1002  } else {
1003  frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, false);
1004  }
1005 
1006  // TLS
1008  if (lsaGiven) {
1009  tlls = &myJunctionControlBuilder.getTLLogic(lsaid);
1010  if (tlls->getActive() == 0) {
1011  throw InvalidArgument("The detector '" + id + "' refers to an unknown lsa '" + lsaid + "'.");
1012  }
1013  if (frequency != -1) {
1014  WRITE_WARNING("Ignoring argument 'frequency' for E2Detector '" + id + "' since argument 'tl' was given.");
1015  frequency = -1;
1016  }
1017  }
1018 
1019  // Link
1020  MSLane* cToLane = 0;
1021  if (toLaneGiven) {
1022  cToLane = myDetectorBuilder.getLaneChecking(toLane, SUMO_TAG_E2DETECTOR, id);
1023  }
1024 
1025  // File
1026  std::string filename;
1027  try {
1028  filename = FileHelpers::checkForRelativity(file, getFileName());
1029  } catch (IOError& e) {
1030  WRITE_ERROR(e.what());
1031  }
1032 
1033  // Build detector
1034  if (lanesGiven) {
1035  // specification by a lane sequence
1036  myDetectorBuilder.buildE2Detector(id, clanes, position, endPosition, filename, frequency,
1037  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
1038  vTypes, friendlyPos, showDetector,
1039  tlls, cToLane);
1040  } else {
1041  // specification by start or end lane
1042  myDetectorBuilder.buildE2Detector(id, clane, position, endPosition, length, filename, frequency,
1043  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
1044  vTypes, friendlyPos, showDetector,
1045  tlls, cToLane);
1046  }
1047 
1048 }
1049 
1050 
1051 void
1053  bool ok = true;
1054  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1055  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
1056  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
1057  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
1058  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
1059  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
1060  if (!ok) {
1061  return;
1062  }
1063  try {
1066  frequency, haltingSpeedThreshold, haltingTimeThreshold, vTypes);
1067  } catch (InvalidArgument& e) {
1068  WRITE_ERROR(e.what());
1069  } catch (IOError& e) {
1070  WRITE_ERROR(e.what());
1071  }
1072 }
1073 
1074 
1075 void
1077  bool ok = true;
1078  const double position = attrs.get<double>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1079  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
1080  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1081  if (!ok) {
1082  return;
1083  }
1084  myDetectorBuilder.addE3Entry(lane, position, friendlyPos);
1085 }
1086 
1087 
1088 void
1090  bool ok = true;
1091  const double position = attrs.get<double>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1092  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
1093  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1094  if (!ok) {
1095  return;
1096  }
1097  myDetectorBuilder.addE3Exit(lane, position, friendlyPos);
1098 }
1099 
1100 
1101 void
1102 NLHandler::addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype) {
1103  bool ok = true;
1104  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1105  const double maxTravelTime = attrs.getOpt<double>(SUMO_ATTR_MAX_TRAVELTIME, id.c_str(), ok, 100000);
1106  const double minSamples = attrs.getOpt<double>(SUMO_ATTR_MIN_SAMPLES, id.c_str(), ok, 0);
1107  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, POSITION_EPS);
1108  const std::string excludeEmpty = attrs.getOpt<std::string>(SUMO_ATTR_EXCLUDE_EMPTY, id.c_str(), ok, "false");
1109  const bool withInternal = attrs.getOpt<bool>(SUMO_ATTR_WITH_INTERNAL, id.c_str(), ok, false);
1110  const bool trackVehicles = attrs.getOpt<bool>(SUMO_ATTR_TRACK_VEHICLES, id.c_str(), ok, false);
1111  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
1112  const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "performance");
1113  std::string vtypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
1114  const SUMOTime frequency = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, -1);
1115  const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("begin")));
1116  const SUMOTime end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("end")));
1117  if (!ok) {
1118  return;
1119  }
1120  try {
1121  myDetectorBuilder.createEdgeLaneMeanData(id, frequency, begin, end,
1122  type, objecttype == SUMO_TAG_MEANDATA_LANE,
1123  // equivalent to TplConvert::_2bool used in SUMOSAXAttributes::getBool
1124  excludeEmpty[0] != 't' && excludeEmpty[0] != 'T' && excludeEmpty[0] != '1' && excludeEmpty[0] != 'x',
1125  excludeEmpty == "defaults", withInternal, trackVehicles,
1126  maxTravelTime, minSamples, haltingSpeedThreshold, vtypes,
1128  } catch (InvalidArgument& e) {
1129  WRITE_ERROR(e.what());
1130  } catch (IOError& e) {
1131  WRITE_ERROR(e.what());
1132  }
1133 }
1134 
1135 
1136 void
1138  bool ok = true;
1139  const std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
1140  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
1141  if (!MSGlobals::gUsingInternalLanes && (fromID[0] == ':' || toID[0] == ':')) {
1142  return;
1143  }
1144 
1145  MSLink* link = 0;
1146  try {
1147  bool ok = true;
1148  const int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, 0, ok);
1149  const double foeVisibilityDistance = attrs.getOpt<double>(SUMO_ATTR_VISIBILITY_DISTANCE, 0, ok, 4.5);
1150  const int toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, 0, ok);
1151  LinkDirection dir = parseLinkDir(attrs.get<std::string>(SUMO_ATTR_DIR, 0, ok));
1152  LinkState state = parseLinkState(attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok));
1153  bool keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, 0, ok, true);
1154  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, 0, ok, "");
1155  std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, 0, ok, "");
1156 
1157  MSEdge* from = MSEdge::dictionary(fromID);
1158  if (from == 0) {
1159  WRITE_ERROR("Unknown from-edge '" + fromID + "' in connection.");
1160  return;
1161  }
1162  MSEdge* to = MSEdge::dictionary(toID);
1163  if (to == 0) {
1164  WRITE_ERROR("Unknown to-edge '" + toID + "' in connection.");
1165  return;
1166  }
1167  if (fromLaneIdx < 0 || fromLaneIdx >= (int)from->getLanes().size() ||
1168  toLaneIdx < 0 || toLaneIdx >= (int)to->getLanes().size()) {
1169  WRITE_ERROR("Invalid lane index in connection from '" + from->getID() + "' to '" + to->getID() + "'.");
1170  return;
1171  }
1172  MSLane* fromLane = from->getLanes()[fromLaneIdx];
1173  MSLane* toLane = to->getLanes()[toLaneIdx];
1174  assert(fromLane);
1175  assert(toLane);
1176 
1177  MSTrafficLightLogic* logic = 0;
1178  int tlLinkIdx = -1;
1179  if (tlID != "") {
1180  tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, 0, ok);
1181  // make sure that the index is in range
1183  if ((tlLinkIdx < 0 || tlLinkIdx >= (int)logic->getCurrentPhaseDef().getState().size())
1184  && logic->getLogicType() != "railSignal"
1185  && logic->getLogicType() != "railCrossing") {
1186  WRITE_ERROR("Invalid " + toString(SUMO_ATTR_TLLINKINDEX) + " '" + toString(tlLinkIdx) +
1187  "' in connection controlled by '" + tlID + "'");
1188  return;
1189  }
1190  if (!ok) {
1191  return;
1192  }
1193  }
1194  double length = fromLane->getShape()[-1].distanceTo(toLane->getShape()[0]);
1195 
1196  // build the link
1197  MSLane* via = 0;
1198  if (viaID != "" && MSGlobals::gUsingInternalLanes) {
1199  via = MSLane::dictionary(viaID);
1200  if (via == 0) {
1201  WRITE_ERROR("An unknown lane ('" + viaID +
1202  "') should be set as a via-lane for lane '" + toLane->getID() + "'.");
1203  return;
1204  }
1205  length = via->getLength();
1206  }
1207  link = new MSLink(fromLane, toLane, via, dir, state, length, foeVisibilityDistance, keepClear, logic, tlLinkIdx);
1208  if (via != 0) {
1209  via->addIncomingLane(fromLane, link);
1210  } else {
1211  toLane->addIncomingLane(fromLane, link);
1212  }
1213  toLane->addApproachingLane(fromLane, myNetworkVersion < 0.25);
1214 
1215  // if a traffic light is responsible for it, inform the traffic light
1216  // check whether this link is controlled by a traffic light
1217  // we can not reuse logic here because it might be an inactive one
1218  if (tlID != "") {
1219  myJunctionControlBuilder.getTLLogic(tlID).addLink(link, fromLane, tlLinkIdx);
1220  }
1221  // add the link
1222  fromLane->addLink(link);
1223 
1224  } catch (InvalidArgument& e) {
1225  WRITE_ERROR(e.what());
1226  }
1227 }
1228 
1229 
1231 NLHandler::parseLinkDir(const std::string& dir) {
1232  if (SUMOXMLDefinitions::LinkDirections.hasString(dir)) {
1234  } else {
1235  throw InvalidArgument("Unrecognised link direction '" + dir + "'.");
1236  }
1237 }
1238 
1239 
1240 LinkState
1241 NLHandler::parseLinkState(const std::string& state) {
1242  if (SUMOXMLDefinitions::LinkStates.hasString(state)) {
1243  return SUMOXMLDefinitions::LinkStates.get(state);
1244  } else {
1245  if (state == "t") { // legacy networks
1246  // WRITE_WARNING("Obsolete link state 't'. Use 'o' instead");
1248  } else {
1249  throw InvalidArgument("Unrecognised link state '" + state + "'.");
1250  }
1251  }
1252 }
1253 
1254 
1255 // ----------------------------------
1256 void
1258  if (myNetIsLoaded) {
1259  //WRITE_WARNING("POIs and Polygons should be loaded using option --po-files")
1260  return;
1261  }
1262  bool ok = true;
1264  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, 0, ok);
1265  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, 0, ok);
1266  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, 0, ok);
1267  if (ok) {
1268  Position networkOffset = s[0];
1269  GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
1270  if (OptionsCont::getOptions().getBool("fcd-output.geo") && !GeoConvHelper::getFinal().usingGeoProjection()) {
1271  WRITE_WARNING("no valid geo projection loaded from network. fcd-output.geo will not work");
1272  }
1273  }
1274 }
1275 
1276 
1277 void
1279  bool ok = true;
1280  myCurrentIsBroken = false;
1281  // get the id, report an error if not given or empty...
1282  myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1283  if (!ok) {
1284  myCurrentIsBroken = true;
1285  return;
1286  }
1287  try {
1289  if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) {
1290  delete sink;
1291  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists.");
1292  }
1293  sink->initialize(new std::vector<MSLane*>());
1294  MSEdge* source = myEdgeControlBuilder.buildEdge(myCurrentDistrictID + "-source", EDGEFUNC_CONNECTOR, "", "", -1);
1295  if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) {
1296  delete source;
1297  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists.");
1298  }
1299  source->initialize(new std::vector<MSLane*>());
1300  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1301  std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES);
1302  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
1303  MSEdge* edge = MSEdge::dictionary(*i);
1304  // check whether the edge exists
1305  if (edge == 0) {
1306  throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known.");
1307  }
1308  source->addSuccessor(edge);
1309  edge->addSuccessor(sink);
1310  }
1311  }
1312  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
1314  if (shape.size() != 0) {
1315  if (!myNet.getShapeContainer().addPolygon(myCurrentDistrictID, "taz", RGBColor::parseColor("1.0,.33,.33"), 0, 0, "", shape, false)) {
1316  WRITE_WARNING("Skipping visualization of taz '" + myCurrentDistrictID + "', polygon already exists.");
1317  }
1318  }
1319  }
1320  } catch (InvalidArgument& e) {
1321  WRITE_ERROR(e.what());
1322  myCurrentIsBroken = true;
1323  }
1324 }
1325 
1326 
1327 void
1328 NLHandler::addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource) {
1329  if (myCurrentIsBroken) {
1330  // earlier error
1331  return;
1332  }
1333  bool ok = true;
1334  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentDistrictID.c_str(), ok);
1335  MSEdge* succ = MSEdge::dictionary(id);
1336  if (succ != 0) {
1337  // connect edge
1338  if (isSource) {
1339  MSEdge::dictionary(myCurrentDistrictID + "-source")->addSuccessor(succ);
1340  } else {
1341  succ->addSuccessor(MSEdge::dictionary(myCurrentDistrictID + "-sink"));
1342  }
1343  } else {
1344  WRITE_ERROR("At district '" + myCurrentDistrictID + "': succeeding edge '" + id + "' does not exist.");
1345  }
1346 }
1347 
1348 
1349 void
1351  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1352  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
1353  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
1354  MSEdge* edge = MSEdge::dictionary(*it);
1355  if (edge == 0) {
1356  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
1357  } else {
1358  edge->markAsRoundabout();
1359  }
1360  }
1361  } else {
1362  WRITE_ERROR("Empty edges in roundabout.");
1363  }
1364 }
1365 
1366 
1367 // ----------------------------------
1368 void
1370  try {
1372  } catch (InvalidArgument& e) {
1373  WRITE_ERROR(e.what());
1374  }
1375 }
1376 
1377 
1378 void
1380  if (!myCurrentIsBroken) {
1381  try {
1383  } catch (InvalidArgument& e) {
1384  WRITE_ERROR(e.what());
1385  myCurrentIsBroken = true;
1386  }
1387  }
1388  myCurrentWAUTID = "";
1389 }
1390 
1391 
1392 Position
1393 NLShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat) {
1394  MSLane* lane = MSLane::dictionary(laneID);
1395  if (lane == 0) {
1396  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1397  return Position::INVALID;
1398  }
1399  if (lanePos < 0) {
1400  lanePos = lane->getLength() + lanePos;
1401  }
1402  if (lanePos < 0 || lanePos > lane->getLength()) {
1403  WRITE_WARNING("lane position " + toString(lanePos) + " for poi '" + poiID + "' is not valid.");
1404  }
1405  return lane->geometryPositionAtOffset(lanePos, -lanePosLat);
1406 }
1407 /****************************************************************************/
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.
const std::string & getActiveKey() const
Returns the active key.
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:1052
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:584
Builds detectors for microsim.
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:867
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:180
a routeprobe detector
alternative tag for e1 detector
virtual SumoXMLNodeType getNodeType(bool &ok) const =0
Returns the value of the named attribute.
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:305
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:914
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:538
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:108
bool myCurrentIsBroken
Definition: NLHandler.h:338
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:119
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:168
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:500
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.
const std::string & getActiveSubKey() const
Returns the active sub key.
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:50
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
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:205
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:823
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1350
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:309
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)
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:448
weights: time range begin
link,node: the traffic light id responsible for this link
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1873
double getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:484
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.
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:745
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:768
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:64
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
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
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:321
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:1369
void endE3Detector()
Builds of an e3 detector using collected values.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The simulated network and simulation perfomer.
Definition: MSNet.h:89
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
bool myAmInTLLogicMode
internal information whether a tls-logic is currently read
Definition: NLHandler.h:324
an e3 entry point
void closeJunction(const std::string &basePath)
Closes (ends) the processing of the current junction.
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.
int getNumberOfLoadedPhases() const
return the number of phases loaded so far (for error reporting)
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:351
void closeWAUT()
Definition: NLHandler.cpp:1379
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:520
an edge based mean data detector
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1278
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
The state of a link.
static StringBijection< LinkDirection > LinkDirections
link directions
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:1883
const std::string & getID() const
Returns the id.
Definition: Named.h:66
A road/street connecting two junctions.
Definition: MSEdge.h:81
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1257
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.
#define max(a, b)
Definition: polyfonts.c:65
virtual void openJunction(const SUMOSAXAttributes &attrs)
opens a junction for processing
Definition: NLHandler.cpp:452
const std::string & getFileName() const
returns the current file name
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:315
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
MSTrafficLightLogic * getActive() const
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:1076
Encapsulated SAX-Attributes.
virtual std::vector< std::string > getStringVector(int attr) const =0
Tries to read given attribute assuming it is a string vector.
An instantenous induction loop.
std::string getCurrentE3ID() const
Returns the id of the currently built e3 detector.
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:1089
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
Builder of microsim-junctions and tls.
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:428
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
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:565
JunctionGraph myJunctionGraph
Definition: NLHandler.h:364
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:605
void setPermissionsFound()
Labels the network to contain vehicle class permissions.
Definition: MSNet.h:178
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 fill, bool ignorePruning=false)
Builds a polygon using the given values and adds it to the container.
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, double lanePosLat)
get position for a given laneID
Definition: NLHandler.cpp:1393
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:1137
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:330
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:47
roundabout defined in junction
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:90
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
#define POSITION_EPS
Definition: config.h:176
edge: the shape in xml-definition
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:345
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1231
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:76
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
MSTLLogicControl & getTLLogicControlToUse() const
Returns the used tls control.
void addParam(const std::string &key, const std::string &value)
Adds a parameter.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
begin/end of the description of a neighboring lane
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
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::TLSLogicVariants & getTLLogic(const std::string &id) const
Returns a previously build tls logic.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
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.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
void addParameter(const std::string &key, const std::string &value)
Adds a parameter.
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:327
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:1553
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:797
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:843
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:348
a sink within a district (connection road)
the edges crossed by a pedestrian crossing
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:86
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:312
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:357
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:360
void addWAUT(SUMOTime refTime, const std::string &id, const std::string &startProg)
Adds a WAUT definition.
weights: time range end
void openJunction(const std::string &id, const std::string &key, const SumoXMLNodeType type, double x, double y, const PositionVector &shape, const std::vector< MSLane * > &incomingLanes, const std::vector< MSLane * > &internalLanes)
Begins the processing of the named junction.
a vtypeprobe detector
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:85
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:677
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1328
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:217
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:1241
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
The abstract direction of a link.
void setJunctions(MSJunction *from, MSJunction *to)
Definition: MSEdge.h:358
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...
T get(const std::string &str) const
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:426
The parent class for traffic light logics.
A variable speed sign.
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:302
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:52
#define NUMERICAL_EPS
Definition: config.h:152
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.
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:246
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
void markAsRoundabout()
Definition: MSEdge.h:624
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:1102
Builds trigger objects for microsim.
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:630
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:354
Parameterised * myLastParameterised
Definition: NLHandler.h:342
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:79
void buildVaporizer(const SUMOSAXAttributes &attrs)
Builds a vaporization.
virtual SumoXMLEdgeFunc getEdgeFunc(bool &ok) const =0
Returns the value of the named attribute.
a single phase description
alternative tag for e3 detector
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:318
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:644
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:278
Interface for building edges.
void addLogicItem(int request, const std::string &response, const std::string &foes, bool cont)
Adds a logic item.