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-sim.org/
15 // Copyright (C) 2001-2013 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/MSBitSetLogic.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  break;
243  default:
244  break;
245  }
247  if (element != SUMO_TAG_PARAM) {
249  }
250 }
251 
252 
253 
254 // ---- the root/edge - element
255 void
257  bool ok = true;
258  myCurrentIsBroken = false;
259  // get the id, report an error if not given or empty...
260  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
261  if (!ok) {
262  myCurrentIsBroken = true;
263  return;
264  }
265  // omit internal edges if not wished
266  if (!MSGlobals::gUsingInternalLanes && id[0] == ':') {
267  myHaveSeenInternalEdge = true;
269  return;
270  }
272  // parse the function
273  const SumoXMLEdgeFunc func = attrs.getEdgeFunc(ok);
274  if (!ok) {
275  WRITE_ERROR("Edge '" + id + "' has an invalid type.");
276  myCurrentIsBroken = true;
277  return;
278  }
279  // interpret the function
281  switch (func) {
282  case EDGEFUNC_NORMAL:
283  funcEnum = MSEdge::EDGEFUNCTION_NORMAL;
284  break;
285  case EDGEFUNC_CONNECTOR:
286  case EDGEFUNC_SINK:
287  case EDGEFUNC_SOURCE:
289  break;
290  case EDGEFUNC_INTERNAL:
292  break;
293  }
294  // get the street name
295  std::string streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
296  if (!ok) {
297  myCurrentIsBroken = true;
298  return;
299  }
300  //
301  try {
302  myEdgeControlBuilder.beginEdgeParsing(id, funcEnum, streetName);
303  } catch (InvalidArgument& e) {
304  WRITE_ERROR(e.what());
305  myCurrentIsBroken = true;
306  }
307 }
308 
309 
310 void
312  // omit internal edges if not wished and broken edges
314  return;
315  }
316  try {
318  MSEdge::dictionary(e->getID(), e);
319  } catch (InvalidArgument& e) {
320  WRITE_ERROR(e.what());
321  }
322 }
323 
324 
325 // ---- the root/edge/lanes/lane - element
326 void
328  // omit internal edges if not wished and broken edges
330  return;
331  }
332  bool ok = true;
333  // get the id, report an error if not given or empty...
334  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
335  if (!ok) {
336  myCurrentIsBroken = true;
337  return;
338  }
339  SUMOReal maxSpeed = attrs.get<SUMOReal>(SUMO_ATTR_SPEED, id.c_str(), ok);
340  SUMOReal length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, id.c_str(), ok);
341  std::string allow;
342  try {
343  bool dummy;
344  allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), dummy, "", false);
345  } catch (EmptyData e) {
346  // !!! deprecated
347  }
348  std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
349  SUMOReal width = attrs.getOpt<SUMOReal>(SUMO_ATTR_WIDTH, id.c_str(), ok, SUMO_const_laneWidth);
350  PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
351  if (shape.size() < 2) {
352  WRITE_ERROR("Shape of lane '" + id + "' is broken.\n Can not build according edge.");
353  myCurrentIsBroken = true;
354  return;
355  }
356  SVCPermissions permissions = parseVehicleClasses(allow, disallow);
357  myCurrentIsBroken |= !ok;
358  if (!myCurrentIsBroken) {
359  try {
360  MSLane* lane = myEdgeControlBuilder.addLane(id, maxSpeed, length, shape, width, permissions);
361  // insert the lane into the lane-dictionary, checking
362  if (!MSLane::dictionary(id, lane)) {
363  delete lane;
364  WRITE_ERROR("Another lane with the id '" + id + "' exists.");
365  myCurrentIsBroken = true;
366  }
367  myLastParameterised = lane;
368  } catch (InvalidArgument& e) {
369  WRITE_ERROR(e.what());
370  }
371  }
372 }
373 
374 
375 // ---- the root/junction - element
376 void
378  myCurrentIsBroken = false;
379  bool ok = true;
380  // get the id, report an error if not given or empty...
381  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
382  if (!ok) {
383  myCurrentIsBroken = true;
384  return;
385  }
386  PositionVector shape;
387  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
388  // inner junctions have no shape
389  shape = attrs.getOpt<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok, PositionVector());
390  }
391  SUMOReal x = attrs.get<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok);
392  SUMOReal y = attrs.get<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok);
393  bool typeOK = true;
394  SumoXMLNodeType type = attrs.getNodeType(typeOK);
395  if (!typeOK) {
396  WRITE_ERROR("An unknown or invalid junction type occured in junction '" + id + "'.");
397  ok = false;
398  }
399  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_KEY, id.c_str(), ok, "");
400  // incoming lanes
401  std::vector<MSLane*> incomingLanes;
402  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INCLANES, ""), incomingLanes, ok);
403  // internal lanes
404  std::vector<MSLane*> internalLanes;
405 #ifdef HAVE_INTERNAL_LANES
407  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INTLANES, ""), internalLanes, ok);
408  }
409 #endif
410  if (!ok) {
411  myCurrentIsBroken = true;
412  } else {
413  try {
414  myJunctionControlBuilder.openJunction(id, key, type, x, y, shape, incomingLanes, internalLanes);
415  } catch (InvalidArgument& e) {
416  WRITE_ERROR(e.what() + std::string("\n Can not build according junction."));
417  myCurrentIsBroken = true;
418  }
419  }
420 }
421 
422 
423 void
424 NLHandler::parseLanes(const std::string& junctionID,
425  const std::string& def, std::vector<MSLane*>& into, bool& ok) {
426  StringTokenizer st(def);
427  while (ok && st.hasNext()) {
428  std::string laneID = st.next();
429  MSLane* lane = MSLane::dictionary(laneID);
430  if (!MSGlobals::gUsingInternalLanes && laneID[0] == ':') {
431  continue;
432  }
433  if (lane == 0) {
434  WRITE_ERROR("An unknown lane ('" + laneID + "') was tried to be set as incoming to junction '" + junctionID + "'.");
435  ok = false;
436  continue;
437  }
438  into.push_back(lane);
439  }
440 }
441 // ----
442 
443 void
445  bool ok = true;
446  std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, 0, ok);
447  std::string val = attrs.get<std::string>(SUMO_ATTR_VALUE, 0, ok);
448  if (myLastParameterised != 0) {
450  }
451  // set
452  if (ok && myAmInTLLogicMode) {
453  assert(key != "");
454  assert(val != "");
456  }
457 }
458 
459 
460 void
462  myCurrentIsBroken = false;
463  bool ok = true;
464  // get the id, report an error if not given or empty...
465  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
466  if (!ok) {
467  myCurrentIsBroken = true;
468  return;
469  }
470  SUMOTime t = attrs.getOptSUMOTimeReporting(SUMO_ATTR_REF_TIME, id.c_str(), ok, 0);
471  std::string pro = attrs.get<std::string>(SUMO_ATTR_START_PROG, id.c_str(), ok);
472  if (!ok) {
473  myCurrentIsBroken = true;
474  }
475  if (!myCurrentIsBroken) {
476  myCurrentWAUTID = id;
477  try {
479  } catch (InvalidArgument& e) {
480  WRITE_ERROR(e.what());
481  myCurrentIsBroken = true;
482  }
483  }
484 }
485 
486 
487 void
489  bool ok = true;
491  std::string to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentWAUTID.c_str(), ok);
492  if (!ok) {
493  myCurrentIsBroken = true;
494  }
495  if (!myCurrentIsBroken) {
496  try {
498  } catch (InvalidArgument& e) {
499  WRITE_ERROR(e.what());
500  myCurrentIsBroken = true;
501  }
502  }
503 }
504 
505 
506 void
508  bool ok = true;
509  std::string wautID = attrs.get<std::string>(SUMO_ATTR_WAUT_ID, 0, ok);
510  std::string junctionID = attrs.get<std::string>(SUMO_ATTR_JUNCTION_ID, 0, ok);
511  std::string procedure = attrs.getOpt<std::string>(SUMO_ATTR_PROCEDURE, 0, ok, "");
512  bool synchron = attrs.getOpt<bool>(SUMO_ATTR_SYNCHRON, 0, ok, false);
513  if (!ok) {
514  myCurrentIsBroken = true;
515  }
516  try {
517  if (!myCurrentIsBroken) {
518  myJunctionControlBuilder.getTLLogicControlToUse().addWAUTJunction(wautID, junctionID, procedure, synchron);
519  }
520  } catch (InvalidArgument& e) {
521  WRITE_ERROR(e.what());
522  myCurrentIsBroken = true;
523  }
524 }
525 
526 
527 
528 
529 
530 
531 
532 void
534  bool ok = true;
535  const SUMOReal INVALID_POSITION(-1000000);
536  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
537  SUMOReal x = attrs.getOpt<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok, INVALID_POSITION);
538  SUMOReal y = attrs.getOpt<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok, INVALID_POSITION);
539  SUMOReal lon = attrs.getOpt<SUMOReal>(SUMO_ATTR_LON, id.c_str(), ok, INVALID_POSITION);
540  SUMOReal lat = attrs.getOpt<SUMOReal>(SUMO_ATTR_LAT, id.c_str(), ok, INVALID_POSITION);
541  SUMOReal lanePos = attrs.getOpt<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok, INVALID_POSITION);
542  SUMOReal layer = attrs.getOpt<SUMOReal>(SUMO_ATTR_LAYER, id.c_str(), ok, (SUMOReal)GLO_POI);
543  std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
544  std::string laneID = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, "");
545  RGBColor color = attrs.hasAttribute(SUMO_ATTR_COLOR) ? attrs.get<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), ok) : RGBColor::RED;
546  SUMOReal angle = attrs.getOpt<SUMOReal>(SUMO_ATTR_ANGLE, id.c_str(), ok, Shape::DEFAULT_ANGLE);
547  std::string imgFile = attrs.getOpt<std::string>(SUMO_ATTR_IMGFILE, id.c_str(), ok, Shape::DEFAULT_IMG_FILE);
548  if (imgFile != "" && !FileHelpers::isAbsolute(imgFile)) {
550  }
551  SUMOReal width = attrs.getOpt<SUMOReal>(SUMO_ATTR_WIDTH, id.c_str(), ok, Shape::DEFAULT_IMG_WIDTH);
552  SUMOReal height = attrs.getOpt<SUMOReal>(SUMO_ATTR_HEIGHT, id.c_str(), ok, Shape::DEFAULT_IMG_HEIGHT);
553  if (!ok) {
554  return;
555  }
556  Position pos(x, y);
557  if (x == INVALID_POSITION || y == INVALID_POSITION) {
558  // try computing x,y from lane,pos
559  if (laneID != "") {
560  MSLane* lane = MSLane::dictionary(laneID);
561  if (lane == 0) {
562  WRITE_ERROR("Lane '" + laneID + "' to place a poi '" + id + "'on is not known.");
563  return;
564  }
565  if (lanePos < 0) {
566  lanePos = lane->getLength() + lanePos;
567  }
568  pos = lane->geometryPositionAtOffset(lanePos);
569  } else {
570  // try computing x,y from lon,lat
571  if (lat == INVALID_POSITION || lon == INVALID_POSITION) {
572  WRITE_ERROR("Either (x,y), (lon,lat) or (lane,pos) must be specified for poi '" + id + "'.");
573  return;
574  } else if (!GeoConvHelper::getFinal().usingGeoProjection()) {
575  WRITE_ERROR("(lon, lat) is specified for poi '" + id + "' but no geo-conversion is specified for the network.");
576  return;
577  }
578  pos.set(lon, lat);
580  }
581  }
582  if (!myNet.getShapeContainer().addPOI(id, type, color, layer, angle, imgFile, pos, width, height)) {
583  WRITE_ERROR("PoI '" + id + "' already exists.");
584  }
585 }
586 
587 
588 void
590  bool ok = true;
591  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
592  // get the id, report an error if not given or empty...
593  if (!ok) {
594  return;
595  }
596  SUMOReal layer = attrs.getOpt<SUMOReal>(SUMO_ATTR_LAYER, id.c_str(), ok, Shape::DEFAULT_LAYER);
597  bool fill = attrs.getOpt<bool>(SUMO_ATTR_FILL, id.c_str(), ok, false);
598  std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, Shape::DEFAULT_TYPE);
599  std::string colorStr = attrs.get<std::string>(SUMO_ATTR_COLOR, id.c_str(), ok);
600  RGBColor color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), ok);
601  PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
602  SUMOReal angle = attrs.getOpt<SUMOReal>(SUMO_ATTR_ANGLE, id.c_str(), ok, Shape::DEFAULT_ANGLE);
603  std::string imgFile = attrs.getOpt<std::string>(SUMO_ATTR_IMGFILE, id.c_str(), ok, Shape::DEFAULT_IMG_FILE);
604  if (imgFile != "" && !FileHelpers::isAbsolute(imgFile)) {
606  }
607  if (shape.size() != 0) {
608  if (!myNet.getShapeContainer().addPolygon(id, type, color, layer, angle, imgFile, shape, fill)) {
609  WRITE_WARNING("Skipping redefinition of polygon '" + id + "'.");
610  }
611  }
612 }
613 
614 
615 void
617  if (myCurrentIsBroken) {
618  return;
619  }
620  bool ok = true;
621  int request = attrs.get<int>(SUMO_ATTR_INDEX, 0, ok);
622  bool cont = false;
623 #ifdef HAVE_INTERNAL_LANES
624  cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, 0, ok, false);
625 #endif
626  std::string response = attrs.get<std::string>(SUMO_ATTR_RESPONSE, 0, ok);
627  std::string foes = attrs.get<std::string>(SUMO_ATTR_FOES, 0, ok);
628  if (!ok) {
629  return;
630  }
631  // store received information
632  if (request >= 0 && response.length() > 0) {
633  try {
634  myJunctionControlBuilder.addLogicItem(request, response, foes, cont);
635  } catch (InvalidArgument& e) {
636  WRITE_ERROR(e.what());
637  }
638  }
639 }
640 
641 
642 void
644  if (myCurrentIsBroken) {
645  return;
646  }
647  bool ok = true;
648  // we either a have a junction or a legacy network with ROWLogic
649  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
650  if (ok) {
652  }
653 }
654 
655 
656 void
658  myAmInTLLogicMode = true;
659  bool ok = true;
660  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
661  TrafficLightType type;
662  std::string typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
663  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
665  } else {
666  WRITE_ERROR("Traffic light '" + id + "' has unknown type '" + typeS + "'");
667  return;
668  }
669  //
670  SUMOTime offset = attrs.getOptSUMOTimeReporting(SUMO_ATTR_OFFSET, id.c_str(), ok, 0);
671  if (!ok) {
672  return;
673  }
674  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
675  myJunctionControlBuilder.initTrafficLightLogic(id, programID, type, offset);
676 }
677 
678 
679 void
681  // try to get the phase definition
682  bool ok = true;
683  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok);
684  if (!ok) {
685  return;
686  }
687  // try to get the phase duration
689  if (duration == 0) {
690  WRITE_ERROR("Duration of tls-logic '" + myJunctionControlBuilder.getActiveKey() + "/" + myJunctionControlBuilder.getActiveSubKey() + "' is zero.");
691  return;
692  }
693  // if the traffic light is an actuated traffic light, try to get
694  // the minimum and maximum durations
695  SUMOTime minDuration = attrs.getOptSUMOTimeReporting(
697  SUMOTime maxDuration = attrs.getOptSUMOTimeReporting(
699  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration);
700 }
701 
702 
703 void
705  bool ok = true;
706  // get the id, report an error if not given or empty...
707  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
708  if (!ok) {
709  return;
710  }
711  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
712  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
713  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
714  const bool splitByType = attrs.getOpt<bool>(SUMO_ATTR_SPLIT_VTYPE, id.c_str(), ok, false);
715  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
716  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
717  if (!ok) {
718  return;
719  }
720  try {
721  myDetectorBuilder.buildInductLoop(id, lane, position, frequency,
723  friendlyPos, splitByType);
724  } catch (InvalidArgument& e) {
725  WRITE_ERROR(e.what());
726  } catch (IOError& e) {
727  WRITE_ERROR(e.what());
728  }
729 }
730 
731 
732 void
734  bool ok = true;
735  // get the id, report an error if not given or empty...
736  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
737  if (!ok) {
738  return;
739  }
740  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
741  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
742  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
743  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
744  if (!ok) {
745  return;
746  }
747  try {
748  myDetectorBuilder.buildInstantInductLoop(id, lane, position, FileHelpers::checkForRelativity(file, getFileName()), friendlyPos);
749  } catch (InvalidArgument& e) {
750  WRITE_ERROR(e.what());
751  } catch (IOError& e) {
752  WRITE_ERROR(e.what());
753  }
754 }
755 
756 
757 void
759  bool ok = true;
760  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
761  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
762  std::string type = attrs.getStringSecure(SUMO_ATTR_TYPE, "");
763  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
764  if (!ok) {
765  return;
766  }
767  try {
769  } catch (InvalidArgument& e) {
770  WRITE_ERROR(e.what());
771  } catch (IOError& e) {
772  WRITE_ERROR(e.what());
773  }
774 }
775 
776 
777 void
779  bool ok = true;
780  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
781  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
782  SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, -1);
783  std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
784  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
785  if (!ok) {
786  return;
787  }
788  try {
789  myDetectorBuilder.buildRouteProbe(id, edge, frequency, begin,
791  } catch (InvalidArgument& e) {
792  WRITE_ERROR(e.what());
793  } catch (IOError& e) {
794  WRITE_ERROR(e.what());
795  }
796 }
797 
798 
799 
800 void
802  // check whether this is a detector connected to a tls an optionally to a link
803  bool ok = true;
804  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
805  const std::string lsaid = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), ok, "<invalid>");
806  const std::string toLane = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "<invalid>");
807  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
808  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
809  const SUMOReal jamDistThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, 10.0f);
810  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
811  const SUMOReal length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, id.c_str(), ok);
812  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
813  const bool cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, id.c_str(), ok, false);
814  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
815  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
816  if (!ok) {
817  return;
818  }
819  try {
820  if (lsaid != "<invalid>") {
821  if (toLane == "<invalid>") {
822  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont,
825  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
826  friendlyPos);
827  } else {
828  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont,
829  myJunctionControlBuilder.getTLLogic(lsaid), toLane,
831  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
832  friendlyPos);
833  }
834  } else {
835  bool ok = true;
836  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
837  if (!ok) {
838  return;
839  }
840  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont, frequency,
842  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
843  friendlyPos);
844  }
845  } catch (InvalidArgument& e) {
846  WRITE_ERROR(e.what());
847  } catch (IOError& e) {
848  WRITE_ERROR(e.what());
849  }
850 }
851 
852 
853 void
855  bool ok = true;
856  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
857  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
858  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
859  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
860  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
861  if (!ok) {
862  return;
863  }
864  try {
867  frequency, haltingSpeedThreshold, haltingTimeThreshold);
868  } catch (InvalidArgument& e) {
869  WRITE_ERROR(e.what());
870  } catch (IOError& e) {
871  WRITE_ERROR(e.what());
872  }
873 }
874 
875 
876 void
878  bool ok = true;
879  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
880  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
881  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
882  if (!ok) {
883  return;
884  }
885  myDetectorBuilder.addE3Entry(lane, position, friendlyPos);
886 }
887 
888 
889 void
891  bool ok = true;
892  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
893  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
894  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
895  if (!ok) {
896  return;
897  }
898  myDetectorBuilder.addE3Exit(lane, position, friendlyPos);
899 }
900 
901 
902 void
903 NLHandler::addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype) {
904  bool ok = true;
905  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
906  const SUMOReal maxTravelTime = attrs.getOpt<SUMOReal>(SUMO_ATTR_MAX_TRAVELTIME, id.c_str(), ok, 100000);
907  const SUMOReal minSamples = attrs.getOpt<SUMOReal>(SUMO_ATTR_MIN_SAMPLES, id.c_str(), ok, 0);
908  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, POSITION_EPS);
909  const std::string excludeEmpty = attrs.getOpt<std::string>(SUMO_ATTR_EXCLUDE_EMPTY, id.c_str(), ok, "false");
910  const bool withInternal = attrs.getOpt<bool>(SUMO_ATTR_WITH_INTERNAL, id.c_str(), ok, false);
911  const bool trackVehicles = attrs.getOpt<bool>(SUMO_ATTR_TRACK_VEHICLES, id.c_str(), ok, false);
912  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
913  const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "performance");
914  std::string vtypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
915  const SUMOTime frequency = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, -1);
916  const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("begin")));
917  const SUMOTime end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("end")));
918  if (!ok) {
919  return;
920  }
921  try {
922  myDetectorBuilder.createEdgeLaneMeanData(id, frequency, begin, end,
923  type, objecttype == SUMO_TAG_MEANDATA_LANE,
924  // equivalent to TplConvert::_2bool used in SUMOSAXAttributes::getBool
925  excludeEmpty[0] != 't' && excludeEmpty[0] != 'T' && excludeEmpty[0] != '1' && excludeEmpty[0] != 'x',
926  excludeEmpty == "defaults", withInternal, trackVehicles,
927  maxTravelTime, minSamples, haltingSpeedThreshold, vtypes,
929  } catch (InvalidArgument& e) {
930  WRITE_ERROR(e.what());
931  } catch (IOError& e) {
932  WRITE_ERROR(e.what());
933  }
934 }
935 
936 
937 void
939  bool ok = true;
940  std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
941  if (!MSGlobals::gUsingInternalLanes && fromID[0] == ':') {
942  return;
943  }
944 
945  try {
946  bool ok = true;
947  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
948  const int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, 0, ok);
949  const int toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, 0, ok);
950  LinkDirection dir = parseLinkDir(attrs.get<std::string>(SUMO_ATTR_DIR, 0, ok));
951  LinkState state = parseLinkState(attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok));
952  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, 0, ok, "");
953 #ifdef HAVE_INTERNAL_LANES
954  std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, 0, ok, "");
955 #endif
956 
957  MSEdge* from = MSEdge::dictionary(fromID);
958  if (from == 0) {
959  WRITE_ERROR("Unknown from-edge '" + fromID + "' in connection");
960  return;
961  }
962  MSEdge* to = MSEdge::dictionary(toID);
963  if (to == 0) {
964  WRITE_ERROR("Unknown to-edge '" + toID + "' in connection");
965  return;
966  }
967  if (fromLaneIdx < 0 || static_cast<unsigned int>(fromLaneIdx) >= from->getLanes().size() ||
968  toLaneIdx < 0 || static_cast<unsigned int>(toLaneIdx) >= to->getLanes().size()) {
969  WRITE_ERROR("Invalid lane index in connection from '" + from->getID() + "' to '" + to->getID() + "'.");
970  return;
971  }
972  MSLane* fromLane = from->getLanes()[fromLaneIdx];
973  MSLane* toLane = to->getLanes()[toLaneIdx];
974  assert(fromLane);
975  assert(toLane);
976 
977  int tlLinkIdx = -1;
978  if (tlID != "") {
979  tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, 0, ok);
980  // make sure that the index is in range
982  if (tlLinkIdx < 0 || tlLinkIdx >= (int)logic->getCurrentPhaseDef().getState().size()) {
983  WRITE_ERROR("Invalid " + toString(SUMO_ATTR_TLLINKINDEX) + " '" + toString(tlLinkIdx) +
984  "' in connection controlled by '" + tlID + "'");
985  return;
986  }
987  if (!ok) {
988  return;
989  }
990  }
991  SUMOReal length = fromLane->getShape()[-1].distanceTo(toLane->getShape()[0]);
992  MSLink* link = 0;
993 
994  // build the link
995 #ifdef HAVE_INTERNAL_LANES
996  MSLane* via = 0;
997  if (viaID != "" && MSGlobals::gUsingInternalLanes) {
998  via = MSLane::dictionary(viaID);
999  if (via == 0) {
1000  WRITE_ERROR("An unknown lane ('" + viaID +
1001  "') should be set as a via-lane for lane '" + toLane->getID() + "'.");
1002  return;
1003  }
1004  length = via->getLength();
1005  }
1006  link = new MSLink(toLane, via, dir, state, length);
1007  if (via != 0) {
1008  via->addIncomingLane(fromLane, link);
1009  } else {
1010  toLane->addIncomingLane(fromLane, link);
1011  }
1012 #else
1013  link = new MSLink(toLane, dir, state, length);
1014  toLane->addIncomingLane(fromLane, link);
1015 #endif
1016  toLane->addApproachingLane(fromLane);
1017 
1018  // if a traffic light is responsible for it, inform the traffic light
1019  // check whether this link is controlled by a traffic light
1020  if (tlID != "") {
1021  myJunctionControlBuilder.getTLLogic(tlID).addLink(link, fromLane, tlLinkIdx);
1022  }
1023  // add the link
1024  fromLane->addLink(link);
1025 
1026  } catch (InvalidArgument& e) {
1027  WRITE_ERROR(e.what());
1028  }
1029 }
1030 
1031 
1033 NLHandler::parseLinkDir(const std::string& dir) {
1034  if (SUMOXMLDefinitions::LinkDirections.hasString(dir)) {
1036  } else {
1037  throw InvalidArgument("Unrecognised link direction '" + dir + "'.");
1038  }
1039 }
1040 
1041 
1042 LinkState
1043 NLHandler::parseLinkState(const std::string& state) {
1044  if (SUMOXMLDefinitions::LinkStates.hasString(state)) {
1045  return SUMOXMLDefinitions::LinkStates.get(state);
1046  } else {
1047  if (state == "t") { // legacy networks
1048  // WRITE_WARNING("Obsolete link state 't'. Use 'o' instead");
1050  } else {
1051  throw InvalidArgument("Unrecognised link state '" + state + "'.");
1052  }
1053  }
1054 }
1055 
1056 
1057 // ----------------------------------
1058 void
1060  bool ok = true;
1062  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, 0, ok);
1063  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, 0, ok);
1064  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, 0, ok);
1065  if (ok) {
1066  Position networkOffset = s[0];
1067  GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
1068  if (OptionsCont::getOptions().getBool("fcd-output.geo") && !GeoConvHelper::getFinal().usingGeoProjection()) {
1069  WRITE_WARNING("no valid geo projection loaded from network. fcd-output.geo will not work");
1070  }
1071  }
1072 }
1073 
1074 
1075 void
1077  bool ok = true;
1078  myCurrentIsBroken = false;
1079  // get the id, report an error if not given or empty...
1080  myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1081  if (!ok) {
1082  myCurrentIsBroken = true;
1083  return;
1084  }
1085  try {
1087  if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) {
1088  delete sink;
1089  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists.");
1090  }
1091  sink->initialize(new std::vector<MSLane*>());
1093  if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) {
1094  delete source;
1095  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists.");
1096  }
1097  source->initialize(new std::vector<MSLane*>());
1098  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1099  std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES);
1100  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
1101  MSEdge* edge = MSEdge::dictionary(*i);
1102  // check whether the edge exists
1103  if (edge == 0) {
1104  throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known.");
1105  }
1106  source->addFollower(edge);
1107  edge->addFollower(sink);
1108  }
1109  }
1110  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
1112  if (shape.size() != 0) {
1113  if (!myNet.getShapeContainer().addPolygon(myCurrentDistrictID, "taz", RGBColor::parseColor("1.0,.33,.33"), 0, 0, "", shape, false)) {
1114  WRITE_WARNING("Skipping visualization of taz '" + myCurrentDistrictID + "', polygon already exists.");
1115  }
1116  }
1117  }
1118  } catch (InvalidArgument& e) {
1119  WRITE_ERROR(e.what());
1120  myCurrentIsBroken = true;
1121  }
1122 }
1123 
1124 
1125 void
1126 NLHandler::addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource) {
1127  if (myCurrentIsBroken) {
1128  // earlier error
1129  return;
1130  }
1131  bool ok = true;
1132  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentDistrictID.c_str(), ok);
1133  MSEdge* succ = MSEdge::dictionary(id);
1134  if (succ != 0) {
1135  // connect edge
1136  if (isSource) {
1137  MSEdge::dictionary(myCurrentDistrictID + "-source")->addFollower(succ);
1138  } else {
1139  succ->addFollower(MSEdge::dictionary(myCurrentDistrictID + "-sink"));
1140  }
1141  } else {
1142  WRITE_ERROR("At district '" + myCurrentDistrictID + "': succeeding edge '" + id + "' does not exist.");
1143  }
1144 }
1145 
1146 
1147 void
1149  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1150  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
1151  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
1152  MSEdge* edge = MSEdge::dictionary(*it);
1153  if (edge == 0) {
1154  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
1155  } else {
1156  edge->markAsRoundabout();
1157  }
1158  }
1159  } else {
1160  WRITE_ERROR("Empty edges in roundabout.");
1161  }
1162 }
1163 
1164 
1165 // ----------------------------------
1166 void
1168  try {
1170  } catch (InvalidArgument& e) {
1171  WRITE_ERROR(e.what());
1172  }
1173 }
1174 
1175 
1176 void
1178  if (!myCurrentIsBroken) {
1179  try {
1181  } catch (InvalidArgument& e) {
1182  WRITE_ERROR(e.what());
1183  myCurrentIsBroken = true;
1184  }
1185  }
1186  myCurrentWAUTID = "";
1187 }
1188 
1189 
1190 /****************************************************************************/
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:854
void addPoly(const SUMOSAXAttributes &attrs)
adds a polygon
Definition: NLHandler.cpp:589
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:507
Builds detectors for microsim.
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:801
static RGBColor parseColor(std::string coldef)
Parses a color information.
Definition: RGBColor.cpp:154
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:85
bool myCurrentIsInternalToSkip
Information whether the currently parsed edge is internal and not wished, here.
Definition: NLHandler.h:272
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:41
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:151
virtual MSEdge * closeEdge()
Closes the building of an edge; The edge is completely described by now and may not be opened again...
virtual void openWAUT(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:461
const Position geometryPositionAtOffset(SUMOReal offset) const
Definition: MSLane.h:335
bool myCurrentIsBroken
Definition: NLHandler.h:302
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:168
void parseLanes(const std::string &junctionID, const std::string &def, std::vector< MSLane * > &into, bool &ok)
Definition: NLHandler.cpp:424
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:365
void addLink(MSLink *link)
Delayed initialization.
Definition: MSLane.cpp:105
virtual void addVTypeProbeDetector(const SUMOSAXAttributes &attrs)
Builds a vtype-detector using the given specification.
Definition: NLHandler.cpp:758
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1148
NLDetectorBuilder & myDetectorBuilder
The detector builder to use.
Definition: NLHandler.h:276
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:88
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1015
virtual MSEdge * buildEdge(const std::string &id, const MSEdge::EdgeBasicFunction function, const std::string &streetName="")
Builds an edge instance (MSEdge in this case)
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:465
virtual void addE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:704
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:256
maximum duration of a phase
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
static StringBijection< LinkState > LinkStates
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:288
EdgeBasicFunction
Defines possible edge types.
Definition: MSEdge.h:82
static const std::string DEFAULT_TYPE
Definition: Shape.h:148
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:1167
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:84
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:196
The simulated network and simulation perfomer.
Definition: MSNet.h:89
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
bool myAmInTLLogicMode
internal information whether a tls-logic is currently read
Definition: NLHandler.h:291
void initialize(std::vector< MSLane * > *lanes)
Initialize the edge.
Definition: MSEdge.cpp:94
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:1177
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:444
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1076
The state of a link.
static const SUMOReal DEFAULT_ANGLE
Definition: Shape.h:150
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:73
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
Definition: NLHandler.cpp:1059
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:377
const std::string & getFileName() const
returns the current file name
NLEdgeControlBuilder & myEdgeControlBuilder
The edge builder to use.
Definition: NLHandler.h:282
The edge is a district edge.
Definition: MSEdge.h:92
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:877
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:890
static StringBijection< TrafficLightType > TrafficLightTypes
Builder of microsim-junctions and tls.
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:354
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:153
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:488
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:616
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:938
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
void closeJunction()
Closes (ends) the processing of the current junction.
#define POSITION_EPS
Definition: config.h:186
bool myHaveSeenInternalEdge
whether the loaded network contains internal lanes
Definition: NLHandler.h:309
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1033
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:70
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers. ...
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:51
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;.
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:149
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:201
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:294
T get(const std::string &str)
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:812
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:733
static const RGBColor RED
Definition: RGBColor.h:188
virtual void closeEdge()
Closes the process of building an edge.
Definition: NLHandler.cpp:311
virtual void addRouteProbeDetector(const SUMOSAXAttributes &attrs)
Builds a routeProbe-detector using the given specification.
Definition: NLHandler.cpp:778
void addLane(const SUMOSAXAttributes &attrs)
adds a lane to the previously opened edge
Definition: NLHandler.cpp:327
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:279
void initJunctionLogic(const std::string &id)
Initialises a junction logic.
The edge is a normal street.
Definition: MSEdge.h:86
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.
void addFollower(MSEdge *edge)
Returns the list of edges which may be reached from this edge.
Definition: MSEdge.h:232
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:680
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1126
MSNet & myNet
The net to fill (preinitialised)
Definition: NLHandler.h:184
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:1043
The abstract direction of a link.
virtual void closeTrafficLightLogic()
Ends the building of a traffic lights logic.
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.
#define SUMOReal
Definition: config.h:215
NLDiscreteEventBuilder myActionBuilder
A builder for object actions.
Definition: NLHandler.h:269
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.
void beginEdgeParsing(const std::string &id, const MSEdge::EdgeBasicFunction function, const std::string &streetName)
Begins building of an MSEdge.
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:452
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:903
Builds trigger objects for microsim.
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:643
The edge is an internal edge.
Definition: MSEdge.h:90
Parameterised * myLastParameterised
Definition: NLHandler.h:306
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:285
Parser and container for routes during their loading.
void addApproachingLane(MSLane *lane)
Definition: MSLane.cpp:1025
TrafficLightType
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:657
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:152
void addPOI(const SUMOSAXAttributes &attrs)
adds a polygon
Definition: NLHandler.cpp:533