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-2016 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) {
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 (edge != 0 && from != 0 && to != 0) {
288  edge->setJunctions(from, to);
289  from->addOutgoing(edge);
290  to->addIncoming(edge);
291  }
292  }
293  myNetIsLoaded = true;
294  break;
295  default:
296  break;
297  }
299  if (element != SUMO_TAG_PARAM) {
301  }
302 }
303 
304 
305 
306 // ---- the root/edge - element
307 void
309  bool ok = true;
310  myCurrentIsBroken = false;
311  // get the id, report an error if not given or empty...
312  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
313  if (!ok) {
314  myCurrentIsBroken = true;
315  return;
316  }
317  // omit internal edges if not wished
318  if (id[0] == ':') {
319  myHaveSeenInternalEdge = true;
322  return;
323  }
324  }
325  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
326  myJunctionGraph[id] = std::make_pair(
327  attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok),
328  attrs.get<std::string>(SUMO_ATTR_TO, 0, ok));
329  } else if (id[0] == ':') {
330  // must be an internal edge
331  std::string junctionID = SUMOXMLDefinitions::getJunctionIDFromInternalEdge(id);
332  myJunctionGraph[id] = std::make_pair(junctionID, junctionID);
333  }
335  // parse the function
336  const SumoXMLEdgeFunc func = attrs.getEdgeFunc(ok);
337  if (!ok) {
338  WRITE_ERROR("Edge '" + id + "' has an invalid type.");
339  myCurrentIsBroken = true;
340  return;
341  }
342  // interpret the function
344  switch (func) {
345  case EDGEFUNC_NORMAL:
346  funcEnum = MSEdge::EDGEFUNCTION_NORMAL;
347  break;
348  case EDGEFUNC_CONNECTOR:
349  case EDGEFUNC_SINK:
350  case EDGEFUNC_SOURCE:
352  break;
353  case EDGEFUNC_INTERNAL:
355  break;
356  case EDGEFUNC_CROSSING:
358  break;
361  break;
362  }
363  // get the street name
364  const std::string streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
365  // get the edge type
366  const std::string edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
367  // get the edge priority (only for visualization)
368  const int priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1); // default taken from netbuild/NBFrame option 'default.priority'
369  if (!ok) {
370  myCurrentIsBroken = true;
371  return;
372  }
373  //
374  try {
375  myEdgeControlBuilder.beginEdgeParsing(id, funcEnum, streetName, edgeType, priority);
376  } catch (InvalidArgument& e) {
377  WRITE_ERROR(e.what());
378  myCurrentIsBroken = true;
379  }
380 
381  if (funcEnum == MSEdge::EDGEFUNCTION_CROSSING) {
382  //get the crossingEdges attribute (to implement the other side of the road pushbutton)
383  const std::string crossingEdges = attrs.getOpt<std::string>(SUMO_ATTR_CROSSING_EDGES, id.c_str(), ok, "");
384  if (!crossingEdges.empty()) {
385  std::vector<std::string> crossingEdgesVector;
386  StringTokenizer edges(crossingEdges);
387  while (edges.hasNext()) {
388  crossingEdgesVector.push_back(edges.next());
389  }
390  myEdgeControlBuilder.addCrossingEdges(crossingEdgesVector);
391  }
392  }
393 }
394 
395 
396 void
398  // omit internal edges if not wished and broken edges
400  return;
401  }
402  try {
404  MSEdge::dictionary(e->getID(), e);
405  } catch (InvalidArgument& e) {
406  WRITE_ERROR(e.what());
407  }
408 }
409 
410 
411 // ---- the root/edge/lanes/lane - element
412 void
414  // omit internal edges if not wished and broken edges
416  return;
417  }
418  bool ok = true;
419  // get the id, report an error if not given or empty...
420  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
421  if (!ok) {
422  myCurrentIsBroken = true;
423  return;
424  }
425  const double maxSpeed = attrs.get<double>(SUMO_ATTR_SPEED, id.c_str(), ok);
426  const double length = attrs.get<double>(SUMO_ATTR_LENGTH, id.c_str(), ok);
427  const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "", false);
428  const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
429  const double width = attrs.getOpt<double>(SUMO_ATTR_WIDTH, id.c_str(), ok, SUMO_const_laneWidth);
430  const PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
431  const int index = attrs.get<int>(SUMO_ATTR_INDEX, id.c_str(), ok);
432  const bool isRampAccel = attrs.getOpt<bool>(SUMO_ATTR_ACCELERATION, id.c_str(), ok, false);
433  if (shape.size() < 2) {
434  WRITE_ERROR("Shape of lane '" + id + "' is broken.\n Can not build according edge.");
435  myCurrentIsBroken = true;
436  return;
437  }
438  const SVCPermissions permissions = parseVehicleClasses(allow, disallow);
439  if (permissions != SVCAll) {
441  }
442  myCurrentIsBroken |= !ok;
443  if (!myCurrentIsBroken) {
444  try {
445  MSLane* lane = myEdgeControlBuilder.addLane(id, maxSpeed, length, shape, width, permissions, index, isRampAccel);
446  // insert the lane into the lane-dictionary, checking
447  if (!MSLane::dictionary(id, lane)) {
448  delete lane;
449  WRITE_ERROR("Another lane with the id '" + id + "' exists.");
450  myCurrentIsBroken = true;
451  }
452  myLastParameterised = lane;
453  } catch (InvalidArgument& e) {
454  WRITE_ERROR(e.what());
455  }
456  }
457 }
458 
459 
460 // ---- the root/junction - element
461 void
463  myCurrentIsBroken = false;
464  bool ok = true;
465  // get the id, report an error if not given or empty...
466  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
467  if (!ok) {
468  myCurrentIsBroken = true;
469  return;
470  }
471  PositionVector shape;
472  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
473  // inner junctions have no shape
474  shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok, PositionVector());
475  if (shape.size() > 2) {
476  shape.closePolygon();
477  }
478  }
479  double x = attrs.get<double>(SUMO_ATTR_X, id.c_str(), ok);
480  double y = attrs.get<double>(SUMO_ATTR_Y, id.c_str(), ok);
481  bool typeOK = true;
482  SumoXMLNodeType type = attrs.getNodeType(typeOK);
483  if (!typeOK) {
484  WRITE_ERROR("An unknown or invalid junction type occured in junction '" + id + "'.");
485  ok = false;
486  }
487  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_KEY, id.c_str(), ok, "");
488  // incoming lanes
489  std::vector<MSLane*> incomingLanes;
490  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INCLANES, ""), incomingLanes, ok);
491  // internal lanes
492  std::vector<MSLane*> internalLanes;
494  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INTLANES, ""), internalLanes, ok);
495  }
496  if (!ok) {
497  myCurrentIsBroken = true;
498  } else {
499  try {
500  myJunctionControlBuilder.openJunction(id, key, type, x, y, shape, incomingLanes, internalLanes);
501  } catch (InvalidArgument& e) {
502  WRITE_ERROR(e.what() + std::string("\n Can not build according junction."));
503  myCurrentIsBroken = true;
504  }
505  }
506 }
507 
508 
509 void
510 NLHandler::parseLanes(const std::string& junctionID,
511  const std::string& def, std::vector<MSLane*>& into, bool& ok) {
512  StringTokenizer st(def);
513  while (ok && st.hasNext()) {
514  std::string laneID = st.next();
515  MSLane* lane = MSLane::dictionary(laneID);
516  if (!MSGlobals::gUsingInternalLanes && laneID[0] == ':') {
517  continue;
518  }
519  if (lane == 0) {
520  WRITE_ERROR("An unknown lane ('" + laneID + "') was tried to be set as incoming to junction '" + junctionID + "'.");
521  ok = false;
522  continue;
523  }
524  into.push_back(lane);
525  }
526 }
527 // ----
528 
529 void
531  bool ok = true;
532  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, 0, ok);
533  // circumventing empty string test
534  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
535  if (myLastParameterised != 0) {
537  }
538  // set
539  if (ok && myAmInTLLogicMode) {
540  assert(key != "");
541  assert(val != "");
543  }
544 }
545 
546 
547 void
549  myCurrentIsBroken = false;
550  bool ok = true;
551  // get the id, report an error if not given or empty...
552  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
553  if (!ok) {
554  myCurrentIsBroken = true;
555  return;
556  }
557  SUMOTime t = attrs.getOptSUMOTimeReporting(SUMO_ATTR_REF_TIME, id.c_str(), ok, 0);
558  std::string pro = attrs.get<std::string>(SUMO_ATTR_START_PROG, id.c_str(), ok);
559  if (!ok) {
560  myCurrentIsBroken = true;
561  }
562  if (!myCurrentIsBroken) {
563  myCurrentWAUTID = id;
564  try {
566  } catch (InvalidArgument& e) {
567  WRITE_ERROR(e.what());
568  myCurrentIsBroken = true;
569  }
570  }
571 }
572 
573 
574 void
576  bool ok = true;
578  std::string to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentWAUTID.c_str(), ok);
579  if (!ok) {
580  myCurrentIsBroken = true;
581  }
582  if (!myCurrentIsBroken) {
583  try {
585  } catch (InvalidArgument& e) {
586  WRITE_ERROR(e.what());
587  myCurrentIsBroken = true;
588  }
589  }
590 }
591 
592 
593 void
595  bool ok = true;
596  std::string wautID = attrs.get<std::string>(SUMO_ATTR_WAUT_ID, 0, ok);
597  std::string junctionID = attrs.get<std::string>(SUMO_ATTR_JUNCTION_ID, 0, ok);
598  std::string procedure = attrs.getOpt<std::string>(SUMO_ATTR_PROCEDURE, 0, ok, "");
599  bool synchron = attrs.getOpt<bool>(SUMO_ATTR_SYNCHRON, 0, ok, false);
600  if (!ok) {
601  myCurrentIsBroken = true;
602  }
603  try {
604  if (!myCurrentIsBroken) {
605  myJunctionControlBuilder.getTLLogicControlToUse().addWAUTJunction(wautID, junctionID, procedure, synchron);
606  }
607  } catch (InvalidArgument& e) {
608  WRITE_ERROR(e.what());
609  myCurrentIsBroken = true;
610  }
611 }
612 
613 
614 void
616  if (myCurrentIsBroken) {
617  return;
618  }
619  bool ok = true;
620  int request = attrs.get<int>(SUMO_ATTR_INDEX, 0, ok);
621  bool cont = false;
622  cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, 0, ok, false);
623  std::string response = attrs.get<std::string>(SUMO_ATTR_RESPONSE, 0, ok);
624  std::string foes = attrs.get<std::string>(SUMO_ATTR_FOES, 0, ok);
625  if (!ok) {
626  return;
627  }
628  // store received information
629  if (request >= 0 && response.length() > 0) {
630  try {
631  myJunctionControlBuilder.addLogicItem(request, response, foes, cont);
632  } catch (InvalidArgument& e) {
633  WRITE_ERROR(e.what());
634  }
635  }
636 }
637 
638 
639 void
641  if (myCurrentIsBroken) {
642  return;
643  }
644  bool ok = true;
645  // we either a have a junction or a legacy network with ROWLogic
646  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
647  if (ok) {
649  }
650 }
651 
652 
653 void
655  myCurrentIsBroken = false;
656  myAmInTLLogicMode = true;
657  bool ok = true;
658  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
659  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
661  std::string typeS;
662  if (myJunctionControlBuilder.getTLLogicControlToUse().get(id, programID) == 0) {
663  // SUMO_ATTR_TYPE is not needed when only modifying the offset of an
664  // existing program
665  typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok);
666  if (!ok) {
667  myCurrentIsBroken = true;
668  return;
669  }
670  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
672  } else {
673  WRITE_ERROR("Traffic light '" + id + "' has unknown type '" + typeS + "'");
674  }
675  }
676  //
677  const SUMOTime offset = attrs.getOptSUMOTimeReporting(SUMO_ATTR_OFFSET, id.c_str(), ok, 0);
678  if (!ok) {
679  myCurrentIsBroken = true;
680  return;
681  }
682  myJunctionControlBuilder.initTrafficLightLogic(id, programID, type, offset);
683 }
684 
685 
686 void
688  // try to get the phase definition
689  bool ok = true;
690  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok);
691  if (!ok) {
692  return;
693  }
694  // try to get the phase duration
696  if (duration == 0) {
698  + " for tlLogic '" + myJunctionControlBuilder.getActiveKey()
699  + "' program '" + myJunctionControlBuilder.getActiveSubKey() + "' is zero.");
700  return;
701  }
702  // if the traffic light is an actuated traffic light, try to get
703  // the minimum and maximum durations
704  SUMOTime minDuration = attrs.getOptSUMOTimeReporting(
706  SUMOTime maxDuration = attrs.getOptSUMOTimeReporting(
708 
709 
710  //SOTL attributes
711  //If the type attribute is not present, the parsed phase is of type "undefined" (MSPhaseDefinition constructor),
712  //in this way SOTL traffic light logic can recognize the phase as unsuitable or decides other
713  //behaviors. See SOTL traffic light logic implementations.
714  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
715  bool ok = true;
716  std::string phaseTypeString;
717  bool transient_notdecisional_bit;
718  bool commit_bit;
719  MSPhaseDefinition::LaneIdVector laneIdVector;
720  try {
721  phaseTypeString = attrs.get<std::string>(SUMO_ATTR_TYPE, "phase", ok, false);
722  } catch (EmptyData&) {
723  MsgHandler::getWarningInstance()->inform("Empty type definition. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
724  transient_notdecisional_bit = false;
725  }
726  if (phaseTypeString.find("decisional") != std::string::npos) {
727  transient_notdecisional_bit = false;
728  } else if (phaseTypeString.find("transient") != std::string::npos) {
729  transient_notdecisional_bit = true;
730  } else {
731  MsgHandler::getWarningInstance()->inform("SOTL_ATTL_TYPE_DECISIONAL nor SOTL_ATTL_TYPE_TRANSIENT. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
732  transient_notdecisional_bit = false;
733  }
734  commit_bit = (phaseTypeString.find("commit") != std::string::npos);
735 
736  if (phaseTypeString.find("target") != std::string::npos) {
737  std::string delimiter(" ,;");
738  //Phase declared as target, getting targetLanes attribute
739  try {
741  std::string targetLanesString = attrs.getStringSecure(SUMO_ATTR_TARGETLANE, "");
742  //TOKENIZING
743  MSPhaseDefinition::LaneIdVector targetLanesVector;
744  //Skip delimiters at the beginning
745  std::string::size_type firstPos = targetLanesString.find_first_not_of(delimiter, 0);
746  //Find first "non-delimiter".
747  std::string::size_type pos = targetLanesString.find_first_of(delimiter, firstPos);
748 
749  while (std::string::npos != pos || std::string::npos != firstPos) {
750  //Found a token, add it to the vector
751  targetLanesVector.push_back(targetLanesString.substr(firstPos, pos - firstPos));
752 
753  //Skip delimiters
754  firstPos = targetLanesString.find_first_not_of(delimiter, pos);
755 
756  //Find next "non-delimiter"
757  pos = targetLanesString.find_first_of(delimiter, firstPos);
758  }
759  //Adding the SOTL parsed phase to have a new MSPhaseDefinition that is SOTL compliant for target phases
760  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration, transient_notdecisional_bit, commit_bit, targetLanesVector);
761  } catch (EmptyData&) {
762  MsgHandler::getErrorInstance()->inform("Missing targetLane definition for the target phase.");
763  return;
764  }
765  } else {
766  //Adding the SOTL parsed phase to have a new MSPhaseDefinition that is SOTL compliant for non target phases
767  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration, transient_notdecisional_bit, commit_bit);
768  }
769  } else {
770  //Adding the standard parsed phase to have a new MSPhaseDefinition
771 
772  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration);
773  }
774 }
775 
776 
777 void
779  bool ok = true;
780  // get the id, report an error if not given or empty...
781  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
782  if (!ok) {
783  return;
784  }
785  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
786  const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), ok);
787  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
788  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
789  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
790  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
791  if (!ok) {
792  return;
793  }
794  try {
795  myDetectorBuilder.buildInductLoop(id, lane, position, frequency,
797  friendlyPos, vTypes);
798  } catch (InvalidArgument& e) {
799  WRITE_ERROR(e.what());
800  } catch (IOError& e) {
801  WRITE_ERROR(e.what());
802  }
803 }
804 
805 
806 void
808  bool ok = true;
809  // get the id, report an error if not given or empty...
810  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
811  if (!ok) {
812  return;
813  }
814  const double position = attrs.get<double>(SUMO_ATTR_POSITION, id.c_str(), ok);
815  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
816  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
817  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
818  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
819  if (!ok) {
820  return;
821  }
822  try {
823  myDetectorBuilder.buildInstantInductLoop(id, lane, position, FileHelpers::checkForRelativity(file, getFileName()), friendlyPos, vTypes);
824  } catch (InvalidArgument& e) {
825  WRITE_ERROR(e.what());
826  } catch (IOError& e) {
827  WRITE_ERROR(e.what());
828  }
829 }
830 
831 
832 void
834  bool ok = true;
835  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
836  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
837  std::string type = attrs.getStringSecure(SUMO_ATTR_TYPE, "");
838  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
839  if (!ok) {
840  return;
841  }
842  try {
844  } catch (InvalidArgument& e) {
845  WRITE_ERROR(e.what());
846  } catch (IOError& e) {
847  WRITE_ERROR(e.what());
848  }
849 }
850 
851 
852 void
854  bool ok = true;
855  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
856  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
857  SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, -1);
858  std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
859  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
860  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
861  if (!ok) {
862  return;
863  }
864  try {
865  myDetectorBuilder.buildRouteProbe(id, edge, frequency, begin,
867  } catch (InvalidArgument& e) {
868  WRITE_ERROR(e.what());
869  } catch (IOError& e) {
870  WRITE_ERROR(e.what());
871  }
872 }
873 
874 
875 
876 void
878 
879  // check whether this is a detector connected to a tls and optionally to a link
880  bool ok = true;
881  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
882  const std::string lsaid = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), ok, "");
883  const std::string toLane = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "");
884  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
885  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
886  const double jamDistThreshold = attrs.getOpt<double>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, 10.0f);
887  double position = attrs.getOpt<double>(SUMO_ATTR_POSITION, id.c_str(), ok, std::numeric_limits<double>::max());
888  const double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, id.c_str(), ok, std::numeric_limits<double>::max());
889  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
890  // const bool showDetector = attrs.getOpt<bool>(SUMO_ATTR_SHOW_DETECTOR, id.c_str(), ok, true);
891  // TODO: introduce show-detector attribute
892  const bool showDetector = true;
893  const std::string contStr = attrs.getOpt<std::string>(SUMO_ATTR_CONT, id.c_str(), ok, "");
894  if (contStr != "") {
895  WRITE_WARNING("Ignoring deprecated argument 'cont' for E2 detector '" + id + "'");
896  }
897  std::string lane = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, "");
898  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
899  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
900 
901  double endPosition = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, std::numeric_limits<double>::max());
902  const std::string lanes = attrs.getOpt<std::string>(SUMO_ATTR_LANES, id.c_str(), ok, ""); // lanes has priority to lane
903  if (!ok) {
904  return;
905  }
906 
907  bool lanesGiven = lanes != "";
908  bool laneGiven = lane != "";
909  if (!(lanesGiven || laneGiven)) {
910  // in absence of any lane-specification assume specification by id
911  WRITE_WARNING("Trying to specify detector's lane by the given id since the argument 'lane' is missing.")
912  lane = id;
913  laneGiven = true;
914  }
915  bool lengthGiven = length != std::numeric_limits<double>::max();
916  bool posGiven = position != std::numeric_limits<double>::max();
917  bool endPosGiven = endPosition != std::numeric_limits<double>::max();
918  bool lsaGiven = lsaid != "";
919  bool toLaneGiven = toLane != "";
920 
921  MSLane* clane = 0;
922  std::vector<MSLane*> clanes;
923  if (lanesGiven) {
924  // If lanes is given, endPos and startPos are required. lane, endLane and length are ignored
925  std::string seps = " ,\t\n";
926  StringTokenizer st = StringTokenizer(lanes, seps, true);
927 // std::cout << "Parsing lanes..." << std::endl;
928  while (st.hasNext()) {
929  std::string nextLaneID = st.next();
930 // std::cout << "Next: " << nextLaneID << std::endl;
931  if (nextLaneID.find_first_of(seps) != nextLaneID.npos) {
932  continue;
933  }
934  clane = myDetectorBuilder.getLaneChecking(nextLaneID, SUMO_TAG_E2DETECTOR, id);
935  clanes.push_back(clane);
936  }
937  if (clanes.size() == 0) {
938  throw InvalidArgument("Malformed argument 'lanes' for E2Detector '" + id + "'.\nSpecify 'lanes' as a sequence of lane-IDs seperated by whitespace or comma (',')");
939  }
940  if (laneGiven) {
941  WRITE_WARNING("Ignoring argument 'lane' for E2Detector '" + id + "' since argument 'lanes' was given.\n"
942  "Usage combinations for positional specification: [lane, pos, length], [endLane/lane, endPos, length], or [lanes, pos, endPos]");
943  }
944  if (lengthGiven) {
945  WRITE_WARNING("Ignoring argument 'length' for E2Detector '" + id + "' since argument 'lanes' was given.\n"
946  "Usage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]");
947  }
948  if (!posGiven) {
949  // assuming start pos == lane start
950  position = 0;
951  WRITE_WARNING("Missing argument 'pos' for E2Detector '" + id + "'. Assuming detector start == lane start of lane '" + clanes[0]->getID() + "'.");
952  }
953  if (!endPosGiven) {
954  // assuming end pos == lane end
955  endPosition = clanes[clanes.size() - 1]->getLength();
956  WRITE_WARNING("Missing argument 'endPos' for E2Detector '" + id + "'. Assuming detector end == lane end of lane '" + clanes[clanes.size() - 1]->getID() + "'.");
957  }
958 
959  } else {
960  if (!laneGiven) {
961  std::stringstream ss;
962  ss << "Missing argument 'lane' for E2Detector '" << id << "'."
963  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
964  throw InvalidArgument(ss.str());
965  }
967 
968  if (posGiven) {
969  // start pos is given
970  if (endPosGiven && lengthGiven) {
971  std::stringstream ss;
972  ss << "Ignoring argument 'endPos' for E2Detector '" << id << "' since argument 'pos' was given."
973  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
974  WRITE_WARNING(ss.str());
975  endPosition = std::numeric_limits<double>::max();
976  }
977  if (!lengthGiven && !endPosGiven) {
978  std::stringstream ss;
979  ss << "Missing arguments 'length'/'endPos' for E2Detector '" << id << "'. Assuming detector end == lane end of lane '" << lane << "'.";
980  WRITE_WARNING(ss.str());
981  endPosition = clane->getLength();
982  }
983  } else if (endPosGiven) {
984  // endPos is given, pos is not given
985  if (!lengthGiven) {
986  std::stringstream ss;
987  ss << "Missing arguments 'length'/'pos' for E2Detector '" << id << "'. Assuming detector start == lane start of lane '" << lane << "'.";
988  WRITE_WARNING(ss.str());
989  }
990  } else {
991  std::stringstream ss;
992  if (lengthGiven && fabs(length - clane->getLength()) > NUMERICAL_EPS) {
993  ss << "Incomplete positional specification for E2Detector '" << id << "'."
994  << "\nUsage combinations for positional specification: [lane, pos, length], [lane, endPos, length], or [lanes, pos, endPos]";
995  throw InvalidArgument(ss.str());
996  }
997  endPosition = clane->getLength();
998  position = 0;
999  ss << "Missing arguments 'pos'/'endPos' for E2Detector '" << id << "'. Assuming that the detector covers the whole lane '" << lane << "'.";
1000  WRITE_WARNING(ss.str());
1001  }
1002  }
1003 
1004  // Frequency
1005 
1006  SUMOTime frequency;
1007  if (!lsaGiven) {
1008  frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
1009  if (!ok) {
1010  return;
1011  }
1012  } else {
1013  frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, false);
1014  }
1015 
1016  // TLS
1018  if (lsaGiven) {
1019  tlls = &myJunctionControlBuilder.getTLLogic(lsaid);
1020  if (tlls->getActive() == 0) {
1021  throw InvalidArgument("The detector '" + id + "' refers to an unknown lsa '" + lsaid + "'.");
1022  }
1023  if (frequency != -1) {
1024  WRITE_WARNING("Ignoring argument 'frequency' for E2Detector '" + id + "' since argument 'tl' was given.");
1025  frequency = -1;
1026  }
1027  }
1028 
1029  // Link
1030  MSLane* cToLane = 0;
1031  if (toLaneGiven) {
1032  cToLane = myDetectorBuilder.getLaneChecking(toLane, SUMO_TAG_E2DETECTOR, id);
1033  }
1034 
1035  // File
1036  std::string filename;
1037  try {
1038  filename = FileHelpers::checkForRelativity(file, getFileName());
1039  } catch (IOError& e) {
1040  WRITE_ERROR(e.what());
1041  }
1042 
1043  // Build detector
1044  if (lanesGiven) {
1045  // specification by a lane sequence
1046  myDetectorBuilder.buildE2Detector(id, clanes, position, endPosition, filename, frequency,
1047  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
1048  vTypes, friendlyPos, showDetector,
1049  tlls, cToLane);
1050  } else {
1051  // specification by start or end lane
1052  myDetectorBuilder.buildE2Detector(id, clane, position, endPosition, length, filename, frequency,
1053  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
1054  vTypes, friendlyPos, showDetector,
1055  tlls, cToLane);
1056  }
1057 
1058 }
1059 
1060 
1061 void
1063  bool ok = true;
1064  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1065  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
1066  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
1067  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
1068  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
1069  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
1070  if (!ok) {
1071  return;
1072  }
1073  try {
1076  frequency, haltingSpeedThreshold, haltingTimeThreshold, vTypes);
1077  } catch (InvalidArgument& e) {
1078  WRITE_ERROR(e.what());
1079  } catch (IOError& e) {
1080  WRITE_ERROR(e.what());
1081  }
1082 }
1083 
1084 
1085 void
1087  bool ok = true;
1088  const double position = attrs.get<double>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1089  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
1090  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1091  if (!ok) {
1092  return;
1093  }
1094  myDetectorBuilder.addE3Entry(lane, position, friendlyPos);
1095 }
1096 
1097 
1098 void
1100  bool ok = true;
1101  const double position = attrs.get<double>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1102  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
1103  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
1104  if (!ok) {
1105  return;
1106  }
1107  myDetectorBuilder.addE3Exit(lane, position, friendlyPos);
1108 }
1109 
1110 
1111 void
1112 NLHandler::addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype) {
1113  bool ok = true;
1114  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1115  const double maxTravelTime = attrs.getOpt<double>(SUMO_ATTR_MAX_TRAVELTIME, id.c_str(), ok, 100000);
1116  const double minSamples = attrs.getOpt<double>(SUMO_ATTR_MIN_SAMPLES, id.c_str(), ok, 0);
1117  const double haltingSpeedThreshold = attrs.getOpt<double>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, POSITION_EPS);
1118  const std::string excludeEmpty = attrs.getOpt<std::string>(SUMO_ATTR_EXCLUDE_EMPTY, id.c_str(), ok, "false");
1119  const bool withInternal = attrs.getOpt<bool>(SUMO_ATTR_WITH_INTERNAL, id.c_str(), ok, false);
1120  const bool trackVehicles = attrs.getOpt<bool>(SUMO_ATTR_TRACK_VEHICLES, id.c_str(), ok, false);
1121  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
1122  const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "performance");
1123  std::string vtypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
1124  const SUMOTime frequency = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, -1);
1125  const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("begin")));
1126  const SUMOTime end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("end")));
1127  if (!ok) {
1128  return;
1129  }
1130  try {
1131  myDetectorBuilder.createEdgeLaneMeanData(id, frequency, begin, end,
1132  type, objecttype == SUMO_TAG_MEANDATA_LANE,
1133  // equivalent to TplConvert::_2bool used in SUMOSAXAttributes::getBool
1134  excludeEmpty[0] != 't' && excludeEmpty[0] != 'T' && excludeEmpty[0] != '1' && excludeEmpty[0] != 'x',
1135  excludeEmpty == "defaults", withInternal, trackVehicles,
1136  maxTravelTime, minSamples, haltingSpeedThreshold, vtypes,
1138  } catch (InvalidArgument& e) {
1139  WRITE_ERROR(e.what());
1140  } catch (IOError& e) {
1141  WRITE_ERROR(e.what());
1142  }
1143 }
1144 
1145 
1146 void
1148  bool ok = true;
1149  std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
1150  if (!MSGlobals::gUsingInternalLanes && fromID[0] == ':') {
1151  return;
1152  }
1153 
1154  MSLink* link = 0;
1155  try {
1156  bool ok = true;
1157  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
1158  const int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, 0, ok);
1159  const double foeVisibilityDistance = attrs.getOpt<double>(SUMO_ATTR_VISIBILITY_DISTANCE, 0, ok, 4.5);
1160  const int toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, 0, ok);
1161  LinkDirection dir = parseLinkDir(attrs.get<std::string>(SUMO_ATTR_DIR, 0, ok));
1162  LinkState state = parseLinkState(attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok));
1163  bool keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, 0, ok, true);
1164  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, 0, ok, "");
1165  std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, 0, ok, "");
1166 
1167  MSEdge* from = MSEdge::dictionary(fromID);
1168  if (from == 0) {
1169  WRITE_ERROR("Unknown from-edge '" + fromID + "' in connection");
1170  return;
1171  }
1172  MSEdge* to = MSEdge::dictionary(toID);
1173  if (to == 0) {
1174  WRITE_ERROR("Unknown to-edge '" + toID + "' in connection");
1175  return;
1176  }
1177  if (fromLaneIdx < 0 || fromLaneIdx >= (int)from->getLanes().size() ||
1178  toLaneIdx < 0 || toLaneIdx >= (int)to->getLanes().size()) {
1179  WRITE_ERROR("Invalid lane index in connection from '" + from->getID() + "' to '" + to->getID() + "'.");
1180  return;
1181  }
1182  MSLane* fromLane = from->getLanes()[fromLaneIdx];
1183  MSLane* toLane = to->getLanes()[toLaneIdx];
1184  assert(fromLane);
1185  assert(toLane);
1186 
1187  MSTrafficLightLogic* logic = 0;
1188  int tlLinkIdx = -1;
1189  if (tlID != "") {
1190  tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, 0, ok);
1191  // make sure that the index is in range
1193  if ((tlLinkIdx < 0 || tlLinkIdx >= (int)logic->getCurrentPhaseDef().getState().size())
1194  && logic->getLogicType() != "railSignal"
1195  && logic->getLogicType() != "railCrossing") {
1196  WRITE_ERROR("Invalid " + toString(SUMO_ATTR_TLLINKINDEX) + " '" + toString(tlLinkIdx) +
1197  "' in connection controlled by '" + tlID + "'");
1198  return;
1199  }
1200  if (!ok) {
1201  return;
1202  }
1203  }
1204  double length = fromLane->getShape()[-1].distanceTo(toLane->getShape()[0]);
1205 
1206  // build the link
1207  MSLane* via = 0;
1208  if (viaID != "" && MSGlobals::gUsingInternalLanes) {
1209  via = MSLane::dictionary(viaID);
1210  if (via == 0) {
1211  WRITE_ERROR("An unknown lane ('" + viaID +
1212  "') should be set as a via-lane for lane '" + toLane->getID() + "'.");
1213  return;
1214  }
1215  length = via->getLength();
1216  }
1217  link = new MSLink(fromLane, toLane, via, dir, state, length, foeVisibilityDistance, keepClear, logic, tlLinkIdx);
1218  if (via != 0) {
1219  via->addIncomingLane(fromLane, link);
1220  } else {
1221  toLane->addIncomingLane(fromLane, link);
1222  }
1223  toLane->addApproachingLane(fromLane, myNetworkVersion < 0.25);
1224 
1225  // if a traffic light is responsible for it, inform the traffic light
1226  // check whether this link is controlled by a traffic light
1227  // we can not reuse logic here because it might be an inactive one
1228  if (tlID != "") {
1229  myJunctionControlBuilder.getTLLogic(tlID).addLink(link, fromLane, tlLinkIdx);
1230  }
1231  // add the link
1232  fromLane->addLink(link);
1233 
1234  } catch (InvalidArgument& e) {
1235  WRITE_ERROR(e.what());
1236  }
1237 }
1238 
1239 
1241 NLHandler::parseLinkDir(const std::string& dir) {
1242  if (SUMOXMLDefinitions::LinkDirections.hasString(dir)) {
1244  } else {
1245  throw InvalidArgument("Unrecognised link direction '" + dir + "'.");
1246  }
1247 }
1248 
1249 
1250 LinkState
1251 NLHandler::parseLinkState(const std::string& state) {
1252  if (SUMOXMLDefinitions::LinkStates.hasString(state)) {
1253  return SUMOXMLDefinitions::LinkStates.get(state);
1254  } else {
1255  if (state == "t") { // legacy networks
1256  // WRITE_WARNING("Obsolete link state 't'. Use 'o' instead");
1258  } else {
1259  throw InvalidArgument("Unrecognised link state '" + state + "'.");
1260  }
1261  }
1262 }
1263 
1264 
1265 // ----------------------------------
1266 void
1268  if (myNetIsLoaded) {
1269  //WRITE_WARNING("POIs and Polygons should be loaded using option --po-files")
1270  return;
1271  }
1272  bool ok = true;
1274  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, 0, ok);
1275  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, 0, ok);
1276  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, 0, ok);
1277  if (ok) {
1278  Position networkOffset = s[0];
1279  GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
1280  if (OptionsCont::getOptions().getBool("fcd-output.geo") && !GeoConvHelper::getFinal().usingGeoProjection()) {
1281  WRITE_WARNING("no valid geo projection loaded from network. fcd-output.geo will not work");
1282  }
1283  }
1284 }
1285 
1286 
1287 void
1289  bool ok = true;
1290  myCurrentIsBroken = false;
1291  // get the id, report an error if not given or empty...
1292  myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1293  if (!ok) {
1294  myCurrentIsBroken = true;
1295  return;
1296  }
1297  try {
1299  if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) {
1300  delete sink;
1301  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists.");
1302  }
1303  sink->initialize(new std::vector<MSLane*>());
1305  if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) {
1306  delete source;
1307  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists.");
1308  }
1309  source->initialize(new std::vector<MSLane*>());
1310  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1311  std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES);
1312  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
1313  MSEdge* edge = MSEdge::dictionary(*i);
1314  // check whether the edge exists
1315  if (edge == 0) {
1316  throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known.");
1317  }
1318  source->addSuccessor(edge);
1319  edge->addSuccessor(sink);
1320  }
1321  }
1322  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
1324  if (shape.size() != 0) {
1325  if (!myNet.getShapeContainer().addPolygon(myCurrentDistrictID, "taz", RGBColor::parseColor("1.0,.33,.33"), 0, 0, "", shape, false)) {
1326  WRITE_WARNING("Skipping visualization of taz '" + myCurrentDistrictID + "', polygon already exists.");
1327  }
1328  }
1329  }
1330  } catch (InvalidArgument& e) {
1331  WRITE_ERROR(e.what());
1332  myCurrentIsBroken = true;
1333  }
1334 }
1335 
1336 
1337 void
1338 NLHandler::addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource) {
1339  if (myCurrentIsBroken) {
1340  // earlier error
1341  return;
1342  }
1343  bool ok = true;
1344  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentDistrictID.c_str(), ok);
1345  MSEdge* succ = MSEdge::dictionary(id);
1346  if (succ != 0) {
1347  // connect edge
1348  if (isSource) {
1349  MSEdge::dictionary(myCurrentDistrictID + "-source")->addSuccessor(succ);
1350  } else {
1351  succ->addSuccessor(MSEdge::dictionary(myCurrentDistrictID + "-sink"));
1352  }
1353  } else {
1354  WRITE_ERROR("At district '" + myCurrentDistrictID + "': succeeding edge '" + id + "' does not exist.");
1355  }
1356 }
1357 
1358 
1359 void
1361  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1362  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
1363  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
1364  MSEdge* edge = MSEdge::dictionary(*it);
1365  if (edge == 0) {
1366  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
1367  } else {
1368  edge->markAsRoundabout();
1369  }
1370  }
1371  } else {
1372  WRITE_ERROR("Empty edges in roundabout.");
1373  }
1374 }
1375 
1376 
1377 // ----------------------------------
1378 void
1380  try {
1382  } catch (InvalidArgument& e) {
1383  WRITE_ERROR(e.what());
1384  }
1385 }
1386 
1387 
1388 void
1390  if (!myCurrentIsBroken) {
1391  try {
1393  } catch (InvalidArgument& e) {
1394  WRITE_ERROR(e.what());
1395  myCurrentIsBroken = true;
1396  }
1397  }
1398  myCurrentWAUTID = "";
1399 }
1400 
1401 
1402 Position
1403 NLShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, double lanePos) {
1404  MSLane* lane = MSLane::dictionary(laneID);
1405  if (lane == 0) {
1406  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1407  return Position::INVALID;
1408  }
1409  if (lanePos < 0) {
1410  lanePos = lane->getLength() + lanePos;
1411  }
1412  return lane->geometryPositionAtOffset(lanePos);
1413 }
1414 /****************************************************************************/
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
void parseAndAddLotEntry(const SUMOSAXAttributes &attrs)
Parses his values and adds a lot entry to current parking area.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:67
void parseAndBuildCalibrator(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a mesoscopic or microscopic calibrator.
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:1062
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:594
Builds detectors for microsim.
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:877
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:168
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:301
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.h:323
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:548
bool myCurrentIsBroken
Definition: NLHandler.h:334
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:119
virtual MSEdge * buildEdge(const std::string &id, const MSEdge::EdgeBasicFunction function, const std::string &streetName, const std::string &edgeType, const int priority)
Builds an edge instance (MSEdge in this case)
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:48
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:201
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:833
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1360
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:305
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
The edge is a macroscopic connector (source/sink)
Definition: MSEdge.h:95
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1691
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:192
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:484
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:426
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:728
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:778
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:64
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:308
maximum duration of a phase
const std::string & getID() const
Returns the id.
Definition: Named.h:66
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
const std::string & getActiveSubKey() const
Returns the active sub key.
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:317
begin/end of the description of an edge restriction
EdgeBasicFunction
Defines possible edge types.
Definition: MSEdge.h:89
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:1379
void endE3Detector()
Builds of an e3 detector using collected values.
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:48
The purpose of the edge is not known.
Definition: MSEdge.h:91
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.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The simulated network and simulation perfomer.
Definition: MSNet.h:94
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
bool myAmInTLLogicMode
internal information whether a tls-logic is currently read
Definition: NLHandler.h:320
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:510
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:347
void closeWAUT()
Definition: NLHandler.cpp:1389
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:530
an edge based mean data detector
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1288
The state of a link.
static StringBijection< LinkDirection > LinkDirections
link directions
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:1701
A road/street connecting two junctions.
Definition: MSEdge.h:80
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1267
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:462
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:311
The edge is a district edge.
Definition: MSEdge.h:99
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:1086
Encapsulated SAX-Attributes.
An instantenous induction loop.
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:1099
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:433
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
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:575
JunctionGraph myJunctionGraph
Definition: NLHandler.h:360
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:615
void setPermissionsFound()
Labels the network to contain vehicle class permissions.
Definition: MSNet.h:183
T get(const std::string &str) const
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.
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:1147
std::string myCurrentTypeID
The id of the currently processed edge type.
Definition: NLHandler.h:326
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:288
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
edge: the shape in xml-definition
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:341
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1241
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...
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: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:323
The edge is a pedestrian walking area (a special type of internal edge)
Definition: MSEdge.h:103
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:1371
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:807
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:397
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:853
A train stop (alias for bus stop)
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:413
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:344
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:308
double myNetworkVersion
the loaded network version
Definition: NLHandler.h:353
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
The edge is a normal street.
Definition: MSEdge.h:93
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:356
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.
The edge is a pedestrian crossing (a special type of internal edge)
Definition: MSEdge.h:101
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: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:687
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:448
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1338
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:213
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:1251
The abstract direction of a link.
void setJunctions(MSJunction *from, MSJunction *to)
Definition: MSEdge.h:377
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.
void beginEdgeParsing(const std::string &id, const MSEdge::EdgeBasicFunction function, const std::string &streetName, const std::string &edgeType, int priority)
Begins building of an MSEdge.
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:298
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: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:246
MSTrafficLightLogic * getActive() const
void markAsRoundabout()
Definition: MSEdge.h:640
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:1112
Builds trigger objects for microsim.
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:640
The edge is an internal edge.
Definition: MSEdge.h:97
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:350
Parameterised * myLastParameterised
Definition: NLHandler.h:338
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.
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:314
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:654
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.
Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos)
get position for a given laneID
Definition: NLHandler.cpp:1403