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