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