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