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-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/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  if (shape.size() > 2) {
391  shape.closePolygon();
392  }
393  }
394  SUMOReal x = attrs.get<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok);
395  SUMOReal y = attrs.get<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok);
396  bool typeOK = true;
397  SumoXMLNodeType type = attrs.getNodeType(typeOK);
398  if (!typeOK) {
399  WRITE_ERROR("An unknown or invalid junction type occured in junction '" + id + "'.");
400  ok = false;
401  }
402  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_KEY, id.c_str(), ok, "");
403  // incoming lanes
404  std::vector<MSLane*> incomingLanes;
405  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INCLANES, ""), incomingLanes, ok);
406  // internal lanes
407  std::vector<MSLane*> internalLanes;
408 #ifdef HAVE_INTERNAL_LANES
410  parseLanes(id, attrs.getStringSecure(SUMO_ATTR_INTLANES, ""), internalLanes, ok);
411  }
412 #endif
413  if (!ok) {
414  myCurrentIsBroken = true;
415  } else {
416  try {
417  myJunctionControlBuilder.openJunction(id, key, type, x, y, shape, incomingLanes, internalLanes);
418  } catch (InvalidArgument& e) {
419  WRITE_ERROR(e.what() + std::string("\n Can not build according junction."));
420  myCurrentIsBroken = true;
421  }
422  }
423 }
424 
425 
426 void
427 NLHandler::parseLanes(const std::string& junctionID,
428  const std::string& def, std::vector<MSLane*>& into, bool& ok) {
429  StringTokenizer st(def);
430  while (ok && st.hasNext()) {
431  std::string laneID = st.next();
432  MSLane* lane = MSLane::dictionary(laneID);
433  if (!MSGlobals::gUsingInternalLanes && laneID[0] == ':') {
434  continue;
435  }
436  if (lane == 0) {
437  WRITE_ERROR("An unknown lane ('" + laneID + "') was tried to be set as incoming to junction '" + junctionID + "'.");
438  ok = false;
439  continue;
440  }
441  into.push_back(lane);
442  }
443 }
444 // ----
445 
446 void
448  bool ok = true;
449  std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, 0, ok);
450  std::string val = attrs.get<std::string>(SUMO_ATTR_VALUE, 0, ok);
451  if (myLastParameterised != 0) {
453  }
454  // set
455  if (ok && myAmInTLLogicMode) {
456  assert(key != "");
457  assert(val != "");
459  }
460 }
461 
462 
463 void
465  myCurrentIsBroken = false;
466  bool ok = true;
467  // get the id, report an error if not given or empty...
468  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
469  if (!ok) {
470  myCurrentIsBroken = true;
471  return;
472  }
473  SUMOTime t = attrs.getOptSUMOTimeReporting(SUMO_ATTR_REF_TIME, id.c_str(), ok, 0);
474  std::string pro = attrs.get<std::string>(SUMO_ATTR_START_PROG, id.c_str(), ok);
475  if (!ok) {
476  myCurrentIsBroken = true;
477  }
478  if (!myCurrentIsBroken) {
479  myCurrentWAUTID = id;
480  try {
482  } catch (InvalidArgument& e) {
483  WRITE_ERROR(e.what());
484  myCurrentIsBroken = true;
485  }
486  }
487 }
488 
489 
490 void
492  bool ok = true;
494  std::string to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentWAUTID.c_str(), ok);
495  if (!ok) {
496  myCurrentIsBroken = true;
497  }
498  if (!myCurrentIsBroken) {
499  try {
501  } catch (InvalidArgument& e) {
502  WRITE_ERROR(e.what());
503  myCurrentIsBroken = true;
504  }
505  }
506 }
507 
508 
509 void
511  bool ok = true;
512  std::string wautID = attrs.get<std::string>(SUMO_ATTR_WAUT_ID, 0, ok);
513  std::string junctionID = attrs.get<std::string>(SUMO_ATTR_JUNCTION_ID, 0, ok);
514  std::string procedure = attrs.getOpt<std::string>(SUMO_ATTR_PROCEDURE, 0, ok, "");
515  bool synchron = attrs.getOpt<bool>(SUMO_ATTR_SYNCHRON, 0, ok, false);
516  if (!ok) {
517  myCurrentIsBroken = true;
518  }
519  try {
520  if (!myCurrentIsBroken) {
521  myJunctionControlBuilder.getTLLogicControlToUse().addWAUTJunction(wautID, junctionID, procedure, synchron);
522  }
523  } catch (InvalidArgument& e) {
524  WRITE_ERROR(e.what());
525  myCurrentIsBroken = true;
526  }
527 }
528 
529 
530 
531 
532 
533 
534 
535 void
537  bool ok = true;
538  const SUMOReal INVALID_POSITION(-1000000);
539  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
540  SUMOReal x = attrs.getOpt<SUMOReal>(SUMO_ATTR_X, id.c_str(), ok, INVALID_POSITION);
541  SUMOReal y = attrs.getOpt<SUMOReal>(SUMO_ATTR_Y, id.c_str(), ok, INVALID_POSITION);
542  SUMOReal lon = attrs.getOpt<SUMOReal>(SUMO_ATTR_LON, id.c_str(), ok, INVALID_POSITION);
543  SUMOReal lat = attrs.getOpt<SUMOReal>(SUMO_ATTR_LAT, id.c_str(), ok, INVALID_POSITION);
544  SUMOReal lanePos = attrs.getOpt<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok, INVALID_POSITION);
545  SUMOReal layer = attrs.getOpt<SUMOReal>(SUMO_ATTR_LAYER, id.c_str(), ok, (SUMOReal)GLO_POI);
546  std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
547  std::string laneID = attrs.getOpt<std::string>(SUMO_ATTR_LANE, id.c_str(), ok, "");
548  RGBColor color = attrs.hasAttribute(SUMO_ATTR_COLOR) ? attrs.get<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), ok) : RGBColor::RED;
549  SUMOReal angle = attrs.getOpt<SUMOReal>(SUMO_ATTR_ANGLE, id.c_str(), ok, Shape::DEFAULT_ANGLE);
550  std::string imgFile = attrs.getOpt<std::string>(SUMO_ATTR_IMGFILE, id.c_str(), ok, Shape::DEFAULT_IMG_FILE);
551  if (imgFile != "" && !FileHelpers::isAbsolute(imgFile)) {
553  }
554  SUMOReal width = attrs.getOpt<SUMOReal>(SUMO_ATTR_WIDTH, id.c_str(), ok, Shape::DEFAULT_IMG_WIDTH);
555  SUMOReal height = attrs.getOpt<SUMOReal>(SUMO_ATTR_HEIGHT, id.c_str(), ok, Shape::DEFAULT_IMG_HEIGHT);
556  if (!ok) {
557  return;
558  }
559  Position pos(x, y);
560  if (x == INVALID_POSITION || y == INVALID_POSITION) {
561  // try computing x,y from lane,pos
562  if (laneID != "") {
563  MSLane* lane = MSLane::dictionary(laneID);
564  if (lane == 0) {
565  WRITE_ERROR("Lane '" + laneID + "' to place poi '" + id + "' on is not known.");
566  return;
567  }
568  if (lanePos < 0) {
569  lanePos = lane->getLength() + lanePos;
570  }
571  pos = lane->geometryPositionAtOffset(lanePos);
572  } else {
573  // try computing x,y from lon,lat
574  if (lat == INVALID_POSITION || lon == INVALID_POSITION) {
575  WRITE_ERROR("Either (x,y), (lon,lat) or (lane,pos) must be specified for poi '" + id + "'.");
576  return;
577  } else if (!GeoConvHelper::getFinal().usingGeoProjection()) {
578  WRITE_ERROR("(lon, lat) is specified for poi '" + id + "' but no geo-conversion is specified for the network.");
579  return;
580  }
581  pos.set(lon, lat);
583  }
584  }
585  if (!myNet.getShapeContainer().addPOI(id, type, color, layer, angle, imgFile, pos, width, height)) {
586  WRITE_ERROR("PoI '" + id + "' already exists.");
587  }
588 }
589 
590 
591 void
593  bool ok = true;
594  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
595  // get the id, report an error if not given or empty...
596  if (!ok) {
597  return;
598  }
599  SUMOReal layer = attrs.getOpt<SUMOReal>(SUMO_ATTR_LAYER, id.c_str(), ok, Shape::DEFAULT_LAYER);
600  bool fill = attrs.getOpt<bool>(SUMO_ATTR_FILL, id.c_str(), ok, false);
601  std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, Shape::DEFAULT_TYPE);
602  std::string colorStr = attrs.get<std::string>(SUMO_ATTR_COLOR, id.c_str(), ok);
603  RGBColor color = attrs.get<RGBColor>(SUMO_ATTR_COLOR, id.c_str(), ok);
604  PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
605  SUMOReal angle = attrs.getOpt<SUMOReal>(SUMO_ATTR_ANGLE, id.c_str(), ok, Shape::DEFAULT_ANGLE);
606  std::string imgFile = attrs.getOpt<std::string>(SUMO_ATTR_IMGFILE, id.c_str(), ok, Shape::DEFAULT_IMG_FILE);
607  if (imgFile != "" && !FileHelpers::isAbsolute(imgFile)) {
609  }
610  if (shape.size() != 0) {
611  if (!myNet.getShapeContainer().addPolygon(id, type, color, layer, angle, imgFile, shape, fill)) {
612  WRITE_WARNING("Skipping redefinition of polygon '" + id + "'.");
613  }
614  }
615 }
616 
617 
618 void
620  if (myCurrentIsBroken) {
621  return;
622  }
623  bool ok = true;
624  int request = attrs.get<int>(SUMO_ATTR_INDEX, 0, ok);
625  bool cont = false;
626 #ifdef HAVE_INTERNAL_LANES
627  cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, 0, ok, false);
628 #endif
629  std::string response = attrs.get<std::string>(SUMO_ATTR_RESPONSE, 0, ok);
630  std::string foes = attrs.get<std::string>(SUMO_ATTR_FOES, 0, ok);
631  if (!ok) {
632  return;
633  }
634  // store received information
635  if (request >= 0 && response.length() > 0) {
636  try {
637  myJunctionControlBuilder.addLogicItem(request, response, foes, cont);
638  } catch (InvalidArgument& e) {
639  WRITE_ERROR(e.what());
640  }
641  }
642 }
643 
644 
645 void
647  if (myCurrentIsBroken) {
648  return;
649  }
650  bool ok = true;
651  // we either a have a junction or a legacy network with ROWLogic
652  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
653  if (ok) {
655  }
656 }
657 
658 
659 void
661  myAmInTLLogicMode = true;
662  bool ok = true;
663  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
664  TrafficLightType type;
665  std::string typeS = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
666  if (SUMOXMLDefinitions::TrafficLightTypes.hasString(typeS)) {
668  } else {
669  WRITE_ERROR("Traffic light '" + id + "' has unknown type '" + typeS + "'");
670  return;
671  }
672  //
673  SUMOTime offset = attrs.getOptSUMOTimeReporting(SUMO_ATTR_OFFSET, id.c_str(), ok, 0);
674  if (!ok) {
675  return;
676  }
677  std::string programID = attrs.getOpt<std::string>(SUMO_ATTR_PROGRAMID, id.c_str(), ok, "<unknown>");
678  myJunctionControlBuilder.initTrafficLightLogic(id, programID, type, offset);
679 }
680 
681 
682 void
684  // try to get the phase definition
685  bool ok = true;
686  std::string state = attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok);
687  if (!ok) {
688  return;
689  }
690  // try to get the phase duration
692  if (duration == 0) {
693  WRITE_ERROR("Duration of tls-logic '" + myJunctionControlBuilder.getActiveKey() + "/" + myJunctionControlBuilder.getActiveSubKey() + "' is zero.");
694  return;
695  }
696  // if the traffic light is an actuated traffic light, try to get
697  // the minimum and maximum durations
698  SUMOTime minDuration = attrs.getOptSUMOTimeReporting(
700  SUMOTime maxDuration = attrs.getOptSUMOTimeReporting(
702  myJunctionControlBuilder.addPhase(duration, state, minDuration, maxDuration);
703 }
704 
705 
706 void
708  bool ok = true;
709  // get the id, report an error if not given or empty...
710  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
711  if (!ok) {
712  return;
713  }
714  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
715  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
716  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
717  const bool splitByType = attrs.getOpt<bool>(SUMO_ATTR_SPLIT_VTYPE, id.c_str(), ok, false);
718  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
719  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
720  if (!ok) {
721  return;
722  }
723  try {
724  myDetectorBuilder.buildInductLoop(id, lane, position, frequency,
726  friendlyPos, splitByType);
727  } catch (InvalidArgument& e) {
728  WRITE_ERROR(e.what());
729  } catch (IOError& e) {
730  WRITE_ERROR(e.what());
731  }
732 }
733 
734 
735 void
737  bool ok = true;
738  // get the id, report an error if not given or empty...
739  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
740  if (!ok) {
741  return;
742  }
743  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
744  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
745  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
746  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
747  if (!ok) {
748  return;
749  }
750  try {
751  myDetectorBuilder.buildInstantInductLoop(id, lane, position, FileHelpers::checkForRelativity(file, getFileName()), friendlyPos);
752  } catch (InvalidArgument& e) {
753  WRITE_ERROR(e.what());
754  } catch (IOError& e) {
755  WRITE_ERROR(e.what());
756  }
757 }
758 
759 
760 void
762  bool ok = true;
763  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
764  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
765  std::string type = attrs.getStringSecure(SUMO_ATTR_TYPE, "");
766  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
767  if (!ok) {
768  return;
769  }
770  try {
772  } catch (InvalidArgument& e) {
773  WRITE_ERROR(e.what());
774  } catch (IOError& e) {
775  WRITE_ERROR(e.what());
776  }
777 }
778 
779 
780 void
782  bool ok = true;
783  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
784  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
785  SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, -1);
786  std::string edge = attrs.get<std::string>(SUMO_ATTR_EDGE, id.c_str(), ok);
787  std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
788  if (!ok) {
789  return;
790  }
791  try {
792  myDetectorBuilder.buildRouteProbe(id, edge, frequency, begin,
794  } catch (InvalidArgument& e) {
795  WRITE_ERROR(e.what());
796  } catch (IOError& e) {
797  WRITE_ERROR(e.what());
798  }
799 }
800 
801 
802 
803 void
805  // check whether this is a detector connected to a tls an optionally to a link
806  bool ok = true;
807  const std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
808  const std::string lsaid = attrs.getOpt<std::string>(SUMO_ATTR_TLID, id.c_str(), ok, "<invalid>");
809  const std::string toLane = attrs.getOpt<std::string>(SUMO_ATTR_TO, id.c_str(), ok, "<invalid>");
810  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
811  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
812  const SUMOReal jamDistThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_JAM_DIST_THRESHOLD, id.c_str(), ok, 10.0f);
813  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, id.c_str(), ok);
814  const SUMOReal length = attrs.get<SUMOReal>(SUMO_ATTR_LENGTH, id.c_str(), ok);
815  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
816  const bool cont = attrs.getOpt<bool>(SUMO_ATTR_CONT, id.c_str(), ok, false);
817  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, id.c_str(), ok);
818  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
819  if (!ok) {
820  return;
821  }
822  try {
823  if (lsaid != "<invalid>") {
824  if (toLane == "<invalid>") {
825  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont,
828  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
829  friendlyPos);
830  } else {
831  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont,
832  myJunctionControlBuilder.getTLLogic(lsaid), toLane,
834  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
835  friendlyPos);
836  }
837  } else {
838  bool ok = true;
839  SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
840  if (!ok) {
841  return;
842  }
843  myDetectorBuilder.buildE2Detector(id, lane, position, length, cont, frequency,
845  haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold,
846  friendlyPos);
847  }
848  } catch (InvalidArgument& e) {
849  WRITE_ERROR(e.what());
850  } catch (IOError& e) {
851  WRITE_ERROR(e.what());
852  }
853 }
854 
855 
856 void
858  bool ok = true;
859  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
860  const SUMOTime frequency = attrs.getSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok);
861  const SUMOTime haltingTimeThreshold = attrs.getOptSUMOTimeReporting(SUMO_ATTR_HALTING_TIME_THRESHOLD, id.c_str(), ok, TIME2STEPS(1));
862  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, 5.0f / 3.6f);
863  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
864  if (!ok) {
865  return;
866  }
867  try {
870  frequency, haltingSpeedThreshold, haltingTimeThreshold);
871  } catch (InvalidArgument& e) {
872  WRITE_ERROR(e.what());
873  } catch (IOError& e) {
874  WRITE_ERROR(e.what());
875  }
876 }
877 
878 
879 void
881  bool ok = true;
882  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
883  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
884  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
885  if (!ok) {
886  return;
887  }
888  myDetectorBuilder.addE3Entry(lane, position, friendlyPos);
889 }
890 
891 
892 void
894  bool ok = true;
895  const SUMOReal position = attrs.get<SUMOReal>(SUMO_ATTR_POSITION, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
896  const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, myDetectorBuilder.getCurrentE3ID().c_str(), ok, false);
897  const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, myDetectorBuilder.getCurrentE3ID().c_str(), ok);
898  if (!ok) {
899  return;
900  }
901  myDetectorBuilder.addE3Exit(lane, position, friendlyPos);
902 }
903 
904 
905 void
906 NLHandler::addEdgeLaneMeanData(const SUMOSAXAttributes& attrs, int objecttype) {
907  bool ok = true;
908  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
909  const SUMOReal maxTravelTime = attrs.getOpt<SUMOReal>(SUMO_ATTR_MAX_TRAVELTIME, id.c_str(), ok, 100000);
910  const SUMOReal minSamples = attrs.getOpt<SUMOReal>(SUMO_ATTR_MIN_SAMPLES, id.c_str(), ok, 0);
911  const SUMOReal haltingSpeedThreshold = attrs.getOpt<SUMOReal>(SUMO_ATTR_HALTING_SPEED_THRESHOLD, id.c_str(), ok, POSITION_EPS);
912  const std::string excludeEmpty = attrs.getOpt<std::string>(SUMO_ATTR_EXCLUDE_EMPTY, id.c_str(), ok, "false");
913  const bool withInternal = attrs.getOpt<bool>(SUMO_ATTR_WITH_INTERNAL, id.c_str(), ok, false);
914  const bool trackVehicles = attrs.getOpt<bool>(SUMO_ATTR_TRACK_VEHICLES, id.c_str(), ok, false);
915  const std::string file = attrs.get<std::string>(SUMO_ATTR_FILE, id.c_str(), ok);
916  const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "performance");
917  std::string vtypes = attrs.getOpt<std::string>(SUMO_ATTR_VTYPES, id.c_str(), ok, "");
918  const SUMOTime frequency = attrs.getOptSUMOTimeReporting(SUMO_ATTR_FREQUENCY, id.c_str(), ok, -1);
919  const SUMOTime begin = attrs.getOptSUMOTimeReporting(SUMO_ATTR_BEGIN, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("begin")));
920  const SUMOTime end = attrs.getOptSUMOTimeReporting(SUMO_ATTR_END, id.c_str(), ok, string2time(OptionsCont::getOptions().getString("end")));
921  if (!ok) {
922  return;
923  }
924  try {
925  myDetectorBuilder.createEdgeLaneMeanData(id, frequency, begin, end,
926  type, objecttype == SUMO_TAG_MEANDATA_LANE,
927  // equivalent to TplConvert::_2bool used in SUMOSAXAttributes::getBool
928  excludeEmpty[0] != 't' && excludeEmpty[0] != 'T' && excludeEmpty[0] != '1' && excludeEmpty[0] != 'x',
929  excludeEmpty == "defaults", withInternal, trackVehicles,
930  maxTravelTime, minSamples, haltingSpeedThreshold, vtypes,
932  } catch (InvalidArgument& e) {
933  WRITE_ERROR(e.what());
934  } catch (IOError& e) {
935  WRITE_ERROR(e.what());
936  }
937 }
938 
939 
940 void
942  bool ok = true;
943  std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, 0, ok);
944  if (!MSGlobals::gUsingInternalLanes && fromID[0] == ':') {
945  return;
946  }
947 
948  try {
949  bool ok = true;
950  const std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, 0, ok);
951  const int fromLaneIdx = attrs.get<int>(SUMO_ATTR_FROM_LANE, 0, ok);
952  const int toLaneIdx = attrs.get<int>(SUMO_ATTR_TO_LANE, 0, ok);
953  LinkDirection dir = parseLinkDir(attrs.get<std::string>(SUMO_ATTR_DIR, 0, ok));
954  LinkState state = parseLinkState(attrs.get<std::string>(SUMO_ATTR_STATE, 0, ok));
955  std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, 0, ok, "");
956 #ifdef HAVE_INTERNAL_LANES
957  std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, 0, ok, "");
958 #endif
959 
960  MSEdge* from = MSEdge::dictionary(fromID);
961  if (from == 0) {
962  WRITE_ERROR("Unknown from-edge '" + fromID + "' in connection");
963  return;
964  }
965  MSEdge* to = MSEdge::dictionary(toID);
966  if (to == 0) {
967  WRITE_ERROR("Unknown to-edge '" + toID + "' in connection");
968  return;
969  }
970  if (fromLaneIdx < 0 || static_cast<unsigned int>(fromLaneIdx) >= from->getLanes().size() ||
971  toLaneIdx < 0 || static_cast<unsigned int>(toLaneIdx) >= to->getLanes().size()) {
972  WRITE_ERROR("Invalid lane index in connection from '" + from->getID() + "' to '" + to->getID() + "'.");
973  return;
974  }
975  MSLane* fromLane = from->getLanes()[fromLaneIdx];
976  MSLane* toLane = to->getLanes()[toLaneIdx];
977  assert(fromLane);
978  assert(toLane);
979 
980  int tlLinkIdx = -1;
981  if (tlID != "") {
982  tlLinkIdx = attrs.get<int>(SUMO_ATTR_TLLINKINDEX, 0, ok);
983  // make sure that the index is in range
985  if (tlLinkIdx < 0 || tlLinkIdx >= (int)logic->getCurrentPhaseDef().getState().size()) {
986  WRITE_ERROR("Invalid " + toString(SUMO_ATTR_TLLINKINDEX) + " '" + toString(tlLinkIdx) +
987  "' in connection controlled by '" + tlID + "'");
988  return;
989  }
990  if (!ok) {
991  return;
992  }
993  }
994  SUMOReal length = fromLane->getShape()[-1].distanceTo(toLane->getShape()[0]);
995  MSLink* link = 0;
996 
997  // build the link
998 #ifdef HAVE_INTERNAL_LANES
999  MSLane* via = 0;
1000  if (viaID != "" && MSGlobals::gUsingInternalLanes) {
1001  via = MSLane::dictionary(viaID);
1002  if (via == 0) {
1003  WRITE_ERROR("An unknown lane ('" + viaID +
1004  "') should be set as a via-lane for lane '" + toLane->getID() + "'.");
1005  return;
1006  }
1007  length = via->getLength();
1008  }
1009  link = new MSLink(toLane, via, dir, state, length);
1010  if (via != 0) {
1011  via->addIncomingLane(fromLane, link);
1012  } else {
1013  toLane->addIncomingLane(fromLane, link);
1014  }
1015 #else
1016  link = new MSLink(toLane, dir, state, length);
1017  toLane->addIncomingLane(fromLane, link);
1018 #endif
1019  toLane->addApproachingLane(fromLane);
1020 
1021  // if a traffic light is responsible for it, inform the traffic light
1022  // check whether this link is controlled by a traffic light
1023  if (tlID != "") {
1024  myJunctionControlBuilder.getTLLogic(tlID).addLink(link, fromLane, tlLinkIdx);
1025  }
1026  // add the link
1027  fromLane->addLink(link);
1028 
1029  } catch (InvalidArgument& e) {
1030  WRITE_ERROR(e.what());
1031  }
1032 }
1033 
1034 
1036 NLHandler::parseLinkDir(const std::string& dir) {
1037  if (SUMOXMLDefinitions::LinkDirections.hasString(dir)) {
1039  } else {
1040  throw InvalidArgument("Unrecognised link direction '" + dir + "'.");
1041  }
1042 }
1043 
1044 
1045 LinkState
1046 NLHandler::parseLinkState(const std::string& state) {
1047  if (SUMOXMLDefinitions::LinkStates.hasString(state)) {
1048  return SUMOXMLDefinitions::LinkStates.get(state);
1049  } else {
1050  if (state == "t") { // legacy networks
1051  // WRITE_WARNING("Obsolete link state 't'. Use 'o' instead");
1053  } else {
1054  throw InvalidArgument("Unrecognised link state '" + state + "'.");
1055  }
1056  }
1057 }
1058 
1059 
1060 // ----------------------------------
1061 void
1063  bool ok = true;
1065  Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, 0, ok);
1066  Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, 0, ok);
1067  std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, 0, ok);
1068  if (ok) {
1069  Position networkOffset = s[0];
1070  GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
1071  if (OptionsCont::getOptions().getBool("fcd-output.geo") && !GeoConvHelper::getFinal().usingGeoProjection()) {
1072  WRITE_WARNING("no valid geo projection loaded from network. fcd-output.geo will not work");
1073  }
1074  }
1075 }
1076 
1077 
1078 void
1080  bool ok = true;
1081  myCurrentIsBroken = false;
1082  // get the id, report an error if not given or empty...
1083  myCurrentDistrictID = attrs.get<std::string>(SUMO_ATTR_ID, 0, ok);
1084  if (!ok) {
1085  myCurrentIsBroken = true;
1086  return;
1087  }
1088  try {
1090  if (!MSEdge::dictionary(myCurrentDistrictID + "-sink", sink)) {
1091  delete sink;
1092  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-sink' exists.");
1093  }
1094  sink->initialize(new std::vector<MSLane*>());
1096  if (!MSEdge::dictionary(myCurrentDistrictID + "-source", source)) {
1097  delete source;
1098  throw InvalidArgument("Another edge with the id '" + myCurrentDistrictID + "-source' exists.");
1099  }
1100  source->initialize(new std::vector<MSLane*>());
1101  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1102  std::vector<std::string> desc = attrs.getStringVector(SUMO_ATTR_EDGES);
1103  for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
1104  MSEdge* edge = MSEdge::dictionary(*i);
1105  // check whether the edge exists
1106  if (edge == 0) {
1107  throw InvalidArgument("The edge '" + *i + "' within district '" + myCurrentDistrictID + "' is not known.");
1108  }
1109  source->addFollower(edge);
1110  edge->addFollower(sink);
1111  }
1112  }
1113  if (attrs.hasAttribute(SUMO_ATTR_SHAPE)) {
1115  if (shape.size() != 0) {
1116  if (!myNet.getShapeContainer().addPolygon(myCurrentDistrictID, "taz", RGBColor::parseColor("1.0,.33,.33"), 0, 0, "", shape, false)) {
1117  WRITE_WARNING("Skipping visualization of taz '" + myCurrentDistrictID + "', polygon already exists.");
1118  }
1119  }
1120  }
1121  } catch (InvalidArgument& e) {
1122  WRITE_ERROR(e.what());
1123  myCurrentIsBroken = true;
1124  }
1125 }
1126 
1127 
1128 void
1129 NLHandler::addDistrictEdge(const SUMOSAXAttributes& attrs, bool isSource) {
1130  if (myCurrentIsBroken) {
1131  // earlier error
1132  return;
1133  }
1134  bool ok = true;
1135  std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentDistrictID.c_str(), ok);
1136  MSEdge* succ = MSEdge::dictionary(id);
1137  if (succ != 0) {
1138  // connect edge
1139  if (isSource) {
1140  MSEdge::dictionary(myCurrentDistrictID + "-source")->addFollower(succ);
1141  } else {
1142  succ->addFollower(MSEdge::dictionary(myCurrentDistrictID + "-sink"));
1143  }
1144  } else {
1145  WRITE_ERROR("At district '" + myCurrentDistrictID + "': succeeding edge '" + id + "' does not exist.");
1146  }
1147 }
1148 
1149 
1150 void
1152  if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
1153  std::vector<std::string> edgeIDs = attrs.getStringVector(SUMO_ATTR_EDGES);
1154  for (std::vector<std::string>::iterator it = edgeIDs.begin(); it != edgeIDs.end(); ++it) {
1155  MSEdge* edge = MSEdge::dictionary(*it);
1156  if (edge == 0) {
1157  WRITE_ERROR("Unknown edge '" + (*it) + "' in roundabout");
1158  } else {
1159  edge->markAsRoundabout();
1160  }
1161  }
1162  } else {
1163  WRITE_ERROR("Empty edges in roundabout.");
1164  }
1165 }
1166 
1167 
1168 // ----------------------------------
1169 void
1171  try {
1173  } catch (InvalidArgument& e) {
1174  WRITE_ERROR(e.what());
1175  }
1176 }
1177 
1178 
1179 void
1181  if (!myCurrentIsBroken) {
1182  try {
1184  } catch (InvalidArgument& e) {
1185  WRITE_ERROR(e.what());
1186  myCurrentIsBroken = true;
1187  }
1188  }
1189  myCurrentWAUTID = "";
1190 }
1191 
1192 
1193 /****************************************************************************/
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:857
void addPoly(const SUMOSAXAttributes &attrs)
adds a polygon
Definition: NLHandler.cpp:592
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:510
Builds detectors for microsim.
virtual void addE2Detector(const SUMOSAXAttributes &attrs)
Builds an e2 detector using the given specification.
Definition: NLHandler.cpp:804
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:273
const SUMOReal SUMO_const_laneWidth
Definition: StdDefs.h:45
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:464
const Position geometryPositionAtOffset(SUMOReal offset) const
Definition: MSLane.h:340
bool myCurrentIsBroken
Definition: NLHandler.h:303
const std::vector< MSLane * > & getLanes() const
Returns this edge'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:427
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's length.
Definition: MSLane.h:370
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:761
void addRoundabout(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1151
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:88
void addIncomingLane(MSLane *lane, MSLink *viaLink)
Definition: MSLane.cpp:1034
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'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:707
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:289
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:1170
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:292
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:1180
void addParam(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:447
void addDistrict(const SUMOSAXAttributes &attrs)
Definition: NLHandler.cpp:1079
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:1062
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:283
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:880
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:893
static StringBijection< TrafficLightType > TrafficLightTypes
Builder of microsim-junctions and tls.
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:364
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:491
void addRequest(const SUMOSAXAttributes &attrs)
adds a request item to the current junction logic
Definition: NLHandler.cpp:619
void addConnection(const SUMOSAXAttributes &attrs)
adds a connection
Definition: NLHandler.cpp:941
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:310
LinkDirection parseLinkDir(const std::string &dir)
Parses the given character into an enumeration typed link direction.
Definition: NLHandler.cpp:1036
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:52
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:295
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:829
virtual void addInstantE1Detector(const SUMOSAXAttributes &attrs)
Builds an e1 detector using the given specification.
Definition: NLHandler.cpp:736
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:781
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:280
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:683
void addDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
Definition: NLHandler.cpp:1129
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...
LinkState parseLinkState(const std::string &state)
Parses the given character into an enumeration typed link state.
Definition: NLHandler.cpp:1046
The abstract direction of a link.
virtual void closeTrafficLightLogic()
Ends the building of a traffic lights logic.
T get(const std::string &str) const
const PositionVector & getShape() const
Returns this lane's shape.
Definition: MSLane.h:323
The parent class for traffic light logics.
A variable speed sign.
#define SUMOReal
Definition: config.h:215
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.
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:906
Builds trigger objects for microsim.
void initJunctionLogic(const SUMOSAXAttributes &attrs)
begins the reading of a junction row logic
Definition: NLHandler.cpp:646
The edge is an internal edge.
Definition: MSEdge.h:90
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:1044
TrafficLightType
void initTrafficLightLogic(const SUMOSAXAttributes &attrs)
begins the reading of a traffic lights logic
Definition: NLHandler.cpp:660
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:536