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-2015 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  myNetIsLoaded(false)
83 {}
84 
85 
87 
88 
89 void
91  const SUMOSAXAttributes& attrs) {
92  try {
93  switch (element) {
94  case SUMO_TAG_EDGE:
95  beginEdgeParsing(attrs);
96  break;
97  case SUMO_TAG_LANE:
98  addLane(attrs);
99  break;
100  case SUMO_TAG_JUNCTION:
101  openJunction(attrs);
102  initJunctionLogic(attrs);
103  break;
104  case SUMO_TAG_PHASE:
105  addPhase(attrs);
106  break;
107  case SUMO_TAG_CONNECTION:
108  addConnection(attrs);
109  break;
110  case SUMO_TAG_TLLOGIC:
111  initTrafficLightLogic(attrs);
112  break;
113  case SUMO_TAG_REQUEST:
114  addRequest(attrs);
115  break;
116  case SUMO_TAG_WAUT:
117  openWAUT(attrs);
118  break;
120  addWAUTSwitch(attrs);
121  break;
123  addWAUTJunction(attrs);
124  break;
125  case SUMO_TAG_E1DETECTOR:
127  addE1Detector(attrs);
128  break;
129  case SUMO_TAG_E2DETECTOR:
131  addE2Detector(attrs);
132  break;
133  case SUMO_TAG_E3DETECTOR:
135  beginE3Detector(attrs);
136  break;
137  case SUMO_TAG_DET_ENTRY:
138  addE3Entry(attrs);
139  break;
140  case SUMO_TAG_DET_EXIT:
141  addE3Exit(attrs);
142  break;
144  addInstantE1Detector(attrs);
145  break;
146  case SUMO_TAG_VSS:
148  break;
149  case SUMO_TAG_CALIBRATOR:
151  break;
152  case SUMO_TAG_REROUTER:
154  break;
155  case SUMO_TAG_BUS_STOP:
157  break;
160  break;
161  case SUMO_TAG_VTYPEPROBE:
162  addVTypeProbeDetector(attrs);
163  break;
164  case SUMO_TAG_ROUTEPROBE:
165  addRouteProbeDetector(attrs);
166  break;
169  break;
172  break;
173  case SUMO_TAG_TIMEDEVENT:
175  break;
176  case SUMO_TAG_VAPORIZER:
178  break;
179  case SUMO_TAG_LOCATION:
180  setLocation(attrs);
181  break;
182  case SUMO_TAG_TAZ:
183  addDistrict(attrs);
184  break;
185  case SUMO_TAG_TAZSOURCE:
186  addDistrictEdge(attrs, true);
187  break;
188  case SUMO_TAG_TAZSINK:
189  addDistrictEdge(attrs, false);
190  break;
191  case SUMO_TAG_ROUNDABOUT:
192  addRoundabout(attrs);
193  break;
194  default:
195  break;
196  }
197  } catch (InvalidArgument& e) {
198  WRITE_ERROR(e.what());
199  }
200  MSRouteHandler::myStartElement(element, attrs);
201  if (element == SUMO_TAG_PARAM) {
202  addParam(attrs);
203  }
204 }
205 
206 
207 void
209  switch (element) {
210  case SUMO_TAG_EDGE:
211  closeEdge();
212  break;
213  case SUMO_TAG_JUNCTION:
214  if (!myCurrentIsBroken) {
215  try {
218  } catch (InvalidArgument& e) {
219  WRITE_ERROR(e.what());
220  }
221  }
222  break;
223  case SUMO_TAG_TLLOGIC:
224  try {
226  } catch (InvalidArgument& e) {
227  WRITE_ERROR(e.what());
228  }
229  myAmInTLLogicMode = false;
230  break;
231  case SUMO_TAG_WAUT:
232  closeWAUT();
233  break;
234  case SUMO_TAG_E3DETECTOR:
236  endE3Detector();
237  break;
238  case SUMO_TAG_NET:
239  // build junction graph
240  for (JunctionGraph::iterator it = myJunctionGraph.begin(); it != myJunctionGraph.end(); ++it) {
241  MSEdge* edge = MSEdge::dictionary(it->first);
242  MSJunction* from = myJunctionControlBuilder.retrieve(it->second.first);
243  MSJunction* to = myJunctionControlBuilder.retrieve(it->second.second);
244  if (edge != 0 && from != 0 && to != 0) {
245  edge->setJunctions(from, to);
246  from->addOutgoing(edge);
247  to->addIncoming(edge);
248  }
249  }
250  //initialise traffic lights
252  myNetIsLoaded = true;
253  break;
254  default:
255  break;
256  }
258  if (element != SUMO_TAG_PARAM) {
260  }
261 }
262 
263 
264 
265 // ---- the root/edge - element
266 void
268  bool ok = true;
269  myCurrentIsBroken = false;
270  // get the id, report an error if not given or empty...
271  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
272  if (!ok) {
273  myCurrentIsBroken = true;
274  return;
275  }
276  // omit internal edges if not wished
277  if (id[0] == ':') {
278  myHaveSeenInternalEdge = true;
281  return;
282  }
283  }
284  if (attrs.hasAttribute(SUMO_ATTR_FROM)) {
285  myJunctionGraph[id] = std::make_pair(
286  attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok),
287  attrs.get<std::string>(SUMO_ATTR_TO, 0, ok));
288  } else {
289  // must be an internal edge
290  std::string junctionID = SUMOXMLDefinitions::getJunctionIDFromInternalEdge(id);
291  myJunctionGraph[id] = std::make_pair(junctionID, junctionID);
292  }
294  // parse the function
295  const SumoXMLEdgeFunc func = attrs.getEdgeFunc(ok);
296  if (!ok) {
297  WRITE_ERROR("Edge '" + id + "' has an invalid type.");
298  myCurrentIsBroken = true;
299  return;
300  }
301  // interpret the function
303  switch (func) {
304  case EDGEFUNC_NORMAL:
305  funcEnum = MSEdge::EDGEFUNCTION_NORMAL;
306  break;
307  case EDGEFUNC_CONNECTOR:
308  case EDGEFUNC_SINK:
309  case EDGEFUNC_SOURCE:
311  break;
312  case EDGEFUNC_INTERNAL:
314  break;
315  case EDGEFUNC_CROSSING:
317  break;
320  break;
321  }
322  // get the street name
323  const std::string streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
324  // get the edge type (only for visualization)
325  const std::string edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
326  // get the edge priority (only for visualization)
327  const int priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1); // default taken from netbuild/NBFrame option 'default.priority'
328  if (!ok) {
329  myCurrentIsBroken = true;
330  return;
331  }
332  //
333  try {
334  myEdgeControlBuilder.beginEdgeParsing(id, funcEnum, streetName, edgeType, priority);
335  } catch (InvalidArgument& e) {
336  WRITE_ERROR(e.what());
337  myCurrentIsBroken = true;
338  }
339 }
340 
341 
342 void
344  // omit internal edges if not wished and broken edges
346  return;
347  }
348  try {
350  MSEdge::dictionary(e->getID(), e);
351  } catch (InvalidArgument& e) {
352  WRITE_ERROR(e.what());
353  }
354 }
355 
356 
357 // ---- the root/edge/lanes/lane - element
358 void
360  // omit internal edges if not wished and broken edges
362  return;
363  }
364  bool ok = true;
365  // get the id, report an error if not given or empty...
366  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
367  if (!ok) {
368  myCurrentIsBroken = true;
369  return;
370  }
371  const SUMOReal maxSpeed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, id.c_str(), ok);
372  const SUMOReal length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, id.c_str(), ok);
373  const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "", false);
374  const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
375  const SUMOReal width = attrs.getOpt<SUMOReal>(SUMO_ATTR_WIDTH, id.c_str(), ok, SUMO_const_laneWidth);
376  const PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
377  if (shape.size() < 2) {
378  WRITE_ERROR("Shape of lane '" + id + "' is broken.\n Can not build according edge.");
379  myCurrentIsBroken = true;
380  return;
381  }
382  const SVCPermissions permissions = parseVehicleClasses(allow, disallow);
383  if (permissions != SVCAll) {
385  }
386  myCurrentIsBroken |= !ok;
387  if (!myCurrentIsBroken) {
388  try {
389  MSLane* lane = myEdgeControlBuilder.addLane(id, maxSpeed, length, shape, width, permissions);
390  // insert the lane into the lane-dictionary, checking
391  if (!MSLane::dictionary(id, lane)) {
392  delete lane;
393  WRITE_ERROR("Another lane with the id '" + id + "' exists.");
394  myCurrentIsBroken = true;
395  }
396  myLastParameterised = lane;
397  } catch (InvalidArgument& e) {
398  WRITE_ERROR(e.what());
399  }
400  }
401 }
402 
403 
404 // ---- the root/junction - element
405 void
407  myCurrentIsBroken = false;
408  bool ok = true;
409  // get the id, report an error if not given or empty...
410  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
411  if (!ok) {
412  myCurrentIsBroken = true;
413  return;
414  }
415  PositionVector shape;
416  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
417  // inner junctions have no shape
418  shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok, PositionVector());
419  if (shape.size() > 2) {
420  shape.closePolygon();
421  }
422  }
423  SUMOReal x = attrs.get<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok);
424  SUMOReal y = attrs.get<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok);
425  bool typeOK = true;
426  SumoXMLNodeType type = attrs.getNodeType(typeOK);
427  if (!typeOK) {
428  WRITE_ERROR("An unknown or invalid junction type occured in junction '" + id + "'.");
429  ok = false;
430  }
431  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_KEY, id.c_str(), ok, "");
432  // incoming lanes
433  std::vector<MSLane*> incomingLanes;
434  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INCLANES, ""), incomingLanes, ok);
435  // internal lanes
436  std::vector<MSLane*> internalLanes;
437 #ifdef HAVE_INTERNAL_LANES
439  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INTLANES, ""), internalLanes, ok);
440  }
441 #endif
442  if (!ok) {
443  myCurrentIsBroken = true;
444  } else {
445  try {
446  myJunctionControlBuilder.openJunction(id, key, type, x, y, shape, incomingLanes, internalLanes);
447  } catch (InvalidArgument& e) {
448  WRITE_ERROR(e.what() + std::string("\n Can not build according junction."));
449  myCurrentIsBroken = true;
450  }
451  }
452 }
453 
454 
455 void
456 NLHandler::parseLanes(const std::string& junctionID,
457  const std::string& def, std::vector<MSLane*>& into, bool& ok) {
458  StringTokenizer st(def);
459  while (ok && st.hasNext()) {
460  std::string laneID = st.next();
461  MSLane* lane = MSLane::dictionary(laneID);
462  if (!MSGlobals::gUsingInternalLanes && laneID[0] == ':') {
463  continue;
464  }
465  if (lane == 0) {
466  WRITE_ERROR("An unknown lane ('" + laneID + "') was tried to be set as incoming to junction '" + junctionID + "'.");
467  ok = false;
468  continue;
469  }
470  into.push_back(lane);
471  }
472 }
473 // ----
474 
475 void
477  bool ok = true;
478  std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, 0, ok);
479  std::string val = attrs.get<std::string>(SUMO_ATTR_VALUE, 0, ok);
480  if (myLastParameterised != 0) {
482  }
483  // set
484  if (ok && myAmInTLLogicMode) {
485  assert(key != "");
486  assert(val != "");
488  }
489 }
490 
491 
492 void
494  myCurrentIsBroken = false;
495  bool ok = true;
496  // get the id, report an error if not given or empty...
497  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
498  if (!ok) {
499  myCurrentIsBroken = true;
500  return;
501  }
502  SUMOTime t = attrs.getOptSUMOTimeReporting(SUMO_ATTR_REF_TIME, id.c_str(), ok, 0);
503  std::string pro = attrs.get<std::string>(SUMO_ATTR_START_PROG, id.c_str(), ok);
504  if (!ok) {
505  myCurrentIsBroken = true;
506  }
507  if (!myCurrentIsBroken) {
508  myCurrentWAUTID = id;
509  try {
511  } catch (InvalidArgument& e) {
512  WRITE_ERROR(e.what());
513  myCurrentIsBroken = true;
514  }
515  }
516 }
517 
518 
519 void
521  bool ok = true;
523  std::string to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentWAUTID.c_str(), ok);
524  if (!ok) {
525  myCurrentIsBroken = true;
526  }
527  if (!myCurrentIsBroken) {
528  try {
530  } catch (InvalidArgument& e) {
531  WRITE_ERROR(e.what());
532  myCurrentIsBroken = true;
533  }
534  }
535 }
536 
537 
538 void
540  bool ok = true;
541  std::string wautID = attrs.get<std::string>(SUMO_ATTR_WAUT_ID, 0, ok);
542  std::string junctionID = attrs.get<std::string>(SUMO_ATTR_JUNCTION_ID, 0, ok);
543  std::string procedure = attrs.getOpt<std::string>(SUMO_ATTR_PROCEDURE, 0, ok, "");
544  bool synchron = attrs.getOpt<bool>(SUMO_ATTR_SYNCHRON, 0, ok, false);
545  if (!ok) {
546  myCurrentIsBroken = true;
547  }
548  try {
549  if (!myCurrentIsBroken) {
550  myJunctionControlBuilder.getTLLogicControlToUse().addWAUTJunction(wautID, junctionID, procedure, synchron);
551  }
552  } catch (InvalidArgument& e) {
553  WRITE_ERROR(e.what());
554  myCurrentIsBroken = true;
555  }
556 }
557 
558 
559 void
561  if (myCurrentIsBroken) {
562  return;
563  }
564  bool ok = true;
565  int request = attrs.get<int>(SUMO_ATTR_INDEX, 0, ok);
566  bool cont = false;
567 #ifdef HAVE_INTERNAL_LANES
568  cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, 0, ok, false);
569 #endif
570  std::string response = attrs.get<std::string>(SUMO_ATTR_RESPONSE, 0, ok);
571  std::string foes = attrs.get<std::string>(SUMO_ATTR_FOES, 0, ok);
572  if (!ok) {
573  return;
574  }
575  // store received information
576  if (request >= 0 && response.length() > 0) {
577  try {
578  myJunctionControlBuilder.addLogicItem(request, response, foes, cont);
579  } catch (InvalidArgument& e) {
580  WRITE_ERROR(e.what());
581  }
582  }
583 }
584 
585 
586 void
588  if (myCurrentIsBroken) {
589  return;
590  }
591  bool ok = true;
592  // we either a have a junction or a legacy network with ROWLogic
593  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
594  if (ok) {
596  }
597 }
598 
599 
600 void
602  myAmInTLLogicMode = true;
603  bool ok = true;
604  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
605  TrafficLightType type;
606  std::string typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
607  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
609  } else {
610  WRITE_ERROR("Traffic light '" + id + "' has unknown type '" + typeS + "'");
611  return;
612  }
613  //
614  SUMOTime offset = attrs.getOptSUMOTimeReporting(SUMO_ATTR_OFFSET, id.c_str(), ok, 0);
615  if (!ok) {
616  return;
617  }
618  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
619  myJunctionControlBuilder.initTrafficLightLogic(id, programID, type, offset);
620 }
621 
622 
623 void
625  // try to get the phase definition
626  bool ok = true;
627  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok);
628  if (!ok) {
629  return;
630  }
631  // try to get the phase duration
633  if (duration == 0) {
635  + " for tlLogic '" + myJunctionControlBuilder.getActiveKey()
636  + "' program '" + myJunctionControlBuilder.getActiveSubKey() + "' is zero.");
637  return;
638  }
639  // if the traffic light is an actuated traffic light, try to get
640  // the minimum and maximum durations
641  SUMOTime minDuration = attrs.getOptSUMOTimeReporting(
643  SUMOTime maxDuration = attrs.getOptSUMOTimeReporting(
645  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration);
646 }
647 
648 
649 void
651  bool ok = true;
652  // get the id, report an error if not given or empty...
653  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
654  if (!ok) {
655  return;
656  }
657  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
658  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
659  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
660  const bool splitByType = attrs.getOpt<bool>(SUMO_ATTR_SPLIT_VTYPE, id.c_str(), ok, false);
661  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
662  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
663  if (!ok) {
664  return;
665  }
666  try {
667  myDetectorBuilder.buildInductLoop(id, lane, position, frequency,
669  friendlyPos, splitByType);
670  } catch (InvalidArgument& e) {
671  WRITE_ERROR(e.what());
672  } catch (IOError& e) {
673  WRITE_ERROR(e.what());
674  }
675 }
676 
677 
678 void
680  bool ok = true;
681  // get the id, report an error if not given or empty...
682  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
683  if (!ok) {
684  return;
685  }
686  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
687  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
688  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
689  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
690  if (!ok) {
691  return;
692  }
693  try {
694  myDetectorBuilder.buildInstantInductLoop(id, lane, position, FileHelpers::checkForRelativity(file, getFileName()), friendlyPos);
695  } catch (InvalidArgument& e) {
696  WRITE_ERROR(e.what());
697  } catch (IOError& e) {
698  WRITE_ERROR(e.what());
699  }
700 }
701 
702 
703 void
705  bool ok = true;
706  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
707  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
708  std::string type = attrs.getStringSecure(SUMO_ATTR_TYPE, "");
709  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
710  if (!ok) {
711  return;
712  }
713  try {
715  } catch (InvalidArgument& e) {
716  WRITE_ERROR(e.what());
717  } catch (IOError& e) {
718  WRITE_ERROR(e.what());
719  }
720 }
721 
722 
723 void
725  bool ok = true;
726  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
727  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
728  SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, -1);
729  std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
730  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
731  if (!ok) {
732  return;
733  }
734  try {
735  myDetectorBuilder.buildRouteProbe(id, edge, frequency, begin,
737  } catch (InvalidArgument& e) {
738  WRITE_ERROR(e.what());
739  } catch (IOError& e) {
740  WRITE_ERROR(e.what());
741  }
742 }
743 
744 
745 
746 void
748  // check whether this is a detector connected to a tls an optionally to a link
749  bool ok = true;
750  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
751  const std::string lsaid = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), ok, "<invalid>");
752  const std::string toLane = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "<invalid>");
753  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
754  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
755  const SUMOReal jamDistThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, 10.0f);
756  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
757  const SUMOReal length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, id.c_str(), ok);
758  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
759  const bool cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, id.c_str(), ok, false);
760  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
761  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
762  if (!ok) {
763  return;
764  }
765  try {
766  if (lsaid != "<invalid>") {
767  if (toLane == "<invalid>") {
768  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont,
771  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
772  friendlyPos);
773  } else {
774  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont,
775  myJunctionControlBuilder.getTLLogic(lsaid), toLane,
777  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
778  friendlyPos);
779  }
780  } else {
781  bool ok = true;
782  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
783  if (!ok) {
784  return;
785  }
786  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont, frequency,
788  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
789  friendlyPos);
790  }
791  } catch (InvalidArgument& e) {
792  WRITE_ERROR(e.what());
793  } catch (IOError& e) {
794  WRITE_ERROR(e.what());
795  }
796 }
797 
798 
799 void
801  bool ok = true;
802  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
803  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
804  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
805  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
806  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
807  if (!ok) {
808  return;
809  }
810  try {
813  frequency, haltingSpeedThreshold, haltingTimeThreshold);
814  } catch (InvalidArgument& e) {
815  WRITE_ERROR(e.what());
816  } catch (IOError& e) {
817  WRITE_ERROR(e.what());
818  }
819 }
820 
821 
822 void
824  bool ok = true;
825  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
826  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
827  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
828  if (!ok) {
829  return;
830  }
831  myDetectorBuilder.addE3Entry(lane, position, friendlyPos);
832 }
833 
834 
835 void
837  bool ok = true;
838  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
839  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
840  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
841  if (!ok) {
842  return;
843  }
844  myDetectorBuilder.addE3Exit(lane, position, friendlyPos);
845 }
846 
847 
848 void
849 NLHandler::addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype) {
850  bool ok = true;
851  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
852  const SUMOReal maxTravelTime = attrs.getOpt<SUMOReal>(SUMO_ATTR_MAX_TRAVELTIME, id.c_str(), ok, 100000);
853  const SUMOReal minSamples = attrs.getOpt<SUMOReal>(SUMO_ATTR_MIN_SAMPLES, id.c_str(), ok, 0);
854  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, POSITION_EPS);
855  const std::string excludeEmpty = attrs.getOpt<std::string>(SUMO_ATTR_EXCLUDE_EMPTY, id.c_str(), ok, "false");
856  const bool withInternal = attrs.getOpt<bool>(SUMO_ATTR_WITH_INTERNAL, id.c_str(), ok, false);
857  const bool trackVehicles = attrs.getOpt<bool>(SUMO_ATTR_TRACK_VEHICLES, id.c_str(), ok, false);
858  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
859  const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "performance");
860  std::string vtypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
861  const SUMOTime frequency = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, -1);
862  const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("begin")));
863  const SUMOTime end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("end")));
864  if (!ok) {
865  return;
866  }
867  try {
868  myDetectorBuilder.createEdgeLaneMeanData(id, frequency, begin, end,
869  type, objecttype == SUMO_TAG_MEANDATA_LANE,
870  // equivalent to TplConvert::_2bool used in SUMOSAXAttributes::getBool
871  excludeEmpty[0] != 't' && excludeEmpty[0] != 'T' && excludeEmpty[0] != '1' && excludeEmpty[0] != 'x',
872  excludeEmpty == "defaults", withInternal, trackVehicles,
873  maxTravelTime, minSamples, haltingSpeedThreshold, vtypes,
875  } catch (InvalidArgument& e) {
876  WRITE_ERROR(e.what());
877  } catch (IOError& e) {
878  WRITE_ERROR(e.what());
879  }
880 }
881 
882 
883 void
885  bool ok = true;
886  std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
887  if (!MSGlobals::gUsingInternalLanes && fromID[0] == ':') {
888  return;
889  }
890 
891  try {
892  bool ok = true;
893  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
894  const int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, 0, ok);
895  const int toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, 0, ok);
896  LinkDirection dir = parseLinkDir(attrs.get<std::string>(SUMO_ATTR_DIR, 0, ok));
897  LinkState state = parseLinkState(attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok));
898  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, 0, ok, "");
899 #ifdef HAVE_INTERNAL_LANES
900  std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, 0, ok, "");
901 #endif
902 
903  MSEdge* from = MSEdge::dictionary(fromID);
904  if (from == 0) {
905  WRITE_ERROR("Unknown from-edge '" + fromID + "' in connection");
906  return;
907  }
908  MSEdge* to = MSEdge::dictionary(toID);
909  if (to == 0) {
910  WRITE_ERROR("Unknown to-edge '" + toID + "' in connection");
911  return;
912  }
913  if (fromLaneIdx < 0 || static_cast<unsigned int>(fromLaneIdx) >= from->getLanes().size() ||
914  toLaneIdx < 0 || static_cast<unsigned int>(toLaneIdx) >= to->getLanes().size()) {
915  WRITE_ERROR("Invalid lane index in connection from '" + from->getID() + "' to '" + to->getID() + "'.");
916  return;
917  }
918  MSLane* fromLane = from->getLanes()[fromLaneIdx];
919  MSLane* toLane = to->getLanes()[toLaneIdx];
920  assert(fromLane);
921  assert(toLane);
922 
923  int tlLinkIdx = -1;
924  if (tlID != "") {
925  tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, 0, ok);
926  // make sure that the index is in range
928  if ((tlLinkIdx < 0 || tlLinkIdx >= (int)logic->getCurrentPhaseDef().getState().size())
929  && logic->getLogicType() != "railSignal") {
930  WRITE_ERROR("Invalid " + toString(SUMO_ATTR_TLLINKINDEX) + " '" + toString(tlLinkIdx) +
931  "' in connection controlled by '" + tlID + "'");
932  return;
933  }
934  if (!ok) {
935  return;
936  }
937  }
938  SUMOReal length = fromLane->getShape()[-1].distanceTo(toLane->getShape()[0]);
939  MSLink* link = 0;
940 
941  // build the link
942 #ifdef HAVE_INTERNAL_LANES
943  MSLane* via = 0;
944  if (viaID != "" && MSGlobals::gUsingInternalLanes) {
945  via = MSLane::dictionary(viaID);
946  if (via == 0) {
947  WRITE_ERROR("An unknown lane ('" + viaID +
948  "') should be set as a via-lane for lane '" + toLane->getID() + "'.");
949  return;
950  }
951  length = via->getLength();
952  }
953  link = new MSLink(toLane, via, dir, state, length);
954  if (via != 0) {
955  via->addIncomingLane(fromLane, link);
956  } else {
957  toLane->addIncomingLane(fromLane, link);
958  }
959 #else
960  link = new MSLink(toLane, dir, state, length);
961  toLane->addIncomingLane(fromLane, link);
962 #endif
963  toLane->addApproachingLane(fromLane);
964 
965  // if a traffic light is responsible for it, inform the traffic light
966  // check whether this link is controlled by a traffic light
967  if (tlID != "") {
968  myJunctionControlBuilder.getTLLogic(tlID).addLink(link, fromLane, tlLinkIdx);
969  }
970  // add the link
971  fromLane->addLink(link);
972 
973  } catch (InvalidArgument& e) {
974  WRITE_ERROR(e.what());
975  }
976 }
977 
978 
980 NLHandler::parseLinkDir(const std::string& dir) {
981  if (SUMOXMLDefinitions::LinkDirections.hasString(dir)) {
983  } else {
984  throw InvalidArgument("Unrecognised link direction '" + dir + "'.");
985  }
986 }
987 
988 
989 LinkState
990 NLHandler::parseLinkState(const std::string& state) {
991  if (SUMOXMLDefinitions::LinkStates.hasString(state)) {
992  return SUMOXMLDefinitions::LinkStates.get(state);
993  } else {
994  if (state == "t") { // legacy networks
995  // WRITE_WARNING("Obsolete link state 't'. Use 'o' instead");
997  } else {
998  throw InvalidArgument("Unrecognised link state '" + state + "'.");
999  }
1000  }
1001 }
1002 
1003 
1004 // ----------------------------------
1005 void
1007  if (myNetIsLoaded) {
1008  //WRITE_WARNING("POIs and Polygons should be loaded using option --po-files")
1009  return;
1010  }
1011  bool ok = true;
1013  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, 0, ok);
1014  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, 0, ok);
1015  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, 0, ok);
1016  if (ok) {
1017  Position networkOffset = s[0];
1018  GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
1019  if (OptionsCont::getOptions().getBool("fcd-output.geo") && !GeoConvHelper::getFinal().usingGeoProjection()) {
1020  WRITE_WARNING("no valid geo projection loaded from network. fcd-output.geo will not work");
1021  }
1022  }
1023 }
1024 
1025 
1026 void
1028  bool ok = true;
1029  myCurrentIsBroken = false;
1030  // get the id, report an error if not given or empty...
1031  myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1032  if (!ok) {
1033  myCurrentIsBroken = true;
1034  return;
1035  }
1036  try {
1038  if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) {
1039  delete sink;
1040  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists.");
1041  }
1042  sink->initialize(new std::vector<MSLane*>());
1044  if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) {
1045  delete source;
1046  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists.");
1047  }
1048  source->initialize(new std::vector<MSLane*>());
1049  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1050  std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES);
1051  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
1052  MSEdge* edge = MSEdge::dictionary(*i);
1053  // check whether the edge exists
1054  if (edge == 0) {
1055  throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known.");
1056  }
1057  source->addSuccessor(edge);
1058  edge->addSuccessor(sink);
1059  }
1060  }
1061  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
1063  if (shape.size() != 0) {
1064  if (!myNet.getShapeContainer().addPolygon(myCurrentDistrictID, "taz", RGBColor::parseColor("1.0,.33,.33"), 0, 0, "", shape, false)) {
1065  WRITE_WARNING("Skipping visualization of taz '" + myCurrentDistrictID + "', polygon already exists.");
1066  }
1067  }
1068  }
1069  } catch (InvalidArgument& e) {
1070  WRITE_ERROR(e.what());
1071  myCurrentIsBroken = true;
1072  }
1073 }
1074 
1075 
1076 void
1077 NLHandler::addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource) {
1078  if (myCurrentIsBroken) {
1079  // earlier error
1080  return;
1081  }
1082  bool ok = true;
1083  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentDistrictID.c_str(), ok);
1084  MSEdge* succ = MSEdge::dictionary(id);
1085  if (succ != 0) {
1086  // connect edge
1087  if (isSource) {
1088  MSEdge::dictionary(myCurrentDistrictID + "-source")->addSuccessor(succ);
1089  } else {
1090  succ->addSuccessor(MSEdge::dictionary(myCurrentDistrictID + "-sink"));
1091  }
1092  } else {
1093  WRITE_ERROR("At district '" + myCurrentDistrictID + "': succeeding edge '" + id + "' does not exist.");
1094  }
1095 }
1096 
1097 
1098 void
1100  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1101  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
1102  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
1103  MSEdge* edge = MSEdge::dictionary(*it);
1104  if (edge == 0) {
1105  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
1106  } else {
1107  edge->markAsRoundabout();
1108  }
1109  }
1110  } else {
1111  WRITE_ERROR("Empty edges in roundabout.");
1112  }
1113 }
1114 
1115 
1116 // ----------------------------------
1117 void
1119  try {
1121  } catch (InvalidArgument& e) {
1122  WRITE_ERROR(e.what());
1123  }
1124 }
1125 
1126 
1127 void
1129  if (!myCurrentIsBroken) {
1130  try {
1132  } catch (InvalidArgument& e) {
1133  WRITE_ERROR(e.what());
1134  myCurrentIsBroken = true;
1135  }
1136  }
1137  myCurrentWAUTID = "";
1138 }
1139 
1140 
1141 Position
1142 NLShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, SUMOReal lanePos) {
1143  MSLane* lane = MSLane::dictionary(laneID);
1144  if (lane == 0) {
1145  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + poiID + "' on is not known.");
1146  return Position::INVALID;
1147  }
1148  if (lanePos < 0) {
1149  lanePos = lane->getLength() + lanePos;
1150  }
1151  return lane->geometryPositionAtOffset(lanePos);
1152 }
1153 /****************************************************************************/
void parseAndBuildCalibrator(MSNet &net, const SUMOSAXAttributes &attrs, const std::string &base)
Parses his values and builds a mesoscopic or microscopic calibrator.
void postLoadInitialization()
initialize junctions after all connections have been loaded
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:800
void initTrafficLightLogic(const std::string &id, const std::string &programID, TrafficLightType type, SUMOTime offset)
Begins the reading of a traffic lights logic.
void addWAUTJunction(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:539
Builds detectors for microsim.
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:747
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:172
minimum duration of a phase
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:294
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:46
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:291
std::string next()
virtual MSEdge * closeEdge()
Closes the building of an edge; The edge is completely described by now and may not be opened again...
size_t getNumberOfLoadedPhases() const
return the number of phases loaded so far (for error reporting)
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:493
void setRestrictionFound()
Labels the network to contain vehicle class restrictions.
Definition: MSNet.h:177
const Position geometryPositionAtOffset(SUMOReal offset) const
Definition: MSLane.h:340
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:107
bool myCurrentIsBroken
Definition: NLHandler.h:324
void addIncoming(MSEdge *edge)
Definition: MSJunction.h:110
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:186
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:456
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.
const std::string & getActiveSubKey() const
Returns the active sub key.
SUMOReal getLength() const
Returns the lane's length.
Definition: MSLane.h:370
The base class for an intersection.
Definition: MSJunction.h:61
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
return the junction id when given an edge of type internal, crossing or WalkingArea ...
int SVCPermissions
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:107
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:704
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1099
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:298
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)
void addE3Exit(const std::string &lane, SUMOReal pos, bool friendlyPos)
Builds an exit point of an e3 detector.
The edge is a macroscopic connector (source/sink)
Definition: MSEdge.h:96
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1076
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
Definition: MSEdge.cpp:531
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:650
NLHandler(const std::string &file, MSNet &net, NLDetectorBuilder &detBuilder, NLTriggerBuilder &triggerBuilder, NLEdgeControlBuilder &edgeBuilder, NLJunctionControlBuilder &junctionBuilder)
Constructor.
Definition: NLHandler.cpp:68
void beginEdgeParsing(const SUMOSAXAttributes &attrs)
begins the processing of an edge
Definition: NLHandler.cpp:267
maximum duration of a phase
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
static StringBijection< LinkState > LinkStates
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.
void parseAndBuildBusStop(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a bus stop.
std::string myCurrentDistrictID
The id of the current district.
Definition: NLHandler.h:310
EdgeBasicFunction
Defines possible edge types.
Definition: MSEdge.h:90
void closeWAUT(const std::string &wautid)
Closes loading of a WAUT.
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:1118
void endE3Detector()
Builds of an e3 detector using collected values.
void buildInductLoop(const std::string &id, const std::string &lane, SUMOReal pos, int splInterval, const std::string &device, bool friendlyPos, bool splitByType)
Builds an e1 detector and adds it to the net.
void addLink(MSLink *link, MSLane *lane, unsigned int pos)
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
virtual SumoXMLEdgeFunc getEdgeFunc(bool &ok) const =0
Returns the value of the named attribute.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
The purpose of the edge is not known.
Definition: MSEdge.h:92
#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:67
bool myAmInTLLogicMode
internal information whether a tls-logic is currently read
Definition: NLHandler.h:313
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.
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
void closeWAUT()
Definition: NLHandler.cpp:1128
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:476
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1027
The state of a link.
static StringBijection< LinkDirection > LinkDirections
const std::string & getID() const
Returns the id.
Definition: Named.h:60
A road/street connecting two junctions.
Definition: MSEdge.h:81
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1006
void addPhase(SUMOTime duration, const std::string &state, int min, int 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:406
const std::string & getFileName() const
returns the current file name
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:304
The edge is a district edge.
Definition: MSEdge.h:100
the edges of a route
MSTrafficLightLogic * getActive() const
void addE3Entry(const SUMOSAXAttributes &attrs)
Adds an entry to the currently processed e3 detector.
Definition: NLHandler.cpp:823
Encapsulated SAX-Attributes.
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:836
static StringBijection< TrafficLightType > TrafficLightTypes
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:1142
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:399
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
void parseAndBuildContainerStop(MSNet &net, const SUMOSAXAttributes &attrs)
Parses his values and builds a container stop.
void addWAUTSwitch(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:520
JunctionGraph myJunctionGraph
Definition: NLHandler.h:338
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:560
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:884
void beginE3Detector(const std::string &id, const std::string &device, int splInterval, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold)
Stores temporary the initial information about an e3 detector to build.
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:48
Information within the junction logic which internal lanes block external.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: NLHandler.cpp:90
MSJunction * retrieve(const std::string id)
try to retrieve junction by id
void closeJunction()
Closes (ends) the processing of the current junction.
#define POSITION_EPS
Definition: config.h:189
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:331
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:980
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:71
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.
void buildRouteProbe(const std::string &id, const std::string &edge, SUMOTime frequency, SUMOTime begin, const std::string &device)
Builds a routeProbe and adds it to the net.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
virtual SumoXMLNodeType getNodeType(bool &ok) const =0
Returns the value of the named attribute.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void addOutgoing(MSEdge *edge)
Definition: MSJunction.h:114
MSTLLogicControl::TLSLogicVariants & getTLLogic(const std::string &id) const
Returns a previously build tls logic.
void addWAUTJunction(const std::string &wautid, const std::string &tls, const std::string &proc, bool synchron)
Adds a tls to the list of tls to be switched by the named WAUT.
virtual std::vector< std::string > getStringVector(int attr) const =0
Tries to read given attribute assuming it is a string vector.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
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:316
The edge is a pedestrian walking area (a special type of internal edge)
Definition: MSEdge.h:104
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:852
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:679
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:343
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:724
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:359
virtual ~NLHandler()
Destructor.
Definition: NLHandler.cpp:86
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)
Builds a polygon using the given values and adds it to the container.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
NLTriggerBuilder & myTriggerBuilder
The trigger builder to use.
Definition: NLHandler.h:301
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
The edge is a normal street.
Definition: MSEdge.h:94
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:334
void addWAUT(SUMOTime refTime, const std::string &id, const std::string &startProg)
Adds a WAUT definition.
The edge is a pedestrian crossing (a special type of internal edge)
Definition: MSEdge.h:102
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 MSLane * addLane(const std::string &id, SUMOReal maxSpeed, SUMOReal length, const PositionVector &shape, SUMOReal width, SVCPermissions permissions)
Adds a lane to the current edge;.
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
void addPhase(const SUMOSAXAttributes &attrs)
adds a phase to the traffic lights logic currently build
Definition: NLHandler.cpp:624
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1077
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:206
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
int SUMOTime
Definition: SUMOTime.h:43
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
Definition: NLHandler.cpp:990
The abstract direction of a link.
void setJunctions(MSJunction *from, MSJunction *to)
Definition: MSEdge.h:354
virtual void closeTrafficLightLogic()
Ends the building of a traffic lights logic.
T get(const std::string &str) const
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:323
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:218
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:291
void addWAUTSwitch(const std::string &wautid, SUMOTime when, const std::string &to)
Adds a WAUT switch step to a previously built WAUT.
void buildInstantInductLoop(const std::string &id, const std::string &lane, SUMOReal pos, const std::string &device, bool friendlyPos)
Builds an instantenous induction and adds it to the net.
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 myEndElement(int element)
Called when a closing tag occurs.
Definition: NLHandler.cpp:208
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:584
void buildE2Detector(const std::string &id, const std::string &lane, SUMOReal pos, SUMOReal length, bool cont, int splInterval, const std::string &device, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, bool friendlyPos)
Builds an e2 detector with a fixed interval and adds it to the net.
virtual void addEdgeLaneMeanData(const SUMOSAXAttributes &attrs, int objecttype)
Builds edge or lane base mean data collector using the given specification.
Definition: NLHandler.cpp:849
Builds trigger objects for microsim.
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:587
The edge is an internal edge.
Definition: MSEdge.h:98
Parameterised * myLastParameterised
Definition: NLHandler.h:328
void closePolygon()
ensures that the last position equals the first
Information whether the detector shall be continued on the folowing lanes.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
void buildVaporizer(const SUMOSAXAttributes &attrs)
Builds a vaporization.
NLJunctionControlBuilder & myJunctionControlBuilder
The junction builder to use.
Definition: NLHandler.h:307
Parser and container for routes during their loading.
void addApproachingLane(MSLane *lane)
Definition: MSLane.cpp:1086
TrafficLightType
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:601
static const Position INVALID
Definition: Position.h:262
Interface for building edges.
void addLogicItem(int request, const std::string &response, const std::string &foes, bool cont)
Adds a logic item.