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