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