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