SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NIImporter_VISUM.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // A VISUM network importer
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
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>
37 #include <utils/common/ToString.h>
40 #include <netbuild/NBDistrict.h>
41 
42 #include <netbuild/NBNetBuilder.h>
43 #include "NILoader.h"
44 #include "NIImporter_VISUM.h"
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
54 // ---------------------------------------------------------------------------
55 // static methods (interface in this case)
56 // ---------------------------------------------------------------------------
57 void
59  // check whether the option is set (properly)
60  if (!oc.isSet("visum-file")) {
61  return;
62  }
63  // build the handler
64  NIImporter_VISUM loader(nb, oc.getString("visum-file"),
65  NBCapacity2Lanes(oc.getFloat("lanes-from-capacity.norm")),
66  oc.getBool("visum.use-type-priority"));
67  loader.load();
68 }
69 
70 
71 
72 // ---------------------------------------------------------------------------
73 // loader methods
74 // ---------------------------------------------------------------------------
76  const std::string& file,
77  NBCapacity2Lanes capacity2Lanes,
78  bool useVisumPrio)
79  : myNetBuilder(nb), myFileName(file),
80  myCapacity2Lanes(capacity2Lanes), myUseVisumPrio(useVisumPrio) {
81  // the order of process is important!
82  // set1
88 
89  // set2
90  // two types of "strecke"
94 
95  // set3
97  // two types of "abbieger"
98  addParser("ABBIEGEBEZIEHUNG", &NIImporter_VISUM::parse_Turns);
100 
102  addParser("FAHRSTREIFEN", &NIImporter_VISUM::parse_Lanes);
103  addParser("FLAECHENELEMENT", &NIImporter_VISUM::parse_PartOfArea);
104 
105  // set4
106  // two types of lsa
109  // two types of knotenzulsa
113  // two types of signalgruppe
114  addParser("LSASIGNALGRUPPE", &NIImporter_VISUM::parse_SignalGroups);
116  // three types of ABBZULSASIGNALGRUPPE
117  addParser("ABBZULSASIGNALGRUPPE", &NIImporter_VISUM::parse_TurnsToSignalGroups);
118  addParser("SIGNALGRUPPEZUABBIEGER", &NIImporter_VISUM::parse_TurnsToSignalGroups);
119  addParser("SIGNALGRUPPEZUFSABBIEGER", &NIImporter_VISUM::parse_TurnsToSignalGroups);
120 
121  addParser("TEILFLAECHENELEMENT", &NIImporter_VISUM::parse_AreaSubPartElement);
122 
123  // two types of LSAPHASE
126 
127  addParser("LSASIGNALGRUPPEZULSAPHASE", &NIImporter_VISUM::parse_SignalGroupsToPhases);
128  addParser("FAHRSTREIFENABBIEGER", &NIImporter_VISUM::parse_LanesConnections);
129 }
130 
131 
133  for (NIVisumTL_Map::iterator j = myTLS.begin(); j != myTLS.end(); j++) {
134  delete j->second;
135  }
136 }
137 
138 
139 void
140 NIImporter_VISUM::addParser(const std::string& name, ParsingFunction function) {
141  TypeParser p;
142  p.name = name;
143  p.function = function;
144  p.position = -1;
145  mySingleDataParsers.push_back(p);
146 }
147 
148 
149 void
151  // open the file
153  throw ProcessError("Can not open visum-file '" + myFileName + "'.");
154  }
155  // scan the file for data positions
156  while (myLineReader.hasMore()) {
157  std::string line = myLineReader.readLine();
158  if (line.length() > 0 && line[0] == '$') {
159  ParserVector::iterator i;
160  for (i = mySingleDataParsers.begin(); i != mySingleDataParsers.end(); i++) {
161  std::string dataName = "$" + (*i).name + ":";
162  if (line.substr(0, dataName.length()) == dataName) {
163  (*i).position = myLineReader.getPosition();
164  (*i).pattern = line.substr(dataName.length());
165  WRITE_MESSAGE("Found: " + dataName + " at " + toString<int>(myLineReader.getPosition()));
166  }
167  }
168  }
169  }
170  // go through the parsers and process all entries
171  for (ParserVector::iterator i = mySingleDataParsers.begin(); i != mySingleDataParsers.end(); i++) {
172  if ((*i).position < 0) {
173  // do not process using parsers for which no information was found
174  continue;
175  }
176  // ok, the according information is stored in the file
177  PROGRESS_BEGIN_MESSAGE("Parsing " + (*i).name);
178  // reset the line reader and let it point to the begin of the according data field
180  myLineReader.setPos((*i).position);
181  // prepare the line parser
182  myLineParser.reinit((*i).pattern);
183  // read
184  bool singleDataEndFound = false;
185  while (myLineReader.hasMore() && !singleDataEndFound) {
186  std::string line = myLineReader.readLine();
187  if (line.length() == 0 || line[0] == '*' || line[0] == '$') {
188  singleDataEndFound = true;
189  } else {
190  myLineParser.parseLine(line);
191  try {
192  myCurrentID = "<unknown>";
193  (this->*(*i).function)();
194  } catch (OutOfBoundsException&) {
195  WRITE_ERROR("Too short value line in " + (*i).name + " occured.");
196  } catch (NumberFormatException&) {
197  WRITE_ERROR("A value in " + (*i).name + " should be numeric but is not (id='" + myCurrentID + "').");
198  } catch (UnknownElement& e) {
199  WRITE_ERROR("One of the needed values ('" + std::string(e.what()) + "') is missing in " + (*i).name + ".");
200  }
201  }
202  }
203  // close single reader processing
205  }
206  // build traffic lights
207  for (NIVisumTL_Map::iterator j = myTLS.begin(); j != myTLS.end(); j++) {
208  j->second->build(myNetBuilder.getTLLogicCont());
209  }
210  // build district shapes
211  for (std::map<NBDistrict*, PositionVector>::const_iterator k = myDistrictShapes.begin(); k != myDistrictShapes.end(); ++k) {
212  (*k).first->addShape((*k).second);
213  }
214 }
215 
216 
217 
218 
219 
220 void
222  std::string name = myLineParser.know("VSysCode") ? myLineParser.get("VSysCode").c_str() : myLineParser.get("CODE").c_str();
223  std::string type = myLineParser.know("VSysMode") ? myLineParser.get("VSysMode").c_str() : myLineParser.get("Typ").c_str();
224  myVSysTypes[name] = type;
225 }
226 
227 
228 void
230  // get the id
232  // get the maximum speed
233  SUMOReal speed = getNamedFloat("v0-IV", "V0IV");
234  // get the priority
235  int priority = 1000 - TplConvert::_2int(myLineParser.get("Rang").c_str());
236  // try to retrieve the number of lanes
237  SUMOReal cap = getNamedFloat("Kap-IV", "KAPIV");
238  int nolanes = myCapacity2Lanes.get(cap);
239  // insert the type
240  myNetBuilder.getTypeCont().insert(myCurrentID, nolanes, speed / (SUMOReal) 3.6, priority, -1);
241 }
242 
243 
244 void
246  // get the id
248  // get the position
249  SUMOReal x = getNamedFloat("XKoord");
250  SUMOReal y = getNamedFloat("YKoord");
251  Position pos(x, y);
253  WRITE_ERROR("Unable to project coordinates for node " + myCurrentID + ".");
254  return;
255  }
256  // add to the list
258  WRITE_ERROR("Duplicate node occured ('" + myCurrentID + "').");
259  }
260 }
261 
262 
263 void
265  // get the id
267  // get the information whether the source and the destination
268  // connections are weighted
269  //bool sourcesWeighted = getWeightedBool("Proz_Q");
270  //bool destWeighted = getWeightedBool("Proz_Z");
271  // get the node information
272  SUMOReal x = getNamedFloat("XKoord");
273  SUMOReal y = getNamedFloat("YKoord");
274  Position pos(x, y);
275  if (!NBNetBuilder::transformCoordinates(pos, false)) {
276  WRITE_ERROR("Unable to project coordinates for district " + myCurrentID + ".");
277  return;
278  }
279  // build the district
280  NBDistrict* district = new NBDistrict(myCurrentID, pos);
281  if (!myNetBuilder.getDistrictCont().insert(district)) {
282  WRITE_ERROR("Duplicate district occured ('" + myCurrentID + "').");
283  delete district;
284  return;
285  }
286  if (myLineParser.know("FLAECHEID")) {
287  SUMOLong flaecheID = TplConvert::_2long(myLineParser.get("FLAECHEID").c_str());
288  myShapeDistrictMap[flaecheID] = district;
289  }
290 }
291 
292 
293 void
295  SUMOLong id = TplConvert::_2long(myLineParser.get("ID").c_str());
296  SUMOReal x = TplConvert::_2SUMOReal(myLineParser.get("XKOORD").c_str());
297  SUMOReal y = TplConvert::_2SUMOReal(myLineParser.get("YKOORD").c_str());
298  Position pos(x, y);
299  if (!NBNetBuilder::transformCoordinates(pos, false)) {
300  WRITE_ERROR("Unable to project coordinates for point " + toString(id) + ".");
301  return;
302  }
303  myPoints[id] = pos;
304 }
305 
306 
307 void
309  if (myLineParser.know("VSYSSET") && myLineParser.get("VSYSSET") == "") {
310  // no vehicle allowed; don't add
311  return;
312  }
313  // get the id
315  // get the from- & to-node and validate them
316  NBNode* from = getNamedNode("VonKnot", "VonKnotNr");
317  NBNode* to = getNamedNode("NachKnot", "NachKnotNr");
318  if (!checkNodes(from, to)) {
319  return;
320  }
321  // get the type
322  std::string type = myLineParser.know("Typ") ? myLineParser.get("Typ") : myLineParser.get("TypNr");
323  // get the speed
324  SUMOReal speed = myNetBuilder.getTypeCont().getSpeed(type);
325  if (!OptionsCont::getOptions().getBool("visum.use-type-speed")) {
326  try {
327  std::string speedS = myLineParser.know("v0-IV") ? myLineParser.get("v0-IV") : myLineParser.get("V0IV");
328  if (speedS.find("km/h") != std::string::npos) {
329  speedS = speedS.substr(0, speedS.find("km/h"));
330  }
331  speed = TplConvert::_2SUMORealSec(speedS.c_str(), -1);
332  speed = speed / (SUMOReal) 3.6;
333  } catch (OutOfBoundsException) {}
334  }
335  if (speed <= 0) {
336  speed = myNetBuilder.getTypeCont().getSpeed(type);
337  }
338 
339  // get the information whether the edge is a one-way
340  bool oneway = myLineParser.know("Einbahn")
341  ? TplConvert::_2bool(myLineParser.get("Einbahn").c_str())
342  : true;
343  // get the number of lanes
344  int nolanes = myNetBuilder.getTypeCont().getNumLanes(type);
345  if (!OptionsCont::getOptions().getBool("visum.recompute-lane-number")) {
346  try {
347  if (!OptionsCont::getOptions().getBool("visum.use-type-laneno")) {
348  nolanes = myLineParser.know("Fahrstreifen")
349  ? TplConvert::_2intSec(myLineParser.get("Fahrstreifen").c_str(), 0)
350  : TplConvert::_2intSec(myLineParser.get("ANZFAHRSTREIFEN").c_str(), 0);
351  }
352  } catch (UnknownElement) {
353  }
354  } else {
355  SUMOReal cap = myLineParser.know("KAPIV")
356  ? TplConvert::_2SUMORealSec(myLineParser.get("KAPIV").c_str(), -1)
357  : TplConvert::_2SUMORealSec(myLineParser.get("KAP-IV").c_str(), -1);
358  nolanes = myCapacity2Lanes.get(cap);
359  }
360  // check whether the id is already used
361  // (should be the opposite direction)
362  bool oneway_checked = oneway;
364  if (previous != 0) {
365  myCurrentID = '-' + myCurrentID;
367  oneway_checked = false;
368  }
369  if (find(myTouchedEdges.begin(), myTouchedEdges.end(), myCurrentID) != myTouchedEdges.end()) {
370  oneway_checked = false;
371  }
372  std::string tmpid = '-' + myCurrentID;
373  if (find(myTouchedEdges.begin(), myTouchedEdges.end(), tmpid) != myTouchedEdges.end()) {
374  previous = myNetBuilder.getEdgeCont().retrieve(tmpid);
375  if (previous != 0) {
377  }
378  oneway_checked = false;
379  }
380  // add the edge
381  int prio = myUseVisumPrio ? myNetBuilder.getTypeCont().getPriority(type) : -1;
382  if (nolanes != 0 && speed != 0) {
383  LaneSpreadFunction lsf = oneway_checked ? LANESPREAD_CENTER : LANESPREAD_RIGHT;
384  // @todo parse name from visum files
385  NBEdge* e = new NBEdge(myCurrentID, from, to, type, speed, nolanes, prio,
387  if (!myNetBuilder.getEdgeCont().insert(e)) {
388  delete e;
389  WRITE_ERROR("Duplicate edge occured ('" + myCurrentID + "').");
390  }
391  }
392  myTouchedEdges.push_back(myCurrentID);
393  // nothing more to do, when the edge is a one-way street
394  if (oneway) {
395  return;
396  }
397  // add the opposite edge
398  myCurrentID = '-' + myCurrentID;
399  if (nolanes != 0 && speed != 0) {
400  LaneSpreadFunction lsf = oneway_checked ? LANESPREAD_CENTER : LANESPREAD_RIGHT;
401  // @todo parse name from visum files
402  NBEdge* e = new NBEdge(myCurrentID, from, to, type, speed, nolanes, prio,
404  if (!myNetBuilder.getEdgeCont().insert(e)) {
405  delete e;
406  WRITE_ERROR("Duplicate edge occured ('" + myCurrentID + "').");
407  }
408  }
409  myTouchedEdges.push_back(myCurrentID);
410 }
411 
412 
413 void
415  SUMOLong id = TplConvert::_2long(myLineParser.get("ID").c_str());
416  SUMOLong from = TplConvert::_2long(myLineParser.get("VONPUNKTID").c_str());
417  SUMOLong to = TplConvert::_2long(myLineParser.get("NACHPUNKTID").c_str());
418  myEdges[id] = std::make_pair(from, to);
419 }
420 
421 
422 void
424  SUMOLong flaecheID = TplConvert::_2long(myLineParser.get("FLAECHEID").c_str());
425  SUMOLong flaechePartID = TplConvert::_2long(myLineParser.get("TFLAECHEID").c_str());
426  if (mySubPartsAreas.find(flaechePartID) == mySubPartsAreas.end()) {
427  mySubPartsAreas[flaechePartID] = std::vector<SUMOLong>();
428  }
429  mySubPartsAreas[flaechePartID].push_back(flaecheID);
430 }
431 
432 
433 void
435  if (OptionsCont::getOptions().getBool("visum.no-connectors")) {
436  // do nothing, if connectors shall not be imported
437  return;
438  }
439  // get the source district
440  std::string bez = NBHelpers::normalIDRepresentation(myLineParser.get("BezNr"));
441  // get the destination node
442  NBNode* dest = getNamedNode("KnotNr");
443  if (dest == 0) {
444  return;
445  }
446  // get the weight of the connection
447  SUMOReal proz = getWeightedFloat("Proz");
448  if (proz > 0) {
449  proz /= 100.;
450  } else {
451  proz = 1;
452  }
453  // get the duration to wait (unused)
454 // SUMOReal retard = -1;
455 // if (myLineParser.know("t0-IV")) {
456 // retard = getNamedFloat("t0-IV", -1);
457 // }
458  // get the type;
459  // use a standard type with a large speed when a type is not given
460  std::string type = myLineParser.know("Typ")
462  : "";
463  // add the connectors as an edge
464  std::string id = bez + "-" + dest->getID();
465  // get the information whether this is a sink or a source
466  std::string dir = myLineParser.get("Richtung");
467  if (dir.length() == 0) {
468  dir = "QZ";
469  }
470  // build the source when needed
471  if (dir.find('Q') != std::string::npos) {
472  const EdgeVector& edges = dest->getOutgoingEdges();
473  bool hasContinuation = false;
474  for (EdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
475  if (!(*i)->isMacroscopicConnector()) {
476  hasContinuation = true;
477  }
478  }
479  if (!hasContinuation) {
480  // obviously, there is no continuation on the net
481  WRITE_WARNING("Incoming connector '" + id + "' will not be build - would be not connected to network.");
482  } else {
483  NBNode* src = buildDistrictNode(bez, dest, true);
484  if (src == 0) {
485  WRITE_ERROR("The district '" + bez + "' could not be built.");
486  return;
487  }
488  NBEdge* edge = new NBEdge(id, src, dest, "VisumConnector",
489  OptionsCont::getOptions().getFloat("visum.connector-speeds"),
490  OptionsCont::getOptions().getInt("visum.connectors-lane-number"),
492  "", LANESPREAD_RIGHT);
494  if (!myNetBuilder.getEdgeCont().insert(edge)) {
495  WRITE_ERROR("A duplicate edge id occured (ID='" + id + "').");
496  return;
497  }
498  edge = myNetBuilder.getEdgeCont().retrieve(id);
499  if (edge != 0) {
500  myNetBuilder.getDistrictCont().addSource(bez, edge, proz);
501  }
502  }
503  }
504  // build the sink when needed
505  if (dir.find('Z') != std::string::npos) {
506  const EdgeVector& edges = dest->getIncomingEdges();
507  bool hasPredeccessor = false;
508  for (EdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
509  if (!(*i)->isMacroscopicConnector()) {
510  hasPredeccessor = true;
511  }
512  }
513  if (!hasPredeccessor) {
514  // obviously, the network is not connected to this node
515  WRITE_WARNING("Outgoing connector '" + id + "' will not be build - would be not connected to network.");
516  } else {
517  NBNode* src = buildDistrictNode(bez, dest, false);
518  if (src == 0) {
519  WRITE_ERROR("The district '" + bez + "' could not be built.");
520  return;
521  }
522  id = "-" + id;
523  NBEdge* edge = new NBEdge(id, dest, src, "VisumConnector",
524  OptionsCont::getOptions().getFloat("visum.connector-speeds"),
525  OptionsCont::getOptions().getInt("visum.connectors-lane-number"),
527  "", LANESPREAD_RIGHT);
529  if (!myNetBuilder.getEdgeCont().insert(edge)) {
530  WRITE_ERROR("A duplicate edge id occured (ID='" + id + "').");
531  return;
532  }
533  edge = myNetBuilder.getEdgeCont().retrieve(id);
534  if (edge != 0) {
535  myNetBuilder.getDistrictCont().addSink(bez, edge, proz);
536  }
537  }
538  }
539 }
540 
541 
542 void
544  if (myLineParser.know("VSYSSET") && myLineParser.get("VSYSSET") == "") {
545  // no vehicle allowed; don't add
546  return;
547  }
548  // retrieve the nodes
549  NBNode* from = getNamedNode("VonKnot", "VonKnotNr");
550  NBNode* via = getNamedNode("UeberKnot", "UeberKnotNr");
551  NBNode* to = getNamedNode("NachKnot", "NachKnotNr");
552  if (from == 0 || via == 0 || to == 0) {
553  return;
554  }
555  // all nodes are known
556  std::string type = myLineParser.know("VSysCode")
557  ? myLineParser.get("VSysCode")
558  : myLineParser.get("VSYSSET");
559  if (myVSysTypes.find(type) != myVSysTypes.end() && myVSysTypes.find(type)->second == "IV") {
560  // try to set the turning definition
561  NBEdge* src = from->getConnectionTo(via);
562  NBEdge* dest = via->getConnectionTo(to);
563  // check both
564  if (src == 0) {
565  // maybe it was removed due to something
566  if (OptionsCont::getOptions().isSet("keep-edges.min-speed")
567  ||
568  OptionsCont::getOptions().isSet("keep-edges.explicit")) {
569  WRITE_WARNING("Could not set connection from node '" + from->getID() + "' to node '" + via->getID() + "'.");
570  } else {
571  if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
572  WRITE_WARNING("There is no edge from node '" + from->getID() + "' to node '" + via->getID() + "'.");
573  }
574  }
575  return;
576  }
577  if (dest == 0) {
578  if (OptionsCont::getOptions().isSet("keep-edges.min-speed")
579  ||
580  OptionsCont::getOptions().isSet("keep-edges.explicit")) {
581  WRITE_WARNING("Could not set connection from node '" + via->getID() + "' to node '" + to->getID() + "'.");
582  } else {
583  if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
584  WRITE_WARNING("There is no edge from node '" + via->getID() + "' to node '" + to->getID() + "'.");
585  }
586  }
587  return;
588  }
589  // both edges found
590  // set them into the edge
591  src->addEdge2EdgeConnection(dest);
592  }
593 }
594 
595 
596 void
598  // get the from- & to-node and validate them
599  NBNode* from = getNamedNode("VonKnot", "VonKnotNr");
600  NBNode* to = getNamedNode("NachKnot", "NachKnotNr");
601  if (!checkNodes(from, to)) {
602  return;
603  }
604  bool failed = false;
605  int index;
606  SUMOReal x, y;
607  try {
608  index = TplConvert::_2int(myLineParser.get("INDEX").c_str());
609  x = getNamedFloat("XKoord");
610  y = getNamedFloat("YKoord");
611  } catch (NumberFormatException&) {
612  WRITE_ERROR("Error in geometry description from node '" + from->getID() + "' to node '" + to->getID() + "'.");
613  return;
614  }
615  Position pos(x, y);
617  WRITE_ERROR("Unable to project coordinates for node '" + from->getID() + "'.");
618  return;
619  }
620  NBEdge* e = from->getConnectionTo(to);
621  if (e != 0) {
622  e->addGeometryPoint(index, pos);
623  } else {
624  failed = true;
625  }
626  e = to->getConnectionTo(from);
627  if (e != 0) {
628  e->addGeometryPoint(-index, pos);
629  failed = false;
630  }
631  // check whether the operation has failed
632  if (failed) {
633  // we should report this to the warning instance only if we have removed
634  // some nodes or edges...
635  if (OptionsCont::getOptions().isSet("keep-edges.min-speed") || OptionsCont::getOptions().isSet("keep-edges.explicit")) {
636  WRITE_WARNING("Could not set geometry between node '" + from->getID() + "' and node '" + to->getID() + "'.");
637  } else {
638  // ... in the other case we report this to the error instance
639  if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
640  WRITE_WARNING("There is no edge from node '" + from->getID() + "' to node '" + to->getID() + "'.");
641  }
642  }
643  }
644 }
645 
646 
647 void
649  // get the node
650  NBNode* node = getNamedNode("KNOTNR");
651  // get the edge
652  NBEdge* baseEdge = getNamedEdge("STRNR");
653  NBEdge* edge = getNamedEdgeContinuating("STRNR", node);
654  // check
655  if (node == 0 || edge == 0) {
656  return;
657  }
658  // get the lane
659  std::string laneS = myLineParser.know("FSNR")
662  int lane = -1;
663  try {
664  lane = TplConvert::_2int(laneS.c_str());
665  } catch (NumberFormatException&) {
666  WRITE_ERROR("A lane number for edge '" + edge->getID() + "' is not numeric (" + laneS + ").");
667  return;
668  }
669  lane -= 1;
670  if (lane < 0) {
671  WRITE_ERROR("A lane number for edge '" + edge->getID() + "' is not positive (" + laneS + ").");
672  return;
673  }
674  // get the direction
675  std::string dirS = NBHelpers::normalIDRepresentation(myLineParser.get("RICHTTYP"));
676  int prevLaneNo = baseEdge->getNumLanes();
677  if ((dirS == "1" && !(node->hasIncoming(edge))) || (dirS == "0" && !(node->hasOutgoing(edge)))) {
678  // get the last part of the turnaround direction
679  edge = getReversedContinuating(edge, node);
680  }
681  // get the length
682  std::string lengthS = NBHelpers::normalIDRepresentation(myLineParser.get("LAENGE"));
683  SUMOReal length = -1;
684  try {
685  length = TplConvert::_2SUMOReal(lengthS.c_str());
686  } catch (NumberFormatException&) {
687  WRITE_ERROR("A lane length for edge '" + edge->getID() + "' is not numeric (" + lengthS + ").");
688  return;
689  }
690  if (length < 0) {
691  WRITE_ERROR("A lane length for edge '" + edge->getID() + "' is not positive (" + lengthS + ").");
692  return;
693  }
694  //
695  if (dirS == "1") {
696  lane -= prevLaneNo;
697  }
698  //
699  if (length == 0) {
700  if ((int) edge->getNumLanes() > lane) {
701  // ok, we know this already...
702  return;
703  }
704  // increment by one
705  edge->incLaneNo(1);
706  } else {
707  // check whether this edge already has been created
708  if (edge->getID().substr(edge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
709  if (edge->getID().substr(edge->getID().find('_')) == "_" + toString(length) + "_" + node->getID()) {
710  if ((int) edge->getNumLanes() > lane) {
711  // ok, we know this already...
712  return;
713  }
714  // increment by one
715  edge->incLaneNo(1);
716  return;
717  }
718  }
719  // nope, we have to split the edge...
720  // maybe it is not the proper edge to split - VISUM seems not to sort the splits...
721  bool mustRecheck = true;
722  SUMOReal seenLength = 0;
723  while (mustRecheck) {
724  if (edge->getID().substr(edge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
725  // ok, we have a previously created edge here
726  std::string sub = edge->getID();
727  sub = sub.substr(sub.rfind('_', sub.rfind('_') - 1));
728  sub = sub.substr(1, sub.find('_', 1) - 1);
729  SUMOReal dist = TplConvert::_2SUMOReal(sub.c_str());
730  if (dist < length) {
731  seenLength += edge->getLength();
732  if (dirS == "1") {
733  // incoming -> move back
734  edge = edge->getFromNode()->getIncomingEdges()[0];
735  } else {
736  // outgoing -> move forward
737  edge = edge->getToNode()->getOutgoingEdges()[0];
738  }
739  } else {
740  mustRecheck = false;
741  }
742  } else {
743  // we have the center edge - do not continue...
744  mustRecheck = false;
745  }
746  }
747  // compute position
748  Position p;
749  SUMOReal useLength = length - seenLength;
750  useLength = edge->getLength() - useLength;
751  std::string edgeID = edge->getID();
752  p = edge->getGeometry().positionAtOffset(useLength);
753  if (edgeID.substr(edgeID.length() - node->getID().length() - 1) == "_" + node->getID()) {
754  edgeID = edgeID.substr(0, edgeID.find('_'));
755  }
756  NBNode* rn = new NBNode(edgeID + "_" + toString((size_t) length) + "_" + node->getID(), p);
757  if (!myNetBuilder.getNodeCont().insert(rn)) {
758  throw ProcessError("Ups - could not insert node!");
759  }
760  std::string nid = edgeID + "_" + toString((size_t) length) + "_" + node->getID();
762  edge->getID(), nid, edge->getNumLanes() + 0, edge->getNumLanes() + 1);
763  NBEdge* nedge = myNetBuilder.getEdgeCont().retrieve(nid);
764  nedge = nedge->getToNode()->getOutgoingEdges()[0];
765  while (nedge->getID().substr(nedge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
766  assert(nedge->getToNode()->getOutgoingEdges().size() > 0);
767  nedge->incLaneNo(1);
768  nedge = nedge->getToNode()->getOutgoingEdges()[0];
769  }
770  }
771 }
772 
773 
774 void
777  SUMOTime cycleTime = (SUMOTime) getNamedFloat("Umlaufzeit", "UMLZEIT");
778  SUMOTime intermediateTime = (SUMOTime) getNamedFloat("StdZwischenzeit", "STDZWZEIT");
779  bool phaseBased = myLineParser.know("PhasenBasiert")
780  ? TplConvert::_2bool(myLineParser.get("PhasenBasiert").c_str())
781  : false;
782  SUMOTime offset = myLineParser.know("ZEITVERSATZ") ? TIME2STEPS(getNamedFloat("ZEITVERSATZ")) : 0;
783  // add to the list
784  myTLS[myCurrentID] = new NIVisumTL(myCurrentID, cycleTime, offset, intermediateTime, phaseBased);
785 }
786 
787 
788 void
790  std::string node = myLineParser.get("KnotNr").c_str();
791  std::string trafficLight = myLineParser.get("LsaNr").c_str();
792  // add to the list
793  myTLS[trafficLight]->addNode(myNetBuilder.getNodeCont().retrieve(node));
794 }
795 
796 
797 void
800  std::string LSAid = NBHelpers::normalIDRepresentation(myLineParser.get("LsaNr"));
801  SUMOReal startTime = getNamedFloat("GzStart", "GRUENANF");
802  SUMOReal endTime = getNamedFloat("GzEnd", "GRUENENDE");
803  SUMOReal yellowTime = myLineParser.know("GELB") ? getNamedFloat("GELB") : -1;
804  // add to the list
805  if (myTLS.find(LSAid) == myTLS.end()) {
806  WRITE_ERROR("Could not find TLS '" + LSAid + "' for setting the signal group.");
807  return;
808  }
809  myTLS.find(LSAid)->second->addSignalGroup(myCurrentID, (SUMOTime) startTime, (SUMOTime) endTime, (SUMOTime) yellowTime);
810 }
811 
812 
813 void
815  // get the id
816  std::string SGid = getNamedString("SGNR", "SIGNALGRUPPENNR");
817  std::string LSAid = getNamedString("LsaNr");
818  // nodes
819  NBNode* from = myLineParser.know("VonKnot") ? getNamedNode("VonKnot") : 0;
820  NBNode* via = myLineParser.know("KNOTNR")
821  ? getNamedNode("KNOTNR")
822  : getNamedNode("UeberKnot", "UeberKnotNr");
823  NBNode* to = myLineParser.know("NachKnot") ? getNamedNode("NachKnot") : 0;
824  // edges
825  NBEdge* edg1 = 0;
826  NBEdge* edg2 = 0;
827  if (from == 0 && to == 0) {
828  edg1 = getNamedEdgeContinuating("VONSTRNR", via);
829  edg2 = getNamedEdgeContinuating("NACHSTRNR", via);
830  } else {
831  edg1 = getEdge(from, via);
832  edg2 = getEdge(via, to);
833  }
834  // add to the list
835  NIVisumTL::SignalGroup& SG = myTLS.find(LSAid)->second->getSignalGroup(SGid);
836  if (edg1 != 0 && edg2 != 0) {
837  if (!via->hasIncoming(edg1)) {
838  std::string sid;
839  if (edg1->getID()[0] == '-') {
840  sid = edg1->getID().substr(1);
841  } else {
842  sid = "-" + edg1->getID();
843  }
844  if (sid.find('_') != std::string::npos) {
845  sid = sid.substr(0, sid.find('_'));
846  }
848  }
849  if (!via->hasOutgoing(edg2)) {
850  std::string sid;
851  if (edg2->getID()[0] == '-') {
852  sid = edg2->getID().substr(1);
853  } else {
854  sid = "-" + edg2->getID();
855  }
856  if (sid.find('_') != std::string::npos) {
857  sid = sid.substr(0, sid.find('_'));
858  }
860  }
861  SG.connections().push_back(NBConnection(edg1, edg2));
862  }
863 }
864 
865 
866 void
868  SUMOLong id = TplConvert::_2long(myLineParser.get("TFLAECHEID").c_str());
869  SUMOLong edgeid = TplConvert::_2long(myLineParser.get("KANTEID").c_str());
870  if (myEdges.find(edgeid) == myEdges.end()) {
871  WRITE_ERROR("Unknown edge in TEILFLAECHENELEMENT");
872  return;
873  }
874  std::string dir = myLineParser.get("RICHTUNG");
875 // get index (unused)
876 // std::string indexS = NBHelpers::normalIDRepresentation(myLineParser.get("INDEX"));
877 // int index = -1;
878 // try {
879 // index = TplConvert::_2int(indexS.c_str()) - 1;
880 // } catch (NumberFormatException&) {
881 // WRITE_ERROR("An index for a TEILFLAECHENELEMENT is not numeric (id='" + toString(id) + "').");
882 // return;
883 // }
884  PositionVector shape;
885  shape.push_back(myPoints[myEdges[edgeid].first]);
886  shape.push_back(myPoints[myEdges[edgeid].second]);
887  if (dir.length() > 0 && dir[0] == '1') {
888  shape = shape.reverse();
889  }
890  if (mySubPartsAreas.find(id) == mySubPartsAreas.end()) {
891  WRITE_ERROR("Unkown are for area part '" + myCurrentID + "'.");
892  return;
893  }
894 
895  const std::vector<SUMOLong>& areas = mySubPartsAreas.find(id)->second;
896  for (std::vector<SUMOLong>::const_iterator i = areas.begin(); i != areas.end(); ++i) {
898  if (d == 0) {
899  continue;
900  }
901  if (myDistrictShapes.find(d) == myDistrictShapes.end()) {
903  }
904  if (dir.length() > 0 && dir[0] == '1') {
905  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].second]);
906  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].first]);
907  } else {
908  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].first]);
909  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].second]);
910  }
911  }
912 }
913 
914 
915 void
917  // get the id
918  std::string phaseid = NBHelpers::normalIDRepresentation(myLineParser.get("Nr"));
919  std::string LSAid = NBHelpers::normalIDRepresentation(myLineParser.get("LsaNr"));
920  SUMOReal startTime = getNamedFloat("GzStart", "GRUENANF");
921  SUMOReal endTime = getNamedFloat("GzEnd", "GRUENENDE");
922  SUMOReal yellowTime = myLineParser.know("GELB") ? getNamedFloat("GELB") : -1;
923  myTLS.find(LSAid)->second->addPhase(phaseid, (SUMOTime) startTime, (SUMOTime) endTime, (SUMOTime) yellowTime);
924 }
925 
926 
928  // get the id
929  std::string Phaseid = NBHelpers::normalIDRepresentation(myLineParser.get("PsNr"));
930  std::string LSAid = NBHelpers::normalIDRepresentation(myLineParser.get("LsaNr"));
931  std::string SGid = NBHelpers::normalIDRepresentation(myLineParser.get("SGNR"));
932  // insert
933  NIVisumTL* LSA = myTLS.find(LSAid)->second;
934  NIVisumTL::SignalGroup& SG = LSA->getSignalGroup(SGid);
935  NIVisumTL::Phase* PH = LSA->getPhases().find(Phaseid)->second;
936  SG.phases()[Phaseid] = PH;
937 }
938 
939 
941  // get the node
942  NBNode* node = getNamedNode("KNOTNR", "KNOT");
943  if (node == 0) {
944  return;
945  }
946  // get the from-edge
947  NBEdge* fromEdge = getNamedEdgeContinuating("VONSTRNR", "VONSTR", node);
948  NBEdge* toEdge = getNamedEdgeContinuating("NACHSTRNR", "NACHSTR", node);
949  if (fromEdge == 0 || toEdge == 0) {
950  return;
951  }
952 
953  int fromLaneOffset = 0;
954  if (!node->hasIncoming(fromEdge)) {
955  fromLaneOffset = fromEdge->getNumLanes();
956  fromEdge = getReversedContinuating(fromEdge, node);
957  } else {
958  fromEdge = getReversedContinuating(fromEdge, node);
959  NBEdge* tmp = myNetBuilder.getEdgeCont().retrieve(fromEdge->getID().substr(0, fromEdge->getID().find('_')));
960  fromLaneOffset = tmp->getNumLanes();
961  }
962 
963  int toLaneOffset = 0;
964  if (!node->hasOutgoing(toEdge)) {
965  toLaneOffset = toEdge->getNumLanes();
966  toEdge = getReversedContinuating(toEdge, node);
967  } else {
968  NBEdge* tmp = myNetBuilder.getEdgeCont().retrieve(toEdge->getID().substr(0, toEdge->getID().find('_')));
969  toLaneOffset = tmp->getNumLanes();
970  }
971  // get the from-lane
972  std::string fromLaneS = NBHelpers::normalIDRepresentation(myLineParser.get("VONFSNR"));
973  int fromLane = -1;
974  try {
975  fromLane = TplConvert::_2int(fromLaneS.c_str());
976  } catch (NumberFormatException&) {
977  WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is not numeric (" + fromLaneS + ").");
978  return;
979  }
980  fromLane -= 1;
981  if (fromLane < 0) {
982  WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is not positive (" + fromLaneS + ").");
983  return;
984  }
985  // get the from-lane
986  std::string toLaneS = NBHelpers::normalIDRepresentation(myLineParser.get("NACHFSNR"));
987  int toLane = -1;
988  try {
989  toLane = TplConvert::_2int(toLaneS.c_str());
990  } catch (NumberFormatException&) {
991  WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is not numeric (" + toLaneS + ").");
992  return;
993  }
994  toLane -= 1;
995  if (toLane < 0) {
996  WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is not positive (" + toLaneS + ").");
997  return;
998  }
999  // !!! the next is probably a hack
1000  if (fromLane - fromLaneOffset < 0) {
1001  //fromLaneOffset = 0;
1002  } else {
1003  fromLane = (int)fromEdge->getNumLanes() - (fromLane - fromLaneOffset) - 1;
1004  }
1005  if (toLane - toLaneOffset < 0) {
1006  //toLaneOffset = 0;
1007  } else {
1008  toLane = (int)toEdge->getNumLanes() - (toLane - toLaneOffset) - 1;
1009  }
1010  //
1011  if ((int) fromEdge->getNumLanes() <= fromLane) {
1012  WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is larger than the edge's lane number (" + fromLaneS + ").");
1013  return;
1014  }
1015  if ((int) toEdge->getNumLanes() <= toLane) {
1016  WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is larger than the edge's lane number (" + toLaneS + ").");
1017  return;
1018  }
1019  //
1020  fromEdge->addLane2LaneConnection(fromLane, toEdge, toLane, NBEdge::L2L_VALIDATED);
1021 }
1022 
1023 
1024 
1025 
1026 
1027 
1028 
1029 
1030 
1031 
1032 
1033 
1034 
1035 SUMOReal
1036 NIImporter_VISUM::getWeightedFloat(const std::string& name) {
1037  try {
1038  return TplConvert::_2SUMOReal(myLineParser.get(name).c_str());
1039  } catch (...) {}
1040  try {
1041  return TplConvert::_2SUMOReal(myLineParser.get((name + "(IV)")).c_str());
1042  } catch (...) {}
1043  return -1;
1044 }
1045 
1046 
1047 bool
1048 NIImporter_VISUM::getWeightedBool(const std::string& name) {
1049  try {
1050  return TplConvert::_2bool(myLineParser.get(name).c_str());
1051  } catch (...) {}
1052  try {
1053  return TplConvert::_2bool(myLineParser.get((name + "(IV)")).c_str());
1054  } catch (...) {}
1055  return false;
1056 }
1057 
1058 
1059 NBNode*
1060 NIImporter_VISUM::getNamedNode(const std::string& fieldName) {
1061  std::string nodeS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1062  NBNode* node = myNetBuilder.getNodeCont().retrieve(nodeS);
1063  if (node == 0) {
1064  WRITE_ERROR("The node '" + nodeS + "' is not known.");
1065  }
1066  return node;
1067 }
1068 
1069 
1070 NBNode*
1071 NIImporter_VISUM::getNamedNode(const std::string& fieldName1, const std::string& fieldName2) {
1072  if (myLineParser.know(fieldName1)) {
1073  return getNamedNode(fieldName1);
1074  } else {
1075  return getNamedNode(fieldName2);
1076  }
1077 }
1078 
1079 
1080 NBEdge*
1081 NIImporter_VISUM::getNamedEdge(const std::string& fieldName) {
1082  std::string edgeS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1083  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeS);
1084  if (edge == 0) {
1085  WRITE_ERROR("The edge '" + edgeS + "' is not known.");
1086  }
1087  return edge;
1088 }
1089 
1090 
1091 NBEdge*
1092 NIImporter_VISUM::getNamedEdge(const std::string& fieldName1, const std::string& fieldName2) {
1093  if (myLineParser.know(fieldName1)) {
1094  return getNamedEdge(fieldName1);
1095  } else {
1096  return getNamedEdge(fieldName2);
1097  }
1098 }
1099 
1100 
1101 
1102 NBEdge*
1104  std::string sid;
1105  if (edge->getID()[0] == '-') {
1106  sid = edge->getID().substr(1);
1107  } else {
1108  sid = "-" + edge->getID();
1109  }
1110  if (sid.find('_') != std::string::npos) {
1111  sid = sid.substr(0, sid.find('_'));
1112  }
1114 }
1115 
1116 
1117 NBEdge*
1119  if (begin == 0) {
1120  return 0;
1121  }
1122  NBEdge* ret = begin;
1123  std::string edgeID = ret->getID();
1124  // hangle forward
1125  while (ret != 0) {
1126  // ok, this is the edge we are looking for
1127  if (ret->getToNode() == node) {
1128  return ret;
1129  }
1130  const EdgeVector& nedges = ret->getToNode()->getOutgoingEdges();
1131  if (nedges.size() != 1) {
1132  // too many edges follow
1133  ret = 0;
1134  continue;
1135  }
1136  NBEdge* next = nedges[0];
1137  if (ret->getID().substr(0, edgeID.length()) != next->getID().substr(0, edgeID.length())) {
1138  // ok, another edge is next...
1139  ret = 0;
1140  continue;
1141  }
1142  if (next->getID().substr(next->getID().length() - node->getID().length()) != node->getID()) {
1143  ret = 0;
1144  continue;
1145  }
1146  ret = next;
1147  }
1148 
1149  ret = begin;
1150  // hangle backward
1151  while (ret != 0) {
1152  // ok, this is the edge we are looking for
1153  if (ret->getFromNode() == node) {
1154  return ret;
1155  }
1156  const EdgeVector& nedges = ret->getFromNode()->getIncomingEdges();
1157  if (nedges.size() != 1) {
1158  // too many edges follow
1159  ret = 0;
1160  continue;
1161  }
1162  NBEdge* next = nedges[0];
1163  if (ret->getID().substr(0, edgeID.length()) != next->getID().substr(0, edgeID.length())) {
1164  // ok, another edge is next...
1165  ret = 0;
1166  continue;
1167  }
1168  if (next->getID().substr(next->getID().length() - node->getID().length()) != node->getID()) {
1169  ret = 0;
1170  continue;
1171  }
1172  ret = next;
1173  }
1174  return 0;
1175 }
1176 
1177 
1178 NBEdge*
1179 NIImporter_VISUM::getNamedEdgeContinuating(const std::string& fieldName, NBNode* node) {
1180  std::string edgeS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1181  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeS);
1182  if (edge == 0) {
1183  WRITE_ERROR("The edge '" + edgeS + "' is not known.");
1184  }
1185  return getNamedEdgeContinuating(edge, node);
1186 }
1187 
1188 
1189 NBEdge*
1190 NIImporter_VISUM::getNamedEdgeContinuating(const std::string& fieldName1, const std::string& fieldName2,
1191  NBNode* node) {
1192  if (myLineParser.know(fieldName1)) {
1193  return getNamedEdgeContinuating(fieldName1, node);
1194  } else {
1195  return getNamedEdgeContinuating(fieldName2, node);
1196  }
1197 }
1198 
1199 
1200 NBEdge*
1202  EdgeVector::const_iterator i;
1203  for (i = FromNode->getOutgoingEdges().begin(); i != FromNode->getOutgoingEdges().end(); i++) {
1204  if (ToNode == (*i)->getToNode()) {
1205  return(*i);
1206  }
1207  }
1209  return 0;
1210 }
1211 
1212 
1213 SUMOReal
1214 NIImporter_VISUM::getNamedFloat(const std::string& fieldName) {
1215  std::string valS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1216  return TplConvert::_2SUMOReal(valS.c_str());
1217 }
1218 
1219 
1220 SUMOReal
1221 NIImporter_VISUM::getNamedFloat(const std::string& fieldName, SUMOReal defaultValue) {
1222  try {
1223  std::string valS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1224  return TplConvert::_2SUMOReal(valS.c_str());
1225  } catch (...) {
1226  return defaultValue;
1227  }
1228 }
1229 
1230 
1231 SUMOReal
1232 NIImporter_VISUM::getNamedFloat(const std::string& fieldName1, const std::string& fieldName2) {
1233  if (myLineParser.know(fieldName1)) {
1234  return getNamedFloat(fieldName1);
1235  } else {
1236  return getNamedFloat(fieldName2);
1237  }
1238 }
1239 
1240 
1241 SUMOReal
1242 NIImporter_VISUM::getNamedFloat(const std::string& fieldName1, const std::string& fieldName2,
1243  SUMOReal defaultValue) {
1244  if (myLineParser.know(fieldName1)) {
1245  return getNamedFloat(fieldName1, defaultValue);
1246  } else {
1247  return getNamedFloat(fieldName2, defaultValue);
1248  }
1249 }
1250 
1251 
1252 std::string
1253 NIImporter_VISUM::getNamedString(const std::string& fieldName) {
1255 }
1256 
1257 
1258 std::string
1259 NIImporter_VISUM::getNamedString(const std::string& fieldName1,
1260  const std::string& fieldName2) {
1261  if (myLineParser.know(fieldName1)) {
1262  return getNamedString(fieldName1);
1263  } else {
1264  return getNamedString(fieldName2);
1265  }
1266 }
1267 
1268 
1269 
1270 
1271 
1272 
1273 NBNode*
1274 NIImporter_VISUM::buildDistrictNode(const std::string& id, NBNode* dest,
1275  bool isSource) {
1276  // get the district
1278  if (dist == 0) {
1279  return 0;
1280  }
1281  // build the id
1282  std::string nid;
1283  nid = id + "-" + dest->getID();
1284  if (!isSource) {
1285  nid = "-" + nid;
1286  }
1287  // insert the node
1288  if (!myNetBuilder.getNodeCont().insert(nid, dist->getPosition())) {
1289  WRITE_ERROR("Could not build connector node '" + nid + "'.");
1290  }
1291  // return the node
1292  return myNetBuilder.getNodeCont().retrieve(nid);
1293 }
1294 
1295 
1296 bool
1298  if (from == 0) {
1299  WRITE_ERROR(" The from-node was not found within the net");
1300  }
1301  if (to == 0) {
1302  WRITE_ERROR(" The to-node was not found within the net");
1303  }
1304  if (from == to) {
1305  WRITE_ERROR(" Both nodes are the same");
1306  }
1307  return from != 0 && to != 0 && from != to;
1308 }
1309 
1310 
1311 /****************************************************************************/
1312 
std::map< std::string, Phase * > & phases()
Returns the phases map.
Definition: NIVisumTL.h:123
std::map< SUMOLong, Position > myPoints
A map of point ids to positions.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
Definition: NBNode.h:251
long position
Position of the according db within the file.
unsigned long getPosition()
Returns the current position within the file.
Definition: LineReader.cpp:197
void parse_NodesToTrafficLights()
Parses KNOTENZULSA/SIGNALANLAGEZUKNOTEN.
A signal group can be defined either by a time period or by phases.
Definition: NIVisumTL.h:108
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:201
NBTypeCont & getTypeCont()
Returns the type container.
Definition: NBNetBuilder.h:170
void parse_Kante()
Parses FLAECHENELEMENT.
bool myUseVisumPrio
Information whether VISUM priority information shall be used.
void load()
Parses the VISUM-network file storing the parsed structures within myNetBuilder.
std::map< NBDistrict *, PositionVector > myDistrictShapes
A temporary storage for district shapes as they are filled incrementally.
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
LineReader myLineReader
The line reader to use to read from the file.
std::vector< std::string > myTouchedEdges
Already read edges.
const Position & getPosition() const
Returns the position of this district's center.
Definition: NBDistrict.h:130
NBEdge * getNamedEdgeContinuating(const std::string &fieldName, NBNode *node)
Tries to get the edge which name is stored in the given field continuating the search for a subedge t...
bool readLine(LineHandler &lh)
Reads a single (the next) line from the file and reports it to the given LineHandler.
Definition: LineReader.cpp:80
static SUMOReal _2SUMOReal(const E *const data)
Definition: TplConvert.h:223
std::string myCurrentID
The name of the currently parsed item used for error reporting.
static bool _2bool(const E *const data)
Definition: TplConvert.h:282
void parse_Turns()
Parses ABBIEGEBEZIEHUNG/ABBIEGER.
VSysTypeNames myVSysTypes
The used vsystypes.
NBNode * getNamedNode(const std::string &fieldName)
Tries to get the node which name is stored in the given field.
void parse_TrafficLights()
Parses LSA/SIGNALANLAGE.
A helper class which computes the lane number from given capacity.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
Definition: NBEdge.h:71
void parse_PartOfArea()
Parses FLAECHENELEMENT.
void incLaneNo(unsigned int by)
Definition: NBEdge.cpp:2069
bool hasOutgoing(const NBEdge *const e) const
Returns whether the given edge starts at this node.
Definition: NBNode.cpp:1030
std::string get(const std::string &name, bool prune=false) const
Returns the named information.
static SUMOReal _2SUMORealSec(const E *const data, SUMOReal def)
Definition: TplConvert.h:336
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false)
Adds a connection between the specified this edge's lane and an approached one.
Definition: NBEdge.cpp:649
void parse_SignalGroupsToPhases()
Parses LSASIGNALGRUPPEZULSAPHASE.
NIImporter_VISUM(NBNetBuilder &nb, const std::string &file, NBCapacity2Lanes capacity2Lanes, bool useVisumPrio)
constructor
bool setFile(const std::string &file)
Reinitialises the reader for reading from the given file.
Definition: LineReader.cpp:189
bool addSink(const std::string &dist, NBEdge *const destination, SUMOReal weight)
Adds a sink to the named district.
void parse_EdgePolys()
Parses STRECKENPOLY.
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:404
void parse_Phases()
Parses LSAPHASE/PHASE.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
static SUMOLong _2long(const E *const data)
Definition: TplConvert.h:142
std::string myFileName
The name of the parsed file, for error reporting.
void parse_AreaSubPartElement()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:203
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
Definition: NBNode.cpp:1024
SUMOReal getNamedFloat(const std::string &fieldName)
Returns the value from the named column as a float.
NBEdge * getReversedContinuating(NBEdge *edge, NBNode *node)
Returns the opposite direction of the given edge.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
void parse_SignalGroups()
Parses LSASIGNALGRUPPE/SIGNALGRUPPE.
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder...
The connection was computed and validated.
Definition: NBEdge.h:116
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:67
A phase.
Definition: NIVisumTL.h:93
A VISUM network importer.
PositionVector reverse() const
void parse_TurnsToSignalGroups()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
A class representing a single district.
Definition: NBDistrict.h:72
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
Definition: NBNode.h:259
SUMOReal getWeightedFloat(const std::string &name)
tries to get a SUMOReal which is possibly assigned to a certain modality
const std::string & getID() const
Returns the id.
Definition: Named.h:60
void reinit(const std::string &def, const std::string &defDelim=";", const std::string &lineDelim=";", bool chomp=false, bool ignoreCase=true)
Reinitialises the parser.
bool addEdge2EdgeConnection(NBEdge *dest)
Adds a connection to another edge.
Definition: NBEdge.cpp:625
std::string getNamedString(const std::string &fieldName)
Returns the value from the named column as a normalised string.
static std::string normalIDRepresentation(const std::string &id)
Definition: NBHelpers.cpp:87
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:104
A complete call description for parsing a single db.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:170
NIVisumTL_Map myTLS
List of visum traffic lights.
void parse_Connectors()
Parses ANBINDUNG.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
Definition: NBTypeCont.cpp:98
NBEdgeCont & getEdgeCont()
Returns the edge container.
Definition: NBNetBuilder.h:154
A list of positions.
unsigned int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:347
void setAsMacroscopicConnector()
Marks this edge as a macroscopic connector.
Definition: NBEdge.h:851
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:110
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition: MsgHandler.h:202
#define SUMOLong
Definition: config.h:215
void parse_Districts()
Parses BEZIRK.
void addParser(const std::string &name, ParsingFunction function)
Adds a parser into the sorted list of parsers to use.
ParserVector mySingleDataParsers
List of known parsers.
void parse_Point()
Parses PUNKT.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
NBEdge * getEdge(NBNode *FromNode, NBNode *ToNode)
Returns the edge that connects both nodes.
NBEdge * getConnectionTo(NBNode *n) const
Definition: NBNode.cpp:1484
void parse_VSysTypes()
Parses VSYS.
std::map< SUMOLong, NBDistrict * > myShapeDistrictMap
A map from district shape definition name to the district.
bool insert(const std::string &id, int noLanes, SUMOReal maxSpeed, int prio, SUMOReal width, SUMOVehicleClass vClasses=SVC_IGNORING, bool oneWayIsDefault=false, SUMOReal sidewalkWidth=NBEdge::UNSPECIFIED_WIDTH)
Adds a type into the list. This is a simplified convenience form of insert, if only one allowed vehic...
Definition: NBTypeCont.cpp:60
std::map< SUMOLong, std::vector< SUMOLong > > mySubPartsAreas
A map from area parts to area ids.
void parse_Types()
Parses STRECKENTYP.
bool insert(NBDistrict *const district)
Adds a district to the dictionary.
void parse_Nodes()
Parses KNOTEN.
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:205
void push_back(const PositionVector &p)
Appends all positions from the given vector.
int get(SUMOReal capacity) const
Returns the number of lanes computed from the given capacity.
bool know(const std::string &name) const
Returns the information whether the named column is known.
void parse_Lanes()
Parses FAHRSTREIFEN.
static int _2int(const E *const data)
Definition: TplConvert.h:114
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:371
~NIImporter_VISUM()
destructor
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:258
NBNodeCont & getNodeCont()
Returns the node container.
Definition: NBNetBuilder.h:162
Instance responsible for building networks.
Definition: NBNetBuilder.h:113
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:41
NamedColumnsParser myLineParser
the parser to parse the information from the data lines
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:531
A storage for options typed value containers)
Definition: OptionsCont.h:108
bool addSource(const std::string &dist, NBEdge *const source, SUMOReal weight)
Adds a source to the named district.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:79
NBNode * buildDistrictNode(const std::string &id, NBNode *dest, bool isSource)
Builds a node for the given district and returns it.
std::string name
The name of the db.
NBTrafficLightLogicCont & getTLLogicCont()
Returns the traffic light logics container.
Definition: NBNetBuilder.h:178
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
Intermediate class for storing visum traffic lights during their import.
Definition: NIVisumTL.h:50
NBConnectionVector & connections()
Returns the connections vector.
Definition: NIVisumTL.h:118
int SUMOTime
Definition: SUMOTime.h:43
void reinit()
Reinitialises the reading (of the previous file)
Definition: LineReader.cpp:203
Represents a single node (junction) during network building.
Definition: NBNode.h:75
bool getWeightedBool(const std::string &name)
tries to get a bool which is possibly assigned to a certain modality
void setPos(unsigned long pos)
Sets the current position within the file to the given value.
Definition: LineReader.cpp:220
std::map< SUMOLong, std::pair< SUMOLong, SUMOLong > > myEdges
A map of edge (not road, but "edge" in this case) ids to from/to-points.
void parse_Edges()
Parses STRECKE/STRECKEN.
NBNetBuilder & myNetBuilder
The network builder to fill with loaded values.
#define SUMOReal
Definition: config.h:218
bool hasMore() const
Returns whether another line may be read (the file was not read completely)
Definition: LineReader.cpp:64
void addGeometryPoint(int index, const Position &p)
Adds a further geometry point.
Definition: NBEdge.cpp:522
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:108
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:203
ParsingFunction function
Pointer to the function used for parsing.
static int _2intSec(const E *const data, int def)
Definition: TplConvert.h:312
bool checkNodes(NBNode *from, NBNode *to)
Returns whether both nodes are a valid combination of from/to-nodes.
void setLaneSpreadFunction(LaneSpreadFunction spread)
(Re)sets how the lanes lateral offset shall be computed
Definition: NBEdge.cpp:516
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
NBEdge * getNamedEdge(const std::string &fieldName)
Tries to get the edge which name is stored in the given field.
NBDistrictCont & getDistrictCont()
Returns the districts container.
Definition: NBNetBuilder.h:186
void parseLine(const std::string &line)
Parses the contents of the line.
NBCapacity2Lanes myCapacity2Lanes
The converter to compute the lane number of edges from their capacity.
NBDistrict * retrieve(const std::string &id) const
Returns the districts with the given id.
SUMOReal getLength() const
Returns the computed length of the edge.
Definition: NBEdge.h:406
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void parse_LanesConnections()
Parses FAHRSTREIFENABBIEGER.
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:363