SUMO - Simulation of Urban MObility
NLHandler.cpp
Go to the documentation of this file.
1 /****************************************************************************/
12 // The XML-Handler for network loading
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
15 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include "NLHandler.h"
36 #include "NLEdgeControlBuilder.h"
38 #include "NLDetectorBuilder.h"
39 #include "NLTriggerBuilder.h"
43 #include <utils/common/SUMOTime.h>
46 #include <utils/common/RGBColor.h>
48 #include <microsim/MSGlobals.h>
49 #include <microsim/MSLane.h>
50 #include <microsim/MSJunction.h>
57 #include <utils/shapes/Shape.h>
59 
60 #ifdef CHECK_MEMORY_LEAKS
61 #include <foreign/nvwa/debug_new.h>
62 #endif // CHECK_MEMORY_LEAKS
63 
64 
65 // ===========================================================================
66 // method definitions
67 // ===========================================================================
68 NLHandler::NLHandler(const std::string& file, MSNet& net,
69  NLDetectorBuilder& detBuilder,
70  NLTriggerBuilder& triggerBuilder,
71  NLEdgeControlBuilder& edgeBuilder,
72  NLJunctionControlBuilder& junctionBuilder) :
73  MSRouteHandler(file, true),
74  myNet(net), myActionBuilder(net),
75  myCurrentIsInternalToSkip(false),
76  myDetectorBuilder(detBuilder), myTriggerBuilder(triggerBuilder),
77  myEdgeControlBuilder(edgeBuilder), myJunctionControlBuilder(junctionBuilder),
78  myAmInTLLogicMode(false), myCurrentIsBroken(false),
79  myHaveWarnedAboutDeprecatedLanes(false),
80  myLastParameterised(0),
81  myHaveSeenInternalEdge(false),
82  myHaveSeenNeighs(false),
83  myLefthand(false),
84  myNetworkVersion(0),
85  myNetIsLoaded(false) {
86 }
87 
88 
90 
91 
92 void
94  const SUMOSAXAttributes& attrs) {
95  try {
96  switch (element) {
97  case SUMO_TAG_NET: {
98  bool ok;
99  myLefthand = attrs.getOpt<bool>(SUMO_ATTR_LEFTHAND, 0, ok, false);
100  myNetworkVersion = attrs.get<SUMOReal>(SUMO_ATTR_VERSION, 0, ok, false);
101  break;
102  }
103  case SUMO_TAG_EDGE:
104  beginEdgeParsing(attrs);
105  break;
106  case SUMO_TAG_LANE:
107  addLane(attrs);
108  break;
109  case SUMO_TAG_NEIGH:
111  myHaveSeenNeighs = true;
112  break;
113  case SUMO_TAG_JUNCTION:
114  openJunction(attrs);
115  initJunctionLogic(attrs);
116  break;
117  case SUMO_TAG_PHASE:
118  addPhase(attrs);
119  break;
120  case SUMO_TAG_CONNECTION:
121  addConnection(attrs);
122  break;
123  case SUMO_TAG_TLLOGIC:
124  initTrafficLightLogic(attrs);
125  break;
126  case SUMO_TAG_REQUEST:
127  addRequest(attrs);
128  break;
129  case SUMO_TAG_WAUT:
130  openWAUT(attrs);
131  break;
133  addWAUTSwitch(attrs);
134  break;
136  addWAUTJunction(attrs);
137  break;
138  case SUMO_TAG_E1DETECTOR:
140  addE1Detector(attrs);
141  break;
142  case SUMO_TAG_E2DETECTOR:
144  addE2Detector(attrs);
145  break;
146  case SUMO_TAG_E3DETECTOR:
148  beginE3Detector(attrs);
149  break;
150  case SUMO_TAG_DET_ENTRY:
151  addE3Entry(attrs);
152  break;
153  case SUMO_TAG_DET_EXIT:
154  addE3Exit(attrs);
155  break;
157  addInstantE1Detector(attrs);
158  break;
159  case SUMO_TAG_VSS:
161  break;
162  case SUMO_TAG_CALIBRATOR:
164  break;
165  case SUMO_TAG_REROUTER:
167  break;
168  case SUMO_TAG_BUS_STOP:
169  case SUMO_TAG_TRAIN_STOP:
172  break;
175  break;
178  break;
179  case SUMO_TAG_ACCESS:
181  break;
184  break;
185  case SUMO_TAG_VTYPEPROBE:
186  addVTypeProbeDetector(attrs);
187  break;
188  case SUMO_TAG_ROUTEPROBE:
189  addRouteProbeDetector(attrs);
190  break;
193  break;
196  break;
197  case SUMO_TAG_TIMEDEVENT:
199  break;
200  case SUMO_TAG_VAPORIZER:
202  break;
203  case SUMO_TAG_LOCATION:
204  setLocation(attrs);
205  break;
206  case SUMO_TAG_TAZ:
207  addDistrict(attrs);
208  break;
209  case SUMO_TAG_TAZSOURCE:
210  addDistrictEdge(attrs, true);
211  break;
212  case SUMO_TAG_TAZSINK:
213  addDistrictEdge(attrs, false);
214  break;
215  case SUMO_TAG_ROUNDABOUT:
216  addRoundabout(attrs);
217  break;
218  case SUMO_TAG_TYPE: {
219  bool ok = true;
220  myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
221  break;
222  }
223  case SUMO_TAG_RESTRICTION: {
224  bool ok = true;
225  const SUMOVehicleClass svc = getVehicleClassID(attrs.get<std::string>(SUMO_ATTR_VCLASS, myCurrentTypeID.c_str(), ok));
226  const SUMOReal speed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, myCurrentTypeID.c_str(), ok);
227  if (ok) {
228  myNet.addRestriction(myCurrentTypeID, svc, speed);
229  }
230  break;
231  }
232  default:
233  break;
234  }
235  } catch (InvalidArgument& e) {
236  WRITE_ERROR(e.what());
237  }
238  MSRouteHandler::myStartElement(element, attrs);
239  if (element == SUMO_TAG_PARAM) {
240  addParam(attrs);
241  }
242 }
243 
244 
245 void
247  switch (element) {
248  case SUMO_TAG_EDGE:
249  closeEdge();
250  break;
251  case SUMO_TAG_JUNCTION:
252  if (!myCurrentIsBroken) {
253  try {
256  } catch (InvalidArgument& e) {
257  WRITE_ERROR(e.what());
258  }
259  }
260  break;
261  case SUMO_TAG_TLLOGIC:
262  try {
264  } catch (InvalidArgument& e) {
265  WRITE_ERROR(e.what());
266  }
267  myAmInTLLogicMode = false;
268  break;
269  case SUMO_TAG_WAUT:
270  closeWAUT();
271  break;
272  case SUMO_TAG_E3DETECTOR:
274  endE3Detector();
275  break;
278  break;
279  case SUMO_TAG_NET:
280  // build junction graph
281  for (JunctionGraph::iterator it = myJunctionGraph.begin(); it != myJunctionGraph.end(); ++it) {
282  MSEdge* edge = MSEdge::dictionary(it->first);
283  MSJunction* from = myJunctionControlBuilder.retrieve(it->second.first);
284  MSJunction* to = myJunctionControlBuilder.retrieve(it->second.second);
285  if (edge != 0 && from != 0 && to != 0) {
286  edge->setJunctions(from, to);
287  from->addOutgoing(edge);
288  to->addIncoming(edge);
289  }
290  }
291  myNetIsLoaded = true;
292  break;
293  default:
294  break;
295  }
297  if (element != SUMO_TAG_PARAM) {
299  }
300 }
301 
302 
303 
304 // ---- the root/edge - element
305 void
307  bool ok = true;
308  myCurrentIsBroken = false;
309  // get the id, report an error if not given or empty...
310  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
311  if (!ok) {
312  myCurrentIsBroken = true;
313  return;
314  }
315  // omit internal edges if not wished
316  if (id[0] == ':') {
317  myHaveSeenInternalEdge = true;
320  return;
321  }
322  }
323  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
324  myJunctionGraph[id] = std::make_pair(
325  attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok),
326  attrs.get<std::string>(SUMO_ATTR_TO, 0, ok));
327  } else {
328  // must be an internal edge
329  std::string junctionID = SUMOXMLDefinitions::getJunctionIDFromInternalEdge(id);
330  myJunctionGraph[id] = std::make_pair(junctionID, junctionID);
331  }
333  // parse the function
334  const SumoXMLEdgeFunc func = attrs.getEdgeFunc(ok);
335  if (!ok) {
336  WRITE_ERROR("Edge '" + id + "' has an invalid type.");
337  myCurrentIsBroken = true;
338  return;
339  }
340  // interpret the function
342  switch (func) {
343  case EDGEFUNC_NORMAL:
344  funcEnum = MSEdge::EDGEFUNCTION_NORMAL;
345  break;
346  case EDGEFUNC_CONNECTOR:
347  case EDGEFUNC_SINK:
348  case EDGEFUNC_SOURCE:
350  break;
351  case EDGEFUNC_INTERNAL:
353  break;
354  case EDGEFUNC_CROSSING:
356  break;
359  break;
360  }
361  // get the street name
362  const std::string streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
363  // get the edge type
364  const std::string edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
365  // get the edge priority (only for visualization)
366  const int priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1); // default taken from netbuild/NBFrame option 'default.priority'
367  if (!ok) {
368  myCurrentIsBroken = true;
369  return;
370  }
371  //
372  try {
373  myEdgeControlBuilder.beginEdgeParsing(id, funcEnum, streetName, edgeType, priority);
374  } catch (InvalidArgument& e) {
375  WRITE_ERROR(e.what());
376  myCurrentIsBroken = true;
377  }
378 
379  if (funcEnum == MSEdge::EDGEFUNCTION_CROSSING) {
380  //get the crossingEdges attribute (to implement the other side of the road pushbutton)
381  const std::string crossingEdges = attrs.getOpt<std::string>(SUMO_ATTR_CROSSING_EDGES, id.c_str(), ok, "");
382  if (!crossingEdges.empty()) {
383  std::vector<std::string> crossingEdgesVector;
384  StringTokenizer edges(crossingEdges);
385  while (edges.hasNext()) {
386  crossingEdgesVector.push_back(edges.next());
387  }
388  myEdgeControlBuilder.addCrossingEdges(crossingEdgesVector);
389  }
390  }
391 }
392 
393 
394 void
396  // omit internal edges if not wished and broken edges
398  return;
399  }
400  try {
402  MSEdge::dictionary(e->getID(), e);
403  } catch (InvalidArgument& e) {
404  WRITE_ERROR(e.what());
405  }
406 }
407 
408 
409 // ---- the root/edge/lanes/lane - element
410 void
412  // omit internal edges if not wished and broken edges
414  return;
415  }
416  bool ok = true;
417  // get the id, report an error if not given or empty...
418  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
419  if (!ok) {
420  myCurrentIsBroken = true;
421  return;
422  }
423  const SUMOReal maxSpeed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, id.c_str(), ok);
424  const SUMOReal length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, id.c_str(), ok);
425  const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "", false);
426  const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
427  const SUMOReal width = attrs.getOpt<SUMOReal>(SUMO_ATTR_WIDTH, id.c_str(), ok, SUMO_const_laneWidth);
428  const PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
429  const int index = attrs.get<int>(SUMO_ATTR_INDEX, id.c_str(), ok);
430  if (shape.size() < 2) {
431  WRITE_ERROR("Shape of lane '" + id + "' is broken.\n Can not build according edge.");
432  myCurrentIsBroken = true;
433  return;
434  }
435  const SVCPermissions permissions = parseVehicleClasses(allow, disallow);
436  if (permissions != SVCAll) {
438  }
439  myCurrentIsBroken |= !ok;
440  if (!myCurrentIsBroken) {
441  try {
442  MSLane* lane = myEdgeControlBuilder.addLane(id, maxSpeed, length, shape, width, permissions, index);
443  // insert the lane into the lane-dictionary, checking
444  if (!MSLane::dictionary(id, lane)) {
445  delete lane;
446  WRITE_ERROR("Another lane with the id '" + id + "' exists.");
447  myCurrentIsBroken = true;
448  }
449  myLastParameterised = lane;
450  } catch (InvalidArgument& e) {
451  WRITE_ERROR(e.what());
452  }
453  }
454 }
455 
456 
457 // ---- the root/junction - element
458 void
460  myCurrentIsBroken = false;
461  bool ok = true;
462  // get the id, report an error if not given or empty...
463  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
464  if (!ok) {
465  myCurrentIsBroken = true;
466  return;
467  }
468  PositionVector shape;
469  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
470  // inner junctions have no shape
471  shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok, PositionVector());
472  if (shape.size() > 2) {
473  shape.closePolygon();
474  }
475  }
476  SUMOReal x = attrs.get<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok);
477  SUMOReal y = attrs.get<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok);
478  bool typeOK = true;
479  SumoXMLNodeType type = attrs.getNodeType(typeOK);
480  if (!typeOK) {
481  WRITE_ERROR("An unknown or invalid junction type occured in junction '" + id + "'.");
482  ok = false;
483  }
484  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_KEY, id.c_str(), ok, "");
485  // incoming lanes
486  std::vector<MSLane*> incomingLanes;
487  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INCLANES, ""), incomingLanes, ok);
488  // internal lanes
489  std::vector<MSLane*> internalLanes;
490 #ifdef HAVE_INTERNAL_LANES
492  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INTLANES, ""), internalLanes, ok);
493  }
494 #endif
495  if (!ok) {
496  myCurrentIsBroken = true;
497  } else {
498  try {
499  myJunctionControlBuilder.openJunction(id, key, type, x, y, shape, incomingLanes, internalLanes);
500  } catch (InvalidArgument& e) {
501  WRITE_ERROR(e.what() + std::string("\n Can not build according junction."));
502  myCurrentIsBroken = true;
503  }
504  }
505 }
506 
507 
508 void
509 NLHandler::parseLanes(const std::string& junctionID,
510  const std::string& def, std::vector<MSLane*>& into, bool& ok) {
511  StringTokenizer st(def);
512  while (ok && st.hasNext()) {
513  std::string laneID = st.next();
514  MSLane* lane = MSLane::dictionary(laneID);
515  if (!MSGlobals::gUsingInternalLanes && laneID[0] == ':') {
516  continue;
517  }
518  if (lane == 0) {
519  WRITE_ERROR("An unknown lane ('" + laneID + "') was tried to be set as incoming to junction '" + junctionID + "'.");
520  ok = false;
521  continue;
522  }
523  into.push_back(lane);
524  }
525 }
526 // ----
527 
528 void
530  bool ok = true;
531  const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, 0, ok);
532  // circumventing empty string test
533  const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
534  if (myLastParameterised != 0) {
536  }
537  // set
538  if (ok && myAmInTLLogicMode) {
539  assert(key != "");
540  assert(val != "");
542  }
543 }
544 
545 
546 void
548  myCurrentIsBroken = false;
549  bool ok = true;
550  // get the id, report an error if not given or empty...
551  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
552  if (!ok) {
553  myCurrentIsBroken = true;
554  return;
555  }
556  SUMOTime t = attrs.getOptSUMOTimeReporting(SUMO_ATTR_REF_TIME, id.c_str(), ok, 0);
557  std::string pro = attrs.get<std::string>(SUMO_ATTR_START_PROG, id.c_str(), ok);
558  if (!ok) {
559  myCurrentIsBroken = true;
560  }
561  if (!myCurrentIsBroken) {
562  myCurrentWAUTID = id;
563  try {
565  } catch (InvalidArgument& e) {
566  WRITE_ERROR(e.what());
567  myCurrentIsBroken = true;
568  }
569  }
570 }
571 
572 
573 void
575  bool ok = true;
577  std::string to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentWAUTID.c_str(), ok);
578  if (!ok) {
579  myCurrentIsBroken = true;
580  }
581  if (!myCurrentIsBroken) {
582  try {
584  } catch (InvalidArgument& e) {
585  WRITE_ERROR(e.what());
586  myCurrentIsBroken = true;
587  }
588  }
589 }
590 
591 
592 void
594  bool ok = true;
595  std::string wautID = attrs.get<std::string>(SUMO_ATTR_WAUT_ID, 0, ok);
596  std::string junctionID = attrs.get<std::string>(SUMO_ATTR_JUNCTION_ID, 0, ok);
597  std::string procedure = attrs.getOpt<std::string>(SUMO_ATTR_PROCEDURE, 0, ok, "");
598  bool synchron = attrs.getOpt<bool>(SUMO_ATTR_SYNCHRON, 0, ok, false);
599  if (!ok) {
600  myCurrentIsBroken = true;
601  }
602  try {
603  if (!myCurrentIsBroken) {
604  myJunctionControlBuilder.getTLLogicControlToUse().addWAUTJunction(wautID, junctionID, procedure, synchron);
605  }
606  } catch (InvalidArgument& e) {
607  WRITE_ERROR(e.what());
608  myCurrentIsBroken = true;
609  }
610 }
611 
612 
613 void
615  if (myCurrentIsBroken) {
616  return;
617  }
618  bool ok = true;
619  int request = attrs.get<int>(SUMO_ATTR_INDEX, 0, ok);
620  bool cont = false;
621 #ifdef HAVE_INTERNAL_LANES
622  cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, 0, ok, false);
623 #endif
624  std::string response = attrs.get<std::string>(SUMO_ATTR_RESPONSE, 0, ok);
625  std::string foes = attrs.get<std::string>(SUMO_ATTR_FOES, 0, ok);
626  if (!ok) {
627  return;
628  }
629  // store received information
630  if (request >= 0 && response.length() > 0) {
631  try {
632  myJunctionControlBuilder.addLogicItem(request, response, foes, cont);
633  } catch (InvalidArgument& e) {
634  WRITE_ERROR(e.what());
635  }
636  }
637 }
638 
639 
640 void
642  if (myCurrentIsBroken) {
643  return;
644  }
645  bool ok = true;
646  // we either a have a junction or a legacy network with ROWLogic
647  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
648  if (ok) {
650  }
651 }
652 
653 
654 void
656  myAmInTLLogicMode = true;
657  bool ok = true;
658  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
659  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
661  std::string typeS;
662  if (myJunctionControlBuilder.getTLLogicControlToUse().get(id, programID) == 0) {
663  // SUMO_ATTR_TYPE is not needed when only modifying the offst of an
664  // existing program
665  typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
666  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
668  } else {
669  WRITE_ERROR("Traffic light '" + id + "' has unknown type '" + typeS + "'");
670  }
671  }
672  //
673  SUMOTime offset = attrs.getOptSUMOTimeReporting(SUMO_ATTR_OFFSET, id.c_str(), ok, 0);
674  if (!ok) {
675  return;
676  }
677  myJunctionControlBuilder.initTrafficLightLogic(id, programID, type, offset);
678 }
679 
680 
681 void
683  // try to get the phase definition
684  bool ok = true;
685  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok);
686  if (!ok) {
687  return;
688  }
689  // try to get the phase duration
691  if (duration == 0) {
693  + " for tlLogic '" + myJunctionControlBuilder.getActiveKey()
694  + "' program '" + myJunctionControlBuilder.getActiveSubKey() + "' is zero.");
695  return;
696  }
697  // if the traffic light is an actuated traffic light, try to get
698  // the minimum and maximum durations
699  SUMOTime minDuration = attrs.getOptSUMOTimeReporting(
701  SUMOTime maxDuration = attrs.getOptSUMOTimeReporting(
703 
704 
705  //SOTL attributes
706  //If the type attribute is not present, the parsed phase is of type "undefined" (MSPhaseDefinition constructor),
707  //in this way SOTL traffic light logic can recognize the phase as unsuitable or decides other
708  //behaviors. See SOTL traffic light logic implementations.
709  if (attrs.hasAttribute(SUMO_ATTR_TYPE)) {
710  bool ok = true;
711  std::string phaseTypeString;
712  bool transient_notdecisional_bit;
713  bool commit_bit;
714  MSPhaseDefinition::LaneIdVector laneIdVector;
715  try {
716  phaseTypeString = attrs.get<std::string>(SUMO_ATTR_TYPE, "phase", ok, false);
717  } catch (EmptyData&) {
718  MsgHandler::getWarningInstance()->inform("Empty type definition. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
719  transient_notdecisional_bit = false;
720  }
721  if (phaseTypeString.find("decisional") != std::string::npos) {
722  transient_notdecisional_bit = false;
723  } else if (phaseTypeString.find("transient") != std::string::npos) {
724  transient_notdecisional_bit = true;
725  } else {
726  MsgHandler::getWarningInstance()->inform("SOTL_ATTL_TYPE_DECISIONAL nor SOTL_ATTL_TYPE_TRANSIENT. Assuming phase type as SUMOSOTL_TagAttrDefinitions::SOTL_ATTL_TYPE_TRANSIENT");
727  transient_notdecisional_bit = false;
728  }
729  commit_bit = (phaseTypeString.find("commit") != std::string::npos);
730 
731  if (phaseTypeString.find("target") != std::string::npos) {
732  std::string delimiter(" ,;");
733  //Phase declared as target, getting targetLanes attribute
734  try {
736  std::string targetLanesString = attrs.getStringSecure(SUMO_ATTR_TARGETLANE, "");
737  //TOKENIZING
738  MSPhaseDefinition::LaneIdVector targetLanesVector;
739  //Skip delimiters at the beginning
740  std::string::size_type firstPos = targetLanesString.find_first_not_of(delimiter, 0);
741  //Find first "non-delimiter".
742  std::string::size_type pos = targetLanesString.find_first_of(delimiter, firstPos);
743 
744  while (std::string::npos != pos || std::string::npos != firstPos) {
745  //Found a token, add it to the vector
746  targetLanesVector.push_back(targetLanesString.substr(firstPos, pos - firstPos));
747 
748  //Skip delimiters
749  firstPos = targetLanesString.find_first_not_of(delimiter, pos);
750 
751  //Find next "non-delimiter"
752  pos = targetLanesString.find_first_of(delimiter, firstPos);
753  }
754  //Adding the SOTL parsed phase to have a new MSPhaseDefinition that is SOTL compliant for target phases
755  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration, transient_notdecisional_bit, commit_bit, targetLanesVector);
756  } catch (EmptyData&) {
757  MsgHandler::getErrorInstance()->inform("Missing targetLane definition for the target phase.");
758  return;
759  }
760  } else {
761  //Adding the SOTL parsed phase to have a new MSPhaseDefinition that is SOTL compliant for non target phases
762  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration, transient_notdecisional_bit, commit_bit);
763  }
764  } else {
765  //Adding the standard parsed phase to have a new MSPhaseDefinition
766 
767  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration);
768  }
769 }
770 
771 
772 void
774  bool ok = true;
775  // get the id, report an error if not given or empty...
776  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
777  if (!ok) {
778  return;
779  }
780  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
781  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
782  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
783  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
784  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
785  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
786  if (!ok) {
787  return;
788  }
789  try {
790  myDetectorBuilder.buildInductLoop(id, lane, position, frequency,
792  friendlyPos, vTypes);
793  } catch (InvalidArgument& e) {
794  WRITE_ERROR(e.what());
795  } catch (IOError& e) {
796  WRITE_ERROR(e.what());
797  }
798 }
799 
800 
801 void
803  bool ok = true;
804  // get the id, report an error if not given or empty...
805  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
806  if (!ok) {
807  return;
808  }
809  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
810  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
811  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
812  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
813  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
814  if (!ok) {
815  return;
816  }
817  try {
818  myDetectorBuilder.buildInstantInductLoop(id, lane, position, FileHelpers::checkForRelativity(file, getFileName()), friendlyPos, vTypes);
819  } catch (InvalidArgument& e) {
820  WRITE_ERROR(e.what());
821  } catch (IOError& e) {
822  WRITE_ERROR(e.what());
823  }
824 }
825 
826 
827 void
829  bool ok = true;
830  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
831  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
832  std::string type = attrs.getStringSecure(SUMO_ATTR_TYPE, "");
833  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
834  if (!ok) {
835  return;
836  }
837  try {
839  } catch (InvalidArgument& e) {
840  WRITE_ERROR(e.what());
841  } catch (IOError& e) {
842  WRITE_ERROR(e.what());
843  }
844 }
845 
846 
847 void
849  bool ok = true;
850  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
851  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
852  SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, -1);
853  std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
854  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
855  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
856  if (!ok) {
857  return;
858  }
859  try {
860  myDetectorBuilder.buildRouteProbe(id, edge, frequency, begin,
862  } catch (InvalidArgument& e) {
863  WRITE_ERROR(e.what());
864  } catch (IOError& e) {
865  WRITE_ERROR(e.what());
866  }
867 }
868 
869 
870 
871 void
873  // check whether this is a detector connected to a tls an optionally to a link
874  bool ok = true;
875  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
876  const std::string lsaid = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), ok, "<invalid>");
877  const std::string toLane = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "<invalid>");
878  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
879  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
880  const SUMOReal jamDistThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, 10.0f);
881  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
882  const SUMOReal length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, id.c_str(), ok);
883  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
884  const bool cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, id.c_str(), ok, false);
885  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
886  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
887  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
888  if (!ok) {
889  return;
890  }
891  try {
892  if (lsaid != "<invalid>") {
893  if (toLane == "<invalid>") {
894  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont,
897  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
898  friendlyPos, vTypes);
899  } else {
900  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont,
901  myJunctionControlBuilder.getTLLogic(lsaid), toLane,
903  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
904  friendlyPos, vTypes);
905  }
906  } else {
907  bool ok = true;
908  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
909  if (!ok) {
910  return;
911  }
912  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont, frequency,
914  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
915  friendlyPos, vTypes);
916  }
917  } catch (InvalidArgument& e) {
918  WRITE_ERROR(e.what());
919  } catch (IOError& e) {
920  WRITE_ERROR(e.what());
921  }
922 }
923 
924 
925 void
927  bool ok = true;
928  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
929  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
930  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
931  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
932  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
933  const std::string vTypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
934  if (!ok) {
935  return;
936  }
937  try {
940  frequency, haltingSpeedThreshold, haltingTimeThreshold, vTypes);
941  } catch (InvalidArgument& e) {
942  WRITE_ERROR(e.what());
943  } catch (IOError& e) {
944  WRITE_ERROR(e.what());
945  }
946 }
947 
948 
949 void
951  bool ok = true;
952  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
953  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
954  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
955  if (!ok) {
956  return;
957  }
958  myDetectorBuilder.addE3Entry(lane, position, friendlyPos);
959 }
960 
961 
962 void
964  bool ok = true;
965  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
966  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
967  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
968  if (!ok) {
969  return;
970  }
971  myDetectorBuilder.addE3Exit(lane, position, friendlyPos);
972 }
973 
974 
975 void
976 NLHandler::addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype) {
977  bool ok = true;
978  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
979  const SUMOReal maxTravelTime = attrs.getOpt<SUMOReal>(SUMO_ATTR_MAX_TRAVELTIME, id.c_str(), ok, 100000);
980  const SUMOReal minSamples = attrs.getOpt<SUMOReal>(SUMO_ATTR_MIN_SAMPLES, id.c_str(), ok, 0);
981  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, POSITION_EPS);
982  const std::string excludeEmpty = attrs.getOpt<std::string>(SUMO_ATTR_EXCLUDE_EMPTY, id.c_str(), ok, "false");
983  const bool withInternal = attrs.getOpt<bool>(SUMO_ATTR_WITH_INTERNAL, id.c_str(), ok, false);
984  const bool trackVehicles = attrs.getOpt<bool>(SUMO_ATTR_TRACK_VEHICLES, id.c_str(), ok, false);
985  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
986  const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "performance");
987  std::string vtypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
988  const SUMOTime frequency = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, -1);
989  const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("begin")));
990  const SUMOTime end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("end")));
991  if (!ok) {
992  return;
993  }
994  try {
995  myDetectorBuilder.createEdgeLaneMeanData(id, frequency, begin, end,
996  type, objecttype == SUMO_TAG_MEANDATA_LANE,
997  // equivalent to TplConvert::_2bool used in SUMOSAXAttributes::getBool
998  excludeEmpty[0] != 't' && excludeEmpty[0] != 'T' && excludeEmpty[0] != '1' && excludeEmpty[0] != 'x',
999  excludeEmpty == "defaults", withInternal, trackVehicles,
1000  maxTravelTime, minSamples, haltingSpeedThreshold, vtypes,
1002  } catch (InvalidArgument& e) {
1003  WRITE_ERROR(e.what());
1004  } catch (IOError& e) {
1005  WRITE_ERROR(e.what());
1006  }
1007 }
1008 
1009 
1010 void
1012  bool ok = true;
1013  std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
1014  if (!MSGlobals::gUsingInternalLanes && fromID[0] == ':') {
1015  return;
1016  }
1017 
1018  MSLink* link = 0;
1019  try {
1020  bool ok = true;
1021  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
1022  const int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, 0, ok);
1023  const SUMOReal foeVisibilityDistance = attrs.getOpt<SUMOReal>(SUMO_ATTR_VISIBILITY_DISTANCE, 0, ok, 4.5);
1024  const int toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, 0, ok);
1025  LinkDirection dir = parseLinkDir(attrs.get<std::string>(SUMO_ATTR_DIR, 0, ok));
1026  LinkState state = parseLinkState(attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok));
1027  bool keepClear = attrs.getOpt<bool>(SUMO_ATTR_KEEP_CLEAR, 0, ok, true);
1028  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, 0, ok, "");
1029 #ifdef HAVE_INTERNAL_LANES
1030  std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, 0, ok, "");
1031 #endif
1032 
1033  MSEdge* from = MSEdge::dictionary(fromID);
1034  if (from == 0) {
1035  WRITE_ERROR("Unknown from-edge '" + fromID + "' in connection");
1036  return;
1037  }
1038  MSEdge* to = MSEdge::dictionary(toID);
1039  if (to == 0) {
1040  WRITE_ERROR("Unknown to-edge '" + toID + "' in connection");
1041  return;
1042  }
1043  if (fromLaneIdx < 0 || fromLaneIdx >= (int)from->getLanes().size() ||
1044  toLaneIdx < 0 || toLaneIdx >= (int)to->getLanes().size()) {
1045  WRITE_ERROR("Invalid lane index in connection from '" + from->getID() + "' to '" + to->getID() + "'.");
1046  return;
1047  }
1048  MSLane* fromLane = from->getLanes()[fromLaneIdx];
1049  MSLane* toLane = to->getLanes()[toLaneIdx];
1050  assert(fromLane);
1051  assert(toLane);
1052 
1053  MSTrafficLightLogic* logic = 0;
1054  int tlLinkIdx = -1;
1055  if (tlID != "") {
1056  tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, 0, ok);
1057  // make sure that the index is in range
1059  if ((tlLinkIdx < 0 || tlLinkIdx >= (int)logic->getCurrentPhaseDef().getState().size())
1060  && logic->getLogicType() != "railSignal"
1061  && logic->getLogicType() != "railCrossing") {
1062  WRITE_ERROR("Invalid " + toString(SUMO_ATTR_TLLINKINDEX) + " '" + toString(tlLinkIdx) +
1063  "' in connection controlled by '" + tlID + "'");
1064  return;
1065  }
1066  if (!ok) {
1067  return;
1068  }
1069  }
1070  SUMOReal length = fromLane->getShape()[-1].distanceTo(toLane->getShape()[0]);
1071 
1072  // build the link
1073 #ifdef HAVE_INTERNAL_LANES
1074  MSLane* via = 0;
1075  if (viaID != "" && MSGlobals::gUsingInternalLanes) {
1076  via = MSLane::dictionary(viaID);
1077  if (via == 0) {
1078  WRITE_ERROR("An unknown lane ('" + viaID +
1079  "') should be set as a via-lane for lane '" + toLane->getID() + "'.");
1080  return;
1081  }
1082  length = via->getLength();
1083  }
1084  link = new MSLink(fromLane, toLane, via, dir, state, length, foeVisibilityDistance, keepClear, logic, tlLinkIdx);
1085  if (via != 0) {
1086  via->addIncomingLane(fromLane, link);
1087  } else {
1088  toLane->addIncomingLane(fromLane, link);
1089  }
1090 #else
1091  link = new MSLink(fromLane, toLane, dir, state, length, foeVisibilityDistance, keepClear, logic, tlLinkIdx);
1092  toLane->addIncomingLane(fromLane, link);
1093 #endif
1094  toLane->addApproachingLane(fromLane, myNetworkVersion < 0.25);
1095 
1096  // if a traffic light is responsible for it, inform the traffic light
1097  // check whether this link is controlled by a traffic light
1098  // we can not reuse logic here because it might be an inactive one
1099  if (tlID != "") {
1100  myJunctionControlBuilder.getTLLogic(tlID).addLink(link, fromLane, tlLinkIdx);
1101  }
1102  // add the link
1103  fromLane->addLink(link);
1104 
1105  } catch (InvalidArgument& e) {
1106  WRITE_ERROR(e.what());
1107  }
1108 }
1109 
1110 
1112 NLHandler::parseLinkDir(const std::string& dir) {
1113  if (SUMOXMLDefinitions::LinkDirections.hasString(dir)) {
1115  } else {
1116  throw InvalidArgument("Unrecognised link direction '" + dir + "'.");
1117  }
1118 }
1119 
1120 
1121 LinkState
1122 NLHandler::parseLinkState(const std::string& state) {
1123  if (SUMOXMLDefinitions::LinkStates.hasString(state)) {
1124  return SUMOXMLDefinitions::LinkStates.get(state);
1125  } else {
1126  if (state == "t") { // legacy networks
1127  // WRITE_WARNING("Obsolete link state 't'. Use 'o' instead");
1129  } else {
1130  throw InvalidArgument("Unrecognised link state '" + state + "'.");
1131  }
1132  }
1133 }
1134 
1135 
1136 // ----------------------------------
1137 void
1139  if (myNetIsLoaded) {
1140  //WRITE_WARNING("POIs and Polygons should be loaded using option --po-files")
1141  return;
1142  }
1143  bool ok = true;
1145  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, 0, ok);
1146  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, 0, ok);
1147  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, 0, ok);
1148  if (ok) {
1149  Position networkOffset = s[0];
1150  GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
1151  if (OptionsCont::getOptions().getBool("fcd-output.geo") && !GeoConvHelper::getFinal().usingGeoProjection()) {
1152  WRITE_WARNING("no valid geo projection loaded from network. fcd-output.geo will not work");
1153  }
1154  }
1155 }
1156 
1157 
1158 void
1160  bool ok = true;
1161  myCurrentIsBroken = false;
1162  // get the id, report an error if not given or empty...
1163  myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1164  if (!ok) {
1165  myCurrentIsBroken = true;
1166  return;
1167  }
1168  try {
1170  if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) {
1171  delete sink;
1172  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists.");
1173  }
1174  sink->initialize(new std::vector<MSLane*>());
1176  if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) {
1177  delete source;
1178  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists.");
1179  }
1180  source->initialize(new std::vector<MSLane*>());
1181  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1182  std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES);
1183  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
1184  MSEdge* edge = MSEdge::dictionary(*i);
1185  // check whether the edge exists
1186  if (edge == 0) {
1187  throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known.");
1188  }
1189  source->addSuccessor(edge);
1190  edge->addSuccessor(sink);
1191  }
1192  }
1193  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
1195  if (shape.size() != 0) {
1196  if (!myNet.getShapeContainer().addPolygon(myCurrentDistrictID, "taz", RGBColor::parseColor("1.0,.33,.33"), 0, 0, "", shape, false)) {
1197  WRITE_WARNING("Skipping visualization of taz '" + myCurrentDistrictID + "', polygon already exists.");
1198  }
1199  }
1200  }
1201  } catch (InvalidArgument& e) {
1202  WRITE_ERROR(e.what());
1203  myCurrentIsBroken = true;
1204  }
1205 }
1206 
1207 
1208 void
1209 NLHandler::addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource) {
1210  if (myCurrentIsBroken) {
1211  // earlier error
1212  return;
1213  }
1214  bool ok = true;
1215  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentDistrictID.c_str(), ok);
1216  MSEdge* succ = MSEdge::dictionary(id);
1217  if (succ != 0) {
1218  // connect edge
1219  if (isSource) {
1220  MSEdge::dictionary(myCurrentDistrictID + "-source")->addSuccessor(succ);
1221  } else {
1222  succ->addSuccessor(MSEdge::dictionary(myCurrentDistrictID + "-sink"));
1223  }
1224  } else {
1225  WRITE_ERROR("At district '" + myCurrentDistrictID + "': succeeding edge '" + id + "' does not exist.");
1226  }
1227 }
1228 
1229 
1230 void
1232  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1233  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
1234  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
1235  MSEdge* edge = MSEdge::dictionary(*it);
1236  if (edge == 0) {
1237  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
1238  } else {
1239  edge->markAsRoundabout();
1240  }
1241  }
1242  } else {
1243  WRITE_ERROR("Empty edges in roundabout.");
1244  }
1245 }
1246 
1247 
1248 // ----------------------------------
1249 void
1251  try {
1253  } catch (InvalidArgument& e) {
1254  WRITE_ERROR(e.what());
1255  }
1256 }
1257 
1258 
1259 void
1261  if (!myCurrentIsBroken) {
1262  try {
1264  } catch (InvalidArgument& e) {
1265  WRITE_ERROR(e.what());
1266  myCurrentIsBroken = true;
1267  }
1268  }
1269  myCurrentWAUTID = "";
1270 }
1271 
1272 
1273 Position
1274 NLShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, SUMOReal lanePos) {
1275  MSLane* lane = MSLane::dictionary(laneID);
1276  if (lane == 0) {
1277  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1278  return Position::INVALID;
1279  }
1280  if (lanePos < 0) {
1281  lanePos = lane->getLength() + lanePos;
1282  }
1283  return lane->geometryPositionAtOffset(lanePos);
1284 }
1285 /****************************************************************************/
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:71
void parseAndBuildCalibrator(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a mesoscopic or microscopic calibrator.
const std::string & getActiveKey() const
Returns the active key.
void beginE3Detector(const SUMOSAXAttributes &attrs)
Starts building of an e3 detector using the given specification.
Definition: NLHandler.cpp:926
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:80
void addWAUTJunction(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:593
Builds detectors for microsim.
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:872
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:172
a routeprobe detector
long long int SUMOTime
Definition: SUMOTime.h:43
alternative tag for e1 detector
virtual SumoXMLNodeType getNodeType(bool &ok) const =0
Returns the value of the named attribute.
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:297
Whether vehicles must keep the junction clear.
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:48
void addSuccessor(MSEdge *edge)
Adds an edge to the list of edges which may be reached from this edge and to the incoming of the othe...
Definition: MSEdge.h:323
a source within a district (connection road)
void addAccess(MSNet &net, const SUMOSAXAttributes &attrs)
Parses the values and adds an access point to the currently parsed stopping place.
std::string next()
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...
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:547
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:110
bool myCurrentIsBroken
Definition: NLHandler.h:330
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:113
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:192
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:509
virtual MSEdge * buildEdge(const std::string &id, const MSEdge::EdgeBasicFunction function, const std::string &streetName, const std::string &edgeType, const int priority)
Builds an edge instance (MSEdge in this case)
void addE3Entry(const std::string &lane, SUMOReal pos, bool friendlyPos)
Builds an entry point of an e3 detector.
a traffic assignment zone
const std::string & getActiveSubKey() const
Returns the active sub key.
connectio between two lanes
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:480
The base class for an intersection.
Definition: MSJunction.h:64
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
int SVCPermissions
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:192
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:828
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1231
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)
SUMOReal myNetworkVersion
the loaded network version
Definition: NLHandler.h:346
void addE3Exit(const std::string &lane, SUMOReal pos, bool friendlyPos)
Builds an exit point of an e3 detector.
weights: time range begin
link,node: the traffic light id responsible for this link
The edge is a macroscopic connector (source/sink)
Definition: MSEdge.h:95
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1600
void buildRouteProbe(const std::string &id, const std::string &edge, SUMOTime frequency, SUMOTime begin, const std::string &device, const std::string &vTypes)
Builds a routeProbe and adds it to the net.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:693
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:773
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:68
void addLink(MSLink *link, MSLane *lane, int pos)
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Definition: NLHandler.cpp:306
void buildInstantInductLoop(const std::string &id, const std::string &lane, SUMOReal pos, const std::string &device, bool friendlyPos, const std::string &vTypes)
Builds an instantenous induction and adds it to the net.
maximum duration of a phase
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
static StringBijection< LinkState > LinkStates
link states
const SVCPermissions SVCAll
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 SUMOReal maxTravelTime, const SUMOReal minSamples, const SUMOReal haltSpeed, const std::string &vTypes, const std::string &device)
Creates edge based mean data collector using the given specification.
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:313
begin/end of the description of an edge restriction
void buildInductLoop(const std::string &id, const std::string &lane, SUMOReal pos, SUMOTime splInterval, const std::string &device, bool friendlyPos, const std::string &vTypes)
Builds an e1 detector and adds it to the net.
EdgeBasicFunction
Defines possible edge types.
Definition: MSEdge.h:89
A parking space for a single vehicle within a parking area.
void closeWAUT(const std::string &wautid)
Closes loading of a WAUT.
const Position geometryPositionAtOffset(SUMOReal offset, SUMOReal lateralOffset=0) const
Definition: MSLane.h:444
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:1250
void endE3Detector()
Builds of an e3 detector using collected values.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
The purpose of the edge is not known.
Definition: MSEdge.h:91
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
The simulated network and simulation perfomer.
Definition: MSNet.h:94
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
bool myAmInTLLogicMode
internal information whether a tls-logic is currently read
Definition: NLHandler.h:316
an e3 entry point
void closeJunction(const std::string &basePath)
Closes (ends) the processing of the current junction.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
int getNumberOfLoadedPhases() const
return the number of phases loaded so far (for error reporting)
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
void closeWAUT()
Definition: NLHandler.cpp:1260
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:529
an edge based mean data detector
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1159
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
The state of a link.
static StringBijection< LinkDirection > LinkDirections
link directions
void addApproachingLane(MSLane *lane, bool warnMultiCon)
Definition: MSLane.cpp:1610
const std::string & getID() const
Returns the id.
Definition: Named.h:66
A road/street connecting two junctions.
Definition: MSEdge.h:80
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1138
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:459
const std::string & getFileName() const
returns the current file name
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:307
The edge is a district edge.
Definition: MSEdge.h:99
the edges of a route
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
MSTrafficLightLogic * getActive() const
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:950
Encapsulated SAX-Attributes.
virtual std::vector< std::string > getStringVector(int attr) const =0
Tries to read given attribute assuming it is a string vector.
An instantenous induction loop.
std::string getCurrentE3ID() const
Returns the id of the currently built e3 detector.
void addE3Exit(const SUMOSAXAttributes &attrs)
Adds an exit to the currently processed e3 detector.
Definition: NLHandler.cpp:963
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
Builder of microsim-junctions and tls.
Position getLanePos(const std::string &poiID, const std::string &laneID, SUMOReal lanePos)
get position for a given laneID
Definition: NLHandler.cpp:1274
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:431
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void endParkingArea()
End a parking area.
parameter associated to a certain key
an e3 exit point
A list of positions.
virtual void closeTrafficLightLogic(const std::string &basePath)
Ends the building of a traffic lights logic.
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:574
JunctionGraph myJunctionGraph
Definition: NLHandler.h:353
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:614
void setPermissionsFound()
Labels the network to contain vehicle class permissions.
Definition: MSNet.h:181
void buildE2Detector(const std::string &id, const std::string &lane, SUMOReal pos, SUMOReal length, bool cont, SUMOTime splInterval, const std::string &device, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, bool friendlyPos, const std::string &vTypes)
Builds an e2 detector with a fixed interval and adds it to the net.
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:1011
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:47
roundabout defined in junction
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:93
void parseAndBuildStoppingPlace(MSNet &net, const SUMOSAXAttributes &attrs, const SumoXMLTag element)
Parses the values and builds a stopping places for busses, trains or container vehicles.
MSJunction * retrieve(const std::string id)
try to retrieve junction by id
#define POSITION_EPS
Definition: config.h:182
edge: the shape in xml-definition
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:337
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1112
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:73
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
void openJunction(const std::string &id, const std::string &key, const SumoXMLNodeType type, SUMOReal x, SUMOReal y, const PositionVector &shape, const std::vector< MSLane * > &incomingLanes, const std::vector< MSLane * > &internalLanes)
Begins the processing of the named junction.
MSTLLogicControl & getTLLogicControlToUse() const
Returns the used tls control.
void addParam(const std::string &key, const std::string &value)
Adds a parameter.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
begin/end of the description of a neighboring lane
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
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:117
description of a logic request within the junction
MSTLLogicControl::TLSLogicVariants & getTLLogic(const std::string &id) const
Returns a previously build tls logic.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
begin/end of the description of an edge
void addWAUTJunction(const std::string &wautid, const std::string &tls, const std::string &proc, bool synchron)
Adds a tls to the list of tls to be switched by the named WAUT.
virtual bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, SUMOReal layer, SUMOReal angle, const std::string &imgFile, const PositionVector &shape, bool fill, bool ignorePruning=false)
Builds a polygon using the given values and adds it to the container.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
void addParameter(const std::string &key, const std::string &value)
Adds a parameter.
std::string myCurrentWAUTID
The id of the currently processed WAUT.
Definition: NLHandler.h:319
The edge is a pedestrian walking area (a special type of internal edge)
Definition: MSEdge.h:103
virtual void myEndElement(int element)
Called when a closing tag occurs.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
Definition: MSLane.cpp:1317
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:802
std::vector< std::string > LaneIdVector
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:395
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:848
A train stop (alias for bus stop)
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:411
bool myHaveSeenNeighs
whether the loaded network contains explicit neighbor lanes
Definition: NLHandler.h:340
a sink within a district (connection road)
the edges crossed by a pedestrian crossing
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:89
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
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
The edge is a normal street.
Definition: MSEdge.h:93
The link is controlled by a tls which is off and blinks, has to brake.
static std::string checkForRelativity(const std::string &filename, const std::string &basePath)
Returns the path from a configuration so that it is accessable from the current working directory...
bool myNetIsLoaded
whether the location element was already loadee
Definition: NLHandler.h:349
virtual MSLane * addLane(const std::string &id, SUMOReal maxSpeed, SUMOReal length, const PositionVector &shape, SUMOReal width, SVCPermissions permissions, int index)
Adds a lane to the current edge.
void addWAUT(SUMOTime refTime, const std::string &id, const std::string &startProg)
Adds a WAUT definition.
weights: time range end
The edge is a pedestrian crossing (a special type of internal edge)
Definition: MSEdge.h:101
a vtypeprobe detector
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:89
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:682
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1209
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:209
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const SUMOReal speed)
Adds a restriction for an edge type.
Definition: MSNet.cpp:290
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:1122
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
The abstract direction of a link.
void setJunctions(MSJunction *from, MSJunction *to)
Definition: MSEdge.h:378
T get(const std::string &str) const
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:427
The parent class for traffic light logics.
A variable speed sign.
void beginEdgeParsing(const std::string &id, const MSEdge::EdgeBasicFunction function, const std::string &streetName, const std::string &edgeType, int priority)
Begins building of an MSEdge.
#define SUMOReal
Definition: config.h:208
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
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual void addCrossingEdges(const std::vector< std::string > &)
add the crossingEdges in a crossing edge if present
a traffic light logic
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: NLHandler.cpp:246
void beginE3Detector(const std::string &id, const std::string &device, SUMOTime splInterval, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes)
Stores temporary the initial information about an e3 detector to build.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
void markAsRoundabout()
Definition: MSEdge.h:631
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:976
Builds trigger objects for microsim.
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:641
The edge is an internal edge.
Definition: MSEdge.h:97
bool myLefthand
whether the loaded network was built for left hand traffic
Definition: NLHandler.h:343
Parameterised * myLastParameterised
Definition: NLHandler.h:334
An access point for a train stop.
void closePolygon()
ensures that the last position equals the first
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
void buildVaporizer(const SUMOSAXAttributes &attrs)
Builds a vaporization.
virtual SumoXMLEdgeFunc getEdgeFunc(bool &ok) const =0
Returns the value of the named attribute.
a single phase description
alternative tag for e3 detector
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h: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:655
static const Position INVALID
used to indicate that a position is valid
Definition: Position.h:278
Interface for building edges.
void addLogicItem(int request, const std::string &response, const std::string &foes, bool cont)
Adds a logic item.