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-2016 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.getEdgeCont(), 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  const SUMOReal speed = getNamedFloat("v0-IV", "V0IV");
234  // get the priority
235  const int priority = 1000 - TplConvert::_2int(myLineParser.get("Rang").c_str());
236  // try to retrieve the number of lanes
237  const int numLanes = myCapacity2Lanes.get(getNamedFloat("Kap-IV", "KAPIV"));
238  // insert the type
244 }
245 
246 
247 void
249  // get the id
251  // get the position
252  SUMOReal x = getNamedFloat("XKoord");
253  SUMOReal y = getNamedFloat("YKoord");
254  Position pos(x, y);
256  WRITE_ERROR("Unable to project coordinates for node " + myCurrentID + ".");
257  return;
258  }
259  // add to the list
261  WRITE_ERROR("Duplicate node occured ('" + myCurrentID + "').");
262  }
263 }
264 
265 
266 void
268  // get the id
270  // get the information whether the source and the destination
271  // connections are weighted
272  //bool sourcesWeighted = getWeightedBool("Proz_Q");
273  //bool destWeighted = getWeightedBool("Proz_Z");
274  // get the node information
275  SUMOReal x = getNamedFloat("XKoord");
276  SUMOReal y = getNamedFloat("YKoord");
277  Position pos(x, y);
278  if (!NBNetBuilder::transformCoordinates(pos, false)) {
279  WRITE_ERROR("Unable to project coordinates for district " + myCurrentID + ".");
280  return;
281  }
282  // build the district
283  NBDistrict* district = new NBDistrict(myCurrentID, pos);
284  if (!myNetBuilder.getDistrictCont().insert(district)) {
285  WRITE_ERROR("Duplicate district occured ('" + myCurrentID + "').");
286  delete district;
287  return;
288  }
289  if (myLineParser.know("FLAECHEID")) {
290  long long int flaecheID = TplConvert::_2long(myLineParser.get("FLAECHEID").c_str());
291  myShapeDistrictMap[flaecheID] = district;
292  }
293 }
294 
295 
296 void
298  long long int id = TplConvert::_2long(myLineParser.get("ID").c_str());
299  SUMOReal x = TplConvert::_2SUMOReal(myLineParser.get("XKOORD").c_str());
300  SUMOReal y = TplConvert::_2SUMOReal(myLineParser.get("YKOORD").c_str());
301  Position pos(x, y);
302  if (!NBNetBuilder::transformCoordinates(pos, false)) {
303  WRITE_ERROR("Unable to project coordinates for point " + toString(id) + ".");
304  return;
305  }
306  myPoints[id] = pos;
307 }
308 
309 
310 void
312  if (myLineParser.know("VSYSSET") && myLineParser.get("VSYSSET") == "") {
313  // no vehicle allowed; don't add
314  return;
315  }
316  // get the id
318  // get the from- & to-node and validate them
319  NBNode* from = getNamedNode("VonKnot", "VonKnotNr");
320  NBNode* to = getNamedNode("NachKnot", "NachKnotNr");
321  if (!checkNodes(from, to)) {
322  return;
323  }
324  // get the type
325  std::string type = myLineParser.know("Typ") ? myLineParser.get("Typ") : myLineParser.get("TypNr");
326  // get the speed
327  SUMOReal speed = myNetBuilder.getTypeCont().getSpeed(type);
328  if (!OptionsCont::getOptions().getBool("visum.use-type-speed")) {
329  try {
330  std::string speedS = myLineParser.know("v0-IV") ? myLineParser.get("v0-IV") : myLineParser.get("V0IV");
331  if (speedS.find("km/h") != std::string::npos) {
332  speedS = speedS.substr(0, speedS.find("km/h"));
333  }
334  speed = TplConvert::_2SUMORealSec(speedS.c_str(), -1);
335  speed = speed / (SUMOReal) 3.6;
336  } catch (OutOfBoundsException) {}
337  }
338  if (speed <= 0) {
339  speed = myNetBuilder.getTypeCont().getSpeed(type);
340  }
341 
342  // get the information whether the edge is a one-way
343  bool oneway = myLineParser.know("Einbahn")
344  ? TplConvert::_2bool(myLineParser.get("Einbahn").c_str())
345  : true;
346  // get the number of lanes
347  int nolanes = myNetBuilder.getTypeCont().getNumLanes(type);
348  if (!OptionsCont::getOptions().getBool("visum.recompute-lane-number")) {
349  try {
350  if (!OptionsCont::getOptions().getBool("visum.use-type-laneno")) {
351  nolanes = myLineParser.know("Fahrstreifen")
352  ? TplConvert::_2intSec(myLineParser.get("Fahrstreifen").c_str(), 0)
353  : TplConvert::_2intSec(myLineParser.get("ANZFAHRSTREIFEN").c_str(), 0);
354  }
355  } catch (UnknownElement) {
356  }
357  } else {
358  SUMOReal cap = myLineParser.know("KAPIV")
359  ? TplConvert::_2SUMORealSec(myLineParser.get("KAPIV").c_str(), -1)
360  : TplConvert::_2SUMORealSec(myLineParser.get("KAP-IV").c_str(), -1);
361  nolanes = myCapacity2Lanes.get(cap);
362  }
363  // check whether the id is already used
364  // (should be the opposite direction)
365  bool oneway_checked = oneway;
367  if (previous != 0) {
368  myCurrentID = '-' + myCurrentID;
370  oneway_checked = false;
371  }
372  if (find(myTouchedEdges.begin(), myTouchedEdges.end(), myCurrentID) != myTouchedEdges.end()) {
373  oneway_checked = false;
374  }
375  std::string tmpid = '-' + myCurrentID;
376  if (find(myTouchedEdges.begin(), myTouchedEdges.end(), tmpid) != myTouchedEdges.end()) {
377  previous = myNetBuilder.getEdgeCont().retrieve(tmpid);
378  if (previous != 0) {
380  }
381  oneway_checked = false;
382  }
383  // add the edge
384  int prio = myUseVisumPrio ? myNetBuilder.getTypeCont().getPriority(type) : -1;
385  if (nolanes != 0 && speed != 0) {
386  LaneSpreadFunction lsf = oneway_checked ? LANESPREAD_CENTER : LANESPREAD_RIGHT;
387  // @todo parse name from visum files
388  NBEdge* e = new NBEdge(myCurrentID, from, to, type, speed, nolanes, prio,
390  if (!myNetBuilder.getEdgeCont().insert(e)) {
391  delete e;
392  WRITE_ERROR("Duplicate edge occured ('" + myCurrentID + "').");
393  }
394  }
395  myTouchedEdges.push_back(myCurrentID);
396  // nothing more to do, when the edge is a one-way street
397  if (oneway) {
398  return;
399  }
400  // add the opposite edge
401  myCurrentID = '-' + myCurrentID;
402  if (nolanes != 0 && speed != 0) {
403  LaneSpreadFunction lsf = oneway_checked ? LANESPREAD_CENTER : LANESPREAD_RIGHT;
404  // @todo parse name from visum files
405  NBEdge* e = new NBEdge(myCurrentID, from, to, type, speed, nolanes, prio,
407  if (!myNetBuilder.getEdgeCont().insert(e)) {
408  delete e;
409  WRITE_ERROR("Duplicate edge occured ('" + myCurrentID + "').");
410  }
411  }
412  myTouchedEdges.push_back(myCurrentID);
413 }
414 
415 
416 void
418  long long int id = TplConvert::_2long(myLineParser.get("ID").c_str());
419  long long int from = TplConvert::_2long(myLineParser.get("VONPUNKTID").c_str());
420  long long int to = TplConvert::_2long(myLineParser.get("NACHPUNKTID").c_str());
421  myEdges[id] = std::make_pair(from, to);
422 }
423 
424 
425 void
427  long long int flaecheID = TplConvert::_2long(myLineParser.get("FLAECHEID").c_str());
428  long long int flaechePartID = TplConvert::_2long(myLineParser.get("TFLAECHEID").c_str());
429  if (mySubPartsAreas.find(flaechePartID) == mySubPartsAreas.end()) {
430  mySubPartsAreas[flaechePartID] = std::vector<long long int>();
431  }
432  mySubPartsAreas[flaechePartID].push_back(flaecheID);
433 }
434 
435 
436 void
438  if (OptionsCont::getOptions().getBool("visum.no-connectors")) {
439  // do nothing, if connectors shall not be imported
440  return;
441  }
442  // get the source district
443  std::string bez = NBHelpers::normalIDRepresentation(myLineParser.get("BezNr"));
444  // get the destination node
445  NBNode* dest = getNamedNode("KnotNr");
446  if (dest == 0) {
447  return;
448  }
449  // get the weight of the connection
450  SUMOReal proz = getWeightedFloat("Proz");
451  if (proz > 0) {
452  proz /= 100.;
453  } else {
454  proz = 1;
455  }
456  // get the duration to wait (unused)
457 // SUMOReal retard = -1;
458 // if (myLineParser.know("t0-IV")) {
459 // retard = getNamedFloat("t0-IV", -1);
460 // }
461  // get the type;
462  // use a standard type with a large speed when a type is not given
463  std::string type = myLineParser.know("Typ")
465  : "";
466  // add the connectors as an edge
467  std::string id = bez + "-" + dest->getID();
468  // get the information whether this is a sink or a source
469  std::string dir = myLineParser.get("Richtung");
470  if (dir.length() == 0) {
471  dir = "QZ";
472  }
473  // build the source when needed
474  if (dir.find('Q') != std::string::npos) {
475  const EdgeVector& edges = dest->getOutgoingEdges();
476  bool hasContinuation = false;
477  for (EdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
478  if (!(*i)->isMacroscopicConnector()) {
479  hasContinuation = true;
480  }
481  }
482  if (!hasContinuation) {
483  // obviously, there is no continuation on the net
484  WRITE_WARNING("Incoming connector '" + id + "' will not be build - would be not connected to network.");
485  } else {
486  NBNode* src = buildDistrictNode(bez, dest, true);
487  if (src == 0) {
488  WRITE_ERROR("The district '" + bez + "' could not be built.");
489  return;
490  }
491  NBEdge* edge = new NBEdge(id, src, dest, "VisumConnector",
492  OptionsCont::getOptions().getFloat("visum.connector-speeds"),
493  OptionsCont::getOptions().getInt("visum.connectors-lane-number"),
495  "", LANESPREAD_RIGHT);
497  if (!myNetBuilder.getEdgeCont().insert(edge)) {
498  WRITE_ERROR("A duplicate edge id occured (ID='" + id + "').");
499  return;
500  }
501  edge = myNetBuilder.getEdgeCont().retrieve(id);
502  if (edge != 0) {
503  myNetBuilder.getDistrictCont().addSource(bez, edge, proz);
504  }
505  }
506  }
507  // build the sink when needed
508  if (dir.find('Z') != std::string::npos) {
509  const EdgeVector& edges = dest->getIncomingEdges();
510  bool hasPredeccessor = false;
511  for (EdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
512  if (!(*i)->isMacroscopicConnector()) {
513  hasPredeccessor = true;
514  }
515  }
516  if (!hasPredeccessor) {
517  // obviously, the network is not connected to this node
518  WRITE_WARNING("Outgoing connector '" + id + "' will not be build - would be not connected to network.");
519  } else {
520  NBNode* src = buildDistrictNode(bez, dest, false);
521  if (src == 0) {
522  WRITE_ERROR("The district '" + bez + "' could not be built.");
523  return;
524  }
525  id = "-" + id;
526  NBEdge* edge = new NBEdge(id, dest, src, "VisumConnector",
527  OptionsCont::getOptions().getFloat("visum.connector-speeds"),
528  OptionsCont::getOptions().getInt("visum.connectors-lane-number"),
530  "", LANESPREAD_RIGHT);
532  if (!myNetBuilder.getEdgeCont().insert(edge)) {
533  WRITE_ERROR("A duplicate edge id occured (ID='" + id + "').");
534  return;
535  }
536  edge = myNetBuilder.getEdgeCont().retrieve(id);
537  if (edge != 0) {
538  myNetBuilder.getDistrictCont().addSink(bez, edge, proz);
539  }
540  }
541  }
542 }
543 
544 
545 void
547  if (myLineParser.know("VSYSSET") && myLineParser.get("VSYSSET") == "") {
548  // no vehicle allowed; don't add
549  return;
550  }
551  // retrieve the nodes
552  NBNode* from = getNamedNode("VonKnot", "VonKnotNr");
553  NBNode* via = getNamedNode("UeberKnot", "UeberKnotNr");
554  NBNode* to = getNamedNode("NachKnot", "NachKnotNr");
555  if (from == 0 || via == 0 || to == 0) {
556  return;
557  }
558  // all nodes are known
559  std::string type = myLineParser.know("VSysCode")
560  ? myLineParser.get("VSysCode")
561  : myLineParser.get("VSYSSET");
562  if (myVSysTypes.find(type) != myVSysTypes.end() && myVSysTypes.find(type)->second == "IV") {
563  // try to set the turning definition
564  NBEdge* src = from->getConnectionTo(via);
565  NBEdge* dest = via->getConnectionTo(to);
566  // check both
567  if (src == 0) {
568  if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
569  WRITE_WARNING("There is no edge from node '" + from->getID() + "' to node '" + via->getID() + "'.");
570  }
571  return;
572  }
573  if (dest == 0) {
574  if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
575  WRITE_WARNING("There is no edge from node '" + via->getID() + "' to node '" + to->getID() + "'.");
576  }
577  return;
578  }
579  // both edges found
580  // set them into the edge
581  src->addEdge2EdgeConnection(dest);
582  }
583 }
584 
585 
586 void
588  // get the from- & to-node and validate them
589  NBNode* from = getNamedNode("VonKnot", "VonKnotNr");
590  NBNode* to = getNamedNode("NachKnot", "NachKnotNr");
591  if (!checkNodes(from, to)) {
592  return;
593  }
594  bool failed = false;
595  int index;
596  SUMOReal x, y;
597  try {
598  index = TplConvert::_2int(myLineParser.get("INDEX").c_str());
599  x = getNamedFloat("XKoord");
600  y = getNamedFloat("YKoord");
601  } catch (NumberFormatException&) {
602  WRITE_ERROR("Error in geometry description from node '" + from->getID() + "' to node '" + to->getID() + "'.");
603  return;
604  }
605  Position pos(x, y);
607  WRITE_ERROR("Unable to project coordinates for node '" + from->getID() + "'.");
608  return;
609  }
610  NBEdge* e = from->getConnectionTo(to);
611  if (e != 0) {
612  e->addGeometryPoint(index, pos);
613  } else {
614  failed = true;
615  }
616  e = to->getConnectionTo(from);
617  if (e != 0) {
618  e->addGeometryPoint(-index, pos);
619  failed = false;
620  }
621  // check whether the operation has failed
622  if (failed) {
623  if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
624  WRITE_WARNING("There is no edge from node '" + from->getID() + "' to node '" + to->getID() + "'.");
625  }
626  }
627 }
628 
629 
630 void
632  // get the node
633  NBNode* node = getNamedNode("KNOTNR");
634  // get the edge
635  NBEdge* baseEdge = getNamedEdge("STRNR");
636  NBEdge* edge = getNamedEdgeContinuating("STRNR", node);
637  // check
638  if (node == 0 || edge == 0) {
639  return;
640  }
641  // get the lane
642  std::string laneS = myLineParser.know("FSNR")
645  int lane = -1;
646  try {
647  lane = TplConvert::_2int(laneS.c_str());
648  } catch (NumberFormatException&) {
649  WRITE_ERROR("A lane number for edge '" + edge->getID() + "' is not numeric (" + laneS + ").");
650  return;
651  }
652  lane -= 1;
653  if (lane < 0) {
654  WRITE_ERROR("A lane number for edge '" + edge->getID() + "' is not positive (" + laneS + ").");
655  return;
656  }
657  // get the direction
658  std::string dirS = NBHelpers::normalIDRepresentation(myLineParser.get("RICHTTYP"));
659  int prevLaneNo = baseEdge->getNumLanes();
660  if ((dirS == "1" && !(node->hasIncoming(edge))) || (dirS == "0" && !(node->hasOutgoing(edge)))) {
661  // get the last part of the turnaround direction
662  edge = getReversedContinuating(edge, node);
663  }
664  // get the length
665  std::string lengthS = NBHelpers::normalIDRepresentation(myLineParser.get("LAENGE"));
666  SUMOReal length = -1;
667  try {
668  length = TplConvert::_2SUMOReal(lengthS.c_str());
669  } catch (NumberFormatException&) {
670  WRITE_ERROR("A lane length for edge '" + edge->getID() + "' is not numeric (" + lengthS + ").");
671  return;
672  }
673  if (length < 0) {
674  WRITE_ERROR("A lane length for edge '" + edge->getID() + "' is not positive (" + lengthS + ").");
675  return;
676  }
677  //
678  if (dirS == "1") {
679  lane -= prevLaneNo;
680  }
681  //
682  if (length == 0) {
683  if ((int) edge->getNumLanes() > lane) {
684  // ok, we know this already...
685  return;
686  }
687  // increment by one
688  edge->incLaneNo(1);
689  } else {
690  // check whether this edge already has been created
691  if (edge->getID().substr(edge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
692  if (edge->getID().substr(edge->getID().find('_')) == "_" + toString(length) + "_" + node->getID()) {
693  if ((int) edge->getNumLanes() > lane) {
694  // ok, we know this already...
695  return;
696  }
697  // increment by one
698  edge->incLaneNo(1);
699  return;
700  }
701  }
702  // nope, we have to split the edge...
703  // maybe it is not the proper edge to split - VISUM seems not to sort the splits...
704  bool mustRecheck = true;
705  SUMOReal seenLength = 0;
706  while (mustRecheck) {
707  if (edge->getID().substr(edge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
708  // ok, we have a previously created edge here
709  std::string sub = edge->getID();
710  sub = sub.substr(sub.rfind('_', sub.rfind('_') - 1));
711  sub = sub.substr(1, sub.find('_', 1) - 1);
712  SUMOReal dist = TplConvert::_2SUMOReal(sub.c_str());
713  if (dist < length) {
714  seenLength += edge->getLength();
715  if (dirS == "1") {
716  // incoming -> move back
717  edge = edge->getFromNode()->getIncomingEdges()[0];
718  } else {
719  // outgoing -> move forward
720  edge = edge->getToNode()->getOutgoingEdges()[0];
721  }
722  } else {
723  mustRecheck = false;
724  }
725  } else {
726  // we have the center edge - do not continue...
727  mustRecheck = false;
728  }
729  }
730  // compute position
731  Position p;
732  SUMOReal useLength = length - seenLength;
733  useLength = edge->getLength() - useLength;
734  std::string edgeID = edge->getID();
735  p = edge->getGeometry().positionAtOffset(useLength);
736  if (edgeID.substr(edgeID.length() - node->getID().length() - 1) == "_" + node->getID()) {
737  edgeID = edgeID.substr(0, edgeID.find('_'));
738  }
739  NBNode* rn = new NBNode(edgeID + "_" + toString((int) length) + "_" + node->getID(), p);
740  if (!myNetBuilder.getNodeCont().insert(rn)) {
741  throw ProcessError("Ups - could not insert node!");
742  }
743  std::string nid = edgeID + "_" + toString((int) length) + "_" + node->getID();
745  edge->getID(), nid, edge->getNumLanes() + 0, edge->getNumLanes() + 1);
746  NBEdge* nedge = myNetBuilder.getEdgeCont().retrieve(nid);
747  nedge = nedge->getToNode()->getOutgoingEdges()[0];
748  while (nedge->getID().substr(nedge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
749  assert(nedge->getToNode()->getOutgoingEdges().size() > 0);
750  nedge->incLaneNo(1);
751  nedge = nedge->getToNode()->getOutgoingEdges()[0];
752  }
753  }
754 }
755 
756 
757 void
760  SUMOTime cycleTime = (SUMOTime) getNamedFloat("Umlaufzeit", "UMLZEIT");
761  SUMOTime intermediateTime = (SUMOTime) getNamedFloat("StdZwischenzeit", "STDZWZEIT");
762  bool phaseBased = myLineParser.know("PhasenBasiert")
763  ? TplConvert::_2bool(myLineParser.get("PhasenBasiert").c_str())
764  : false;
765  SUMOTime offset = myLineParser.know("ZEITVERSATZ") ? TIME2STEPS(getNamedFloat("ZEITVERSATZ")) : 0;
766  // add to the list
767  myTLS[myCurrentID] = new NIVisumTL(myCurrentID, cycleTime, offset, intermediateTime, phaseBased);
768 }
769 
770 
771 void
773  std::string node = myLineParser.get("KnotNr").c_str();
774  std::string trafficLight = myLineParser.get("LsaNr").c_str();
775  // add to the list
776  myTLS[trafficLight]->addNode(myNetBuilder.getNodeCont().retrieve(node));
777 }
778 
779 
780 void
783  std::string LSAid = NBHelpers::normalIDRepresentation(myLineParser.get("LsaNr"));
784  SUMOReal startTime = getNamedFloat("GzStart", "GRUENANF");
785  SUMOReal endTime = getNamedFloat("GzEnd", "GRUENENDE");
786  SUMOReal yellowTime = myLineParser.know("GELB") ? getNamedFloat("GELB") : -1;
787  // add to the list
788  if (myTLS.find(LSAid) == myTLS.end()) {
789  WRITE_ERROR("Could not find TLS '" + LSAid + "' for setting the signal group.");
790  return;
791  }
792  myTLS.find(LSAid)->second->addSignalGroup(myCurrentID, (SUMOTime) startTime, (SUMOTime) endTime, (SUMOTime) yellowTime);
793 }
794 
795 
796 void
798  // get the id
799  std::string SGid = getNamedString("SGNR", "SIGNALGRUPPENNR");
800  std::string LSAid = getNamedString("LsaNr");
801  // nodes
802  NBNode* from = myLineParser.know("VonKnot") ? getNamedNode("VonKnot") : 0;
803  NBNode* via = myLineParser.know("KNOTNR")
804  ? getNamedNode("KNOTNR")
805  : getNamedNode("UeberKnot", "UeberKnotNr");
806  NBNode* to = myLineParser.know("NachKnot") ? getNamedNode("NachKnot") : 0;
807  // edges
808  NBEdge* edg1 = 0;
809  NBEdge* edg2 = 0;
810  if (from == 0 && to == 0) {
811  edg1 = getNamedEdgeContinuating("VONSTRNR", via);
812  edg2 = getNamedEdgeContinuating("NACHSTRNR", via);
813  } else {
814  edg1 = getEdge(from, via);
815  edg2 = getEdge(via, to);
816  }
817  // add to the list
818  NIVisumTL::SignalGroup& SG = myTLS.find(LSAid)->second->getSignalGroup(SGid);
819  if (edg1 != 0 && edg2 != 0) {
820  if (!via->hasIncoming(edg1)) {
821  std::string sid;
822  if (edg1->getID()[0] == '-') {
823  sid = edg1->getID().substr(1);
824  } else {
825  sid = "-" + edg1->getID();
826  }
827  if (sid.find('_') != std::string::npos) {
828  sid = sid.substr(0, sid.find('_'));
829  }
831  }
832  if (!via->hasOutgoing(edg2)) {
833  std::string sid;
834  if (edg2->getID()[0] == '-') {
835  sid = edg2->getID().substr(1);
836  } else {
837  sid = "-" + edg2->getID();
838  }
839  if (sid.find('_') != std::string::npos) {
840  sid = sid.substr(0, sid.find('_'));
841  }
843  }
844  SG.connections().push_back(NBConnection(edg1, edg2));
845  }
846 }
847 
848 
849 void
851  long long int id = TplConvert::_2long(myLineParser.get("TFLAECHEID").c_str());
852  long long int edgeid = TplConvert::_2long(myLineParser.get("KANTEID").c_str());
853  if (myEdges.find(edgeid) == myEdges.end()) {
854  WRITE_ERROR("Unknown edge in TEILFLAECHENELEMENT");
855  return;
856  }
857  std::string dir = myLineParser.get("RICHTUNG");
858 // get index (unused)
859 // std::string indexS = NBHelpers::normalIDRepresentation(myLineParser.get("INDEX"));
860 // int index = -1;
861 // try {
862 // index = TplConvert::_2int(indexS.c_str()) - 1;
863 // } catch (NumberFormatException&) {
864 // WRITE_ERROR("An index for a TEILFLAECHENELEMENT is not numeric (id='" + toString(id) + "').");
865 // return;
866 // }
867  PositionVector shape;
868  shape.push_back(myPoints[myEdges[edgeid].first]);
869  shape.push_back(myPoints[myEdges[edgeid].second]);
870  if (dir.length() > 0 && dir[0] == '1') {
871  shape = shape.reverse();
872  }
873  if (mySubPartsAreas.find(id) == mySubPartsAreas.end()) {
874  WRITE_ERROR("Unkown are for area part '" + myCurrentID + "'.");
875  return;
876  }
877 
878  const std::vector<long long int>& areas = mySubPartsAreas.find(id)->second;
879  for (std::vector<long long int>::const_iterator i = areas.begin(); i != areas.end(); ++i) {
881  if (d == 0) {
882  continue;
883  }
884  if (myDistrictShapes.find(d) == myDistrictShapes.end()) {
886  }
887  if (dir.length() > 0 && dir[0] == '1') {
888  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].second]);
889  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].first]);
890  } else {
891  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].first]);
892  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].second]);
893  }
894  }
895 }
896 
897 
898 void
900  // get the id
901  std::string phaseid = NBHelpers::normalIDRepresentation(myLineParser.get("Nr"));
902  std::string LSAid = NBHelpers::normalIDRepresentation(myLineParser.get("LsaNr"));
903  SUMOReal startTime = getNamedFloat("GzStart", "GRUENANF");
904  SUMOReal endTime = getNamedFloat("GzEnd", "GRUENENDE");
905  SUMOReal yellowTime = myLineParser.know("GELB") ? getNamedFloat("GELB") : -1;
906  myTLS.find(LSAid)->second->addPhase(phaseid, (SUMOTime) startTime, (SUMOTime) endTime, (SUMOTime) yellowTime);
907 }
908 
909 
911  // get the id
912  std::string Phaseid = NBHelpers::normalIDRepresentation(myLineParser.get("PsNr"));
913  std::string LSAid = NBHelpers::normalIDRepresentation(myLineParser.get("LsaNr"));
914  std::string SGid = NBHelpers::normalIDRepresentation(myLineParser.get("SGNR"));
915  // insert
916  NIVisumTL* LSA = myTLS.find(LSAid)->second;
917  NIVisumTL::SignalGroup& SG = LSA->getSignalGroup(SGid);
918  NIVisumTL::Phase* PH = LSA->getPhases().find(Phaseid)->second;
919  SG.phases()[Phaseid] = PH;
920 }
921 
922 
924  // get the node
925  NBNode* node = getNamedNode("KNOTNR", "KNOT");
926  if (node == 0) {
927  return;
928  }
929  // get the from-edge
930  NBEdge* fromEdge = getNamedEdgeContinuating("VONSTRNR", "VONSTR", node);
931  NBEdge* toEdge = getNamedEdgeContinuating("NACHSTRNR", "NACHSTR", node);
932  if (fromEdge == 0 || toEdge == 0) {
933  return;
934  }
935 
936  int fromLaneOffset = 0;
937  if (!node->hasIncoming(fromEdge)) {
938  fromLaneOffset = fromEdge->getNumLanes();
939  fromEdge = getReversedContinuating(fromEdge, node);
940  } else {
941  fromEdge = getReversedContinuating(fromEdge, node);
942  NBEdge* tmp = myNetBuilder.getEdgeCont().retrieve(fromEdge->getID().substr(0, fromEdge->getID().find('_')));
943  fromLaneOffset = tmp->getNumLanes();
944  }
945 
946  int toLaneOffset = 0;
947  if (!node->hasOutgoing(toEdge)) {
948  toLaneOffset = toEdge->getNumLanes();
949  toEdge = getReversedContinuating(toEdge, node);
950  } else {
951  NBEdge* tmp = myNetBuilder.getEdgeCont().retrieve(toEdge->getID().substr(0, toEdge->getID().find('_')));
952  toLaneOffset = tmp->getNumLanes();
953  }
954  // get the from-lane
955  std::string fromLaneS = NBHelpers::normalIDRepresentation(myLineParser.get("VONFSNR"));
956  int fromLane = -1;
957  try {
958  fromLane = TplConvert::_2int(fromLaneS.c_str());
959  } catch (NumberFormatException&) {
960  WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is not numeric (" + fromLaneS + ").");
961  return;
962  }
963  fromLane -= 1;
964  if (fromLane < 0) {
965  WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is not positive (" + fromLaneS + ").");
966  return;
967  }
968  // get the from-lane
969  std::string toLaneS = NBHelpers::normalIDRepresentation(myLineParser.get("NACHFSNR"));
970  int toLane = -1;
971  try {
972  toLane = TplConvert::_2int(toLaneS.c_str());
973  } catch (NumberFormatException&) {
974  WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is not numeric (" + toLaneS + ").");
975  return;
976  }
977  toLane -= 1;
978  if (toLane < 0) {
979  WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is not positive (" + toLaneS + ").");
980  return;
981  }
982  // !!! the next is probably a hack
983  if (fromLane - fromLaneOffset < 0) {
984  //fromLaneOffset = 0;
985  } else {
986  fromLane = (int)fromEdge->getNumLanes() - (fromLane - fromLaneOffset) - 1;
987  }
988  if (toLane - toLaneOffset < 0) {
989  //toLaneOffset = 0;
990  } else {
991  toLane = (int)toEdge->getNumLanes() - (toLane - toLaneOffset) - 1;
992  }
993  //
994  if ((int) fromEdge->getNumLanes() <= fromLane) {
995  WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is larger than the edge's lane number (" + fromLaneS + ").");
996  return;
997  }
998  if ((int) toEdge->getNumLanes() <= toLane) {
999  WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is larger than the edge's lane number (" + toLaneS + ").");
1000  return;
1001  }
1002  //
1003  fromEdge->addLane2LaneConnection(fromLane, toEdge, toLane, NBEdge::L2L_VALIDATED);
1004 }
1005 
1006 
1007 
1008 
1009 
1010 
1011 
1012 
1013 
1014 
1015 
1016 
1017 
1018 SUMOReal
1019 NIImporter_VISUM::getWeightedFloat(const std::string& name) {
1020  try {
1021  return TplConvert::_2SUMOReal(myLineParser.get(name).c_str());
1022  } catch (...) {}
1023  try {
1024  return TplConvert::_2SUMOReal(myLineParser.get((name + "(IV)")).c_str());
1025  } catch (...) {}
1026  return -1;
1027 }
1028 
1029 
1030 bool
1031 NIImporter_VISUM::getWeightedBool(const std::string& name) {
1032  try {
1033  return TplConvert::_2bool(myLineParser.get(name).c_str());
1034  } catch (...) {}
1035  try {
1036  return TplConvert::_2bool(myLineParser.get((name + "(IV)")).c_str());
1037  } catch (...) {}
1038  return false;
1039 }
1040 
1041 
1042 NBNode*
1043 NIImporter_VISUM::getNamedNode(const std::string& fieldName) {
1044  std::string nodeS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1045  NBNode* node = myNetBuilder.getNodeCont().retrieve(nodeS);
1046  if (node == 0) {
1047  WRITE_ERROR("The node '" + nodeS + "' is not known.");
1048  }
1049  return node;
1050 }
1051 
1052 
1053 NBNode*
1054 NIImporter_VISUM::getNamedNode(const std::string& fieldName1, const std::string& fieldName2) {
1055  if (myLineParser.know(fieldName1)) {
1056  return getNamedNode(fieldName1);
1057  } else {
1058  return getNamedNode(fieldName2);
1059  }
1060 }
1061 
1062 
1063 NBEdge*
1064 NIImporter_VISUM::getNamedEdge(const std::string& fieldName) {
1065  std::string edgeS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1066  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeS);
1067  if (edge == 0) {
1068  WRITE_ERROR("The edge '" + edgeS + "' is not known.");
1069  }
1070  return edge;
1071 }
1072 
1073 
1074 NBEdge*
1075 NIImporter_VISUM::getNamedEdge(const std::string& fieldName1, const std::string& fieldName2) {
1076  if (myLineParser.know(fieldName1)) {
1077  return getNamedEdge(fieldName1);
1078  } else {
1079  return getNamedEdge(fieldName2);
1080  }
1081 }
1082 
1083 
1084 
1085 NBEdge*
1087  std::string sid;
1088  if (edge->getID()[0] == '-') {
1089  sid = edge->getID().substr(1);
1090  } else {
1091  sid = "-" + edge->getID();
1092  }
1093  if (sid.find('_') != std::string::npos) {
1094  sid = sid.substr(0, sid.find('_'));
1095  }
1097 }
1098 
1099 
1100 NBEdge*
1102  if (begin == 0) {
1103  return 0;
1104  }
1105  NBEdge* ret = begin;
1106  std::string edgeID = ret->getID();
1107  // hangle forward
1108  while (ret != 0) {
1109  // ok, this is the edge we are looking for
1110  if (ret->getToNode() == node) {
1111  return ret;
1112  }
1113  const EdgeVector& nedges = ret->getToNode()->getOutgoingEdges();
1114  if (nedges.size() != 1) {
1115  // too many edges follow
1116  ret = 0;
1117  continue;
1118  }
1119  NBEdge* next = nedges[0];
1120  if (ret->getID().substr(0, edgeID.length()) != next->getID().substr(0, edgeID.length())) {
1121  // ok, another edge is next...
1122  ret = 0;
1123  continue;
1124  }
1125  if (next->getID().substr(next->getID().length() - node->getID().length()) != node->getID()) {
1126  ret = 0;
1127  continue;
1128  }
1129  ret = next;
1130  }
1131 
1132  ret = begin;
1133  // hangle backward
1134  while (ret != 0) {
1135  // ok, this is the edge we are looking for
1136  if (ret->getFromNode() == node) {
1137  return ret;
1138  }
1139  const EdgeVector& nedges = ret->getFromNode()->getIncomingEdges();
1140  if (nedges.size() != 1) {
1141  // too many edges follow
1142  ret = 0;
1143  continue;
1144  }
1145  NBEdge* next = nedges[0];
1146  if (ret->getID().substr(0, edgeID.length()) != next->getID().substr(0, edgeID.length())) {
1147  // ok, another edge is next...
1148  ret = 0;
1149  continue;
1150  }
1151  if (next->getID().substr(next->getID().length() - node->getID().length()) != node->getID()) {
1152  ret = 0;
1153  continue;
1154  }
1155  ret = next;
1156  }
1157  return 0;
1158 }
1159 
1160 
1161 NBEdge*
1162 NIImporter_VISUM::getNamedEdgeContinuating(const std::string& fieldName, NBNode* node) {
1163  std::string edgeS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1164  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeS);
1165  if (edge == 0) {
1166  WRITE_ERROR("The edge '" + edgeS + "' is not known.");
1167  }
1168  return getNamedEdgeContinuating(edge, node);
1169 }
1170 
1171 
1172 NBEdge*
1173 NIImporter_VISUM::getNamedEdgeContinuating(const std::string& fieldName1, const std::string& fieldName2,
1174  NBNode* node) {
1175  if (myLineParser.know(fieldName1)) {
1176  return getNamedEdgeContinuating(fieldName1, node);
1177  } else {
1178  return getNamedEdgeContinuating(fieldName2, node);
1179  }
1180 }
1181 
1182 
1183 NBEdge*
1185  EdgeVector::const_iterator i;
1186  for (i = FromNode->getOutgoingEdges().begin(); i != FromNode->getOutgoingEdges().end(); i++) {
1187  if (ToNode == (*i)->getToNode()) {
1188  return (*i);
1189  }
1190  }
1192  return 0;
1193 }
1194 
1195 
1196 SUMOReal
1197 NIImporter_VISUM::getNamedFloat(const std::string& fieldName) {
1198  std::string valS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1199  return TplConvert::_2SUMOReal(valS.c_str());
1200 }
1201 
1202 
1203 SUMOReal
1204 NIImporter_VISUM::getNamedFloat(const std::string& fieldName, SUMOReal defaultValue) {
1205  try {
1206  std::string valS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1207  return TplConvert::_2SUMOReal(valS.c_str());
1208  } catch (...) {
1209  return defaultValue;
1210  }
1211 }
1212 
1213 
1214 SUMOReal
1215 NIImporter_VISUM::getNamedFloat(const std::string& fieldName1, const std::string& fieldName2) {
1216  if (myLineParser.know(fieldName1)) {
1217  return getNamedFloat(fieldName1);
1218  } else {
1219  return getNamedFloat(fieldName2);
1220  }
1221 }
1222 
1223 
1224 SUMOReal
1225 NIImporter_VISUM::getNamedFloat(const std::string& fieldName1, const std::string& fieldName2,
1226  SUMOReal defaultValue) {
1227  if (myLineParser.know(fieldName1)) {
1228  return getNamedFloat(fieldName1, defaultValue);
1229  } else {
1230  return getNamedFloat(fieldName2, defaultValue);
1231  }
1232 }
1233 
1234 
1235 std::string
1236 NIImporter_VISUM::getNamedString(const std::string& fieldName) {
1238 }
1239 
1240 
1241 std::string
1242 NIImporter_VISUM::getNamedString(const std::string& fieldName1,
1243  const std::string& fieldName2) {
1244  if (myLineParser.know(fieldName1)) {
1245  return getNamedString(fieldName1);
1246  } else {
1247  return getNamedString(fieldName2);
1248  }
1249 }
1250 
1251 
1252 
1253 
1254 
1255 
1256 NBNode*
1257 NIImporter_VISUM::buildDistrictNode(const std::string& id, NBNode* dest,
1258  bool isSource) {
1259  // get the district
1261  if (dist == 0) {
1262  return 0;
1263  }
1264  // build the id
1265  std::string nid;
1266  nid = id + "-" + dest->getID();
1267  if (!isSource) {
1268  nid = "-" + nid;
1269  }
1270  // insert the node
1271  if (!myNetBuilder.getNodeCont().insert(nid, dist->getPosition())) {
1272  WRITE_ERROR("Could not build connector node '" + nid + "'.");
1273  }
1274  // return the node
1275  return myNetBuilder.getNodeCont().retrieve(nid);
1276 }
1277 
1278 
1279 bool
1281  if (from == 0) {
1282  WRITE_ERROR(" The from-node was not found within the net");
1283  }
1284  if (to == 0) {
1285  WRITE_ERROR(" The to-node was not found within the net");
1286  }
1287  if (from == to) {
1288  WRITE_ERROR(" Both nodes are the same");
1289  }
1290  return from != 0 && to != 0 && from != to;
1291 }
1292 
1293 
1294 /****************************************************************************/
1295 
std::map< std::string, Phase * > & phases()
Returns the phases map.
Definition: NIVisumTL.h:124
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
Definition: NBNode.h:240
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:109
long long int SUMOTime
Definition: SUMOTime.h:43
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
Definition: NBEdge.h:237
NBTypeCont & getTypeCont()
Returns the type container.
Definition: NBNetBuilder.h:169
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)
converts a char-type array into the SUMOReal value described by it
Definition: TplConvert.h:290
std::string myCurrentID
The name of the currently parsed item used for error reporting.
static bool _2bool(const E *const data)
converts a 0-terminated char-type array into the boolean value described by it
Definition: TplConvert.h:364
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.
bool hasOutgoing(const NBEdge *const e) const
Returns whether the given edge starts at this node.
Definition: NBNode.cpp:1230
std::string get(const std::string &name, bool prune=false) const
Returns the named information.
static SUMOReal _2SUMORealSec(const E *const data, SUMOReal def)
converts a 0-terminated char-type array into the SUMOReal value described by it
Definition: TplConvert.h:348
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.
static long long int _2long(const E *const data)
converts a char-type array into the long value described by it
Definition: TplConvert.h:200
bool markAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a type as set.
Definition: NBTypeCont.cpp:96
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
Definition: NBEdgeCont.cpp:412
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
std::string myFileName
The name of the parsed file, for error reporting.
const SVCPermissions SVCAll
void parse_AreaSubPartElement()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:240
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
Definition: NBNode.cpp:1224
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:117
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
A phase.
Definition: NIVisumTL.h:94
A VISUM network importer.
PositionVector reverse() const
reverse position vector
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:248
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:66
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:778
void incLaneNo(int by)
increment lane
Definition: NBEdge.cpp:2543
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:80
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
Definition: NBTypeCont.cpp:185
std::map< long long int, std::pair< long long int, long long int > > myEdges
A map of edge (not road, but "edge" in this case) ids to from/to-points.
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:162
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:179
NBEdgeCont & getEdgeCont()
Returns the edge container.
Definition: NBNetBuilder.h:153
A list of positions.
void setAsMacroscopicConnector()
Definition: NBEdge.h:885
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:191
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, SUMOReal contPos=UNSPECIFIED_CONTPOS, SUMOReal visibility=UNSPECIFIED_VISIBILITY_DISTANCE)
Adds a connection between the specified this edge's lane and an approached one.
Definition: NBEdge.cpp:802
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:395
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
std::map< long long int, std::vector< long long int > > mySubPartsAreas
A map from area parts to area ids.
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition: MsgHandler.h:202
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.
std::map< long long int, Position > myPoints
A map of point ids to positions.
void parse_Point()
Parses PUNKT.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
NBEdge * getEdge(NBNode *FromNode, NBNode *ToNode)
Returns the edge that connects both nodes.
NBEdge * getConnectionTo(NBNode *n) const
Definition: NBNode.cpp:1745
void parse_VSysTypes()
Parses VSYS.
void insert(const std::string &id, int numLanes, SUMOReal maxSpeed, int prio, SVCPermissions permissions, SUMOReal width, bool oneWayIsDefault, SUMOReal sidewalkWidth, SUMOReal bikeLaneWidth)
Adds a type into the list.
Definition: NBTypeCont.cpp:65
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:206
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)
converts a char-type array into the integer value described by it
Definition: TplConvert.h:149
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:416
~NIImporter_VISUM()
destructor
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:247
NBNodeCont & getNodeCont()
Returns the node container.
Definition: NBNetBuilder.h:161
Instance responsible for building networks.
Definition: NBNetBuilder.h:112
std::vector< NBEdge * > EdgeVector
Definition: NBCont.h:41
NamedColumnsParser myLineParser
the parser to parse the information from the data lines
std::map< long long int, NBDistrict * > myShapeDistrictMap
A map from district shape definition name to the district.
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:577
A storage for options typed value containers)
Definition: OptionsCont.h:99
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:81
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:177
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:51
NBConnectionVector & connections()
Returns the connections vector.
Definition: NIVisumTL.h:119
void reinit()
Reinitialises the reading (of the previous file)
Definition: LineReader.cpp:203
Represents a single node (junction) during network building.
Definition: NBNode.h:74
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
void parse_Edges()
Parses STRECKE/STRECKEN.
NBNetBuilder & myNetBuilder
The network builder to fill with loaded values.
#define SUMOReal
Definition: config.h:214
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:671
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:110
#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)
converts a 0-terminated char-type array into the integer value described by it
Definition: TplConvert.h:186
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:665
#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:185
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:463
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:409