SUMO - Simulation of Urban MObility
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  // maybe it was removed due to something
569  if (OptionsCont::getOptions().isSet("keep-edges.min-speed")
570  ||
571  OptionsCont::getOptions().isSet("keep-edges.explicit")) {
572  WRITE_WARNING("Could not set connection from node '" + from->getID() + "' to node '" + via->getID() + "'.");
573  } else {
574  if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
575  WRITE_WARNING("There is no edge from node '" + from->getID() + "' to node '" + via->getID() + "'.");
576  }
577  }
578  return;
579  }
580  if (dest == 0) {
581  if (OptionsCont::getOptions().isSet("keep-edges.min-speed")
582  ||
583  OptionsCont::getOptions().isSet("keep-edges.explicit")) {
584  WRITE_WARNING("Could not set connection from node '" + via->getID() + "' to node '" + to->getID() + "'.");
585  } else {
586  if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
587  WRITE_WARNING("There is no edge from node '" + via->getID() + "' to node '" + to->getID() + "'.");
588  }
589  }
590  return;
591  }
592  // both edges found
593  // set them into the edge
594  src->addEdge2EdgeConnection(dest);
595  }
596 }
597 
598 
599 void
601  // get the from- & to-node and validate them
602  NBNode* from = getNamedNode("VonKnot", "VonKnotNr");
603  NBNode* to = getNamedNode("NachKnot", "NachKnotNr");
604  if (!checkNodes(from, to)) {
605  return;
606  }
607  bool failed = false;
608  int index;
609  SUMOReal x, y;
610  try {
611  index = TplConvert::_2int(myLineParser.get("INDEX").c_str());
612  x = getNamedFloat("XKoord");
613  y = getNamedFloat("YKoord");
614  } catch (NumberFormatException&) {
615  WRITE_ERROR("Error in geometry description from node '" + from->getID() + "' to node '" + to->getID() + "'.");
616  return;
617  }
618  Position pos(x, y);
620  WRITE_ERROR("Unable to project coordinates for node '" + from->getID() + "'.");
621  return;
622  }
623  NBEdge* e = from->getConnectionTo(to);
624  if (e != 0) {
625  e->addGeometryPoint(index, pos);
626  } else {
627  failed = true;
628  }
629  e = to->getConnectionTo(from);
630  if (e != 0) {
631  e->addGeometryPoint(-index, pos);
632  failed = false;
633  }
634  // check whether the operation has failed
635  if (failed) {
636  // we should report this to the warning instance only if we have removed
637  // some nodes or edges...
638  if (OptionsCont::getOptions().isSet("keep-edges.min-speed") || OptionsCont::getOptions().isSet("keep-edges.explicit")) {
639  WRITE_WARNING("Could not set geometry between node '" + from->getID() + "' and node '" + to->getID() + "'.");
640  } else {
641  // ... in the other case we report this to the error instance
642  if (OptionsCont::getOptions().getBool("visum.verbose-warnings")) {
643  WRITE_WARNING("There is no edge from node '" + from->getID() + "' to node '" + to->getID() + "'.");
644  }
645  }
646  }
647 }
648 
649 
650 void
652  // get the node
653  NBNode* node = getNamedNode("KNOTNR");
654  // get the edge
655  NBEdge* baseEdge = getNamedEdge("STRNR");
656  NBEdge* edge = getNamedEdgeContinuating("STRNR", node);
657  // check
658  if (node == 0 || edge == 0) {
659  return;
660  }
661  // get the lane
662  std::string laneS = myLineParser.know("FSNR")
665  int lane = -1;
666  try {
667  lane = TplConvert::_2int(laneS.c_str());
668  } catch (NumberFormatException&) {
669  WRITE_ERROR("A lane number for edge '" + edge->getID() + "' is not numeric (" + laneS + ").");
670  return;
671  }
672  lane -= 1;
673  if (lane < 0) {
674  WRITE_ERROR("A lane number for edge '" + edge->getID() + "' is not positive (" + laneS + ").");
675  return;
676  }
677  // get the direction
678  std::string dirS = NBHelpers::normalIDRepresentation(myLineParser.get("RICHTTYP"));
679  int prevLaneNo = baseEdge->getNumLanes();
680  if ((dirS == "1" && !(node->hasIncoming(edge))) || (dirS == "0" && !(node->hasOutgoing(edge)))) {
681  // get the last part of the turnaround direction
682  edge = getReversedContinuating(edge, node);
683  }
684  // get the length
685  std::string lengthS = NBHelpers::normalIDRepresentation(myLineParser.get("LAENGE"));
686  SUMOReal length = -1;
687  try {
688  length = TplConvert::_2SUMOReal(lengthS.c_str());
689  } catch (NumberFormatException&) {
690  WRITE_ERROR("A lane length for edge '" + edge->getID() + "' is not numeric (" + lengthS + ").");
691  return;
692  }
693  if (length < 0) {
694  WRITE_ERROR("A lane length for edge '" + edge->getID() + "' is not positive (" + lengthS + ").");
695  return;
696  }
697  //
698  if (dirS == "1") {
699  lane -= prevLaneNo;
700  }
701  //
702  if (length == 0) {
703  if ((int) edge->getNumLanes() > lane) {
704  // ok, we know this already...
705  return;
706  }
707  // increment by one
708  edge->incLaneNo(1);
709  } else {
710  // check whether this edge already has been created
711  if (edge->getID().substr(edge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
712  if (edge->getID().substr(edge->getID().find('_')) == "_" + toString(length) + "_" + node->getID()) {
713  if ((int) edge->getNumLanes() > lane) {
714  // ok, we know this already...
715  return;
716  }
717  // increment by one
718  edge->incLaneNo(1);
719  return;
720  }
721  }
722  // nope, we have to split the edge...
723  // maybe it is not the proper edge to split - VISUM seems not to sort the splits...
724  bool mustRecheck = true;
725  SUMOReal seenLength = 0;
726  while (mustRecheck) {
727  if (edge->getID().substr(edge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
728  // ok, we have a previously created edge here
729  std::string sub = edge->getID();
730  sub = sub.substr(sub.rfind('_', sub.rfind('_') - 1));
731  sub = sub.substr(1, sub.find('_', 1) - 1);
732  SUMOReal dist = TplConvert::_2SUMOReal(sub.c_str());
733  if (dist < length) {
734  seenLength += edge->getLength();
735  if (dirS == "1") {
736  // incoming -> move back
737  edge = edge->getFromNode()->getIncomingEdges()[0];
738  } else {
739  // outgoing -> move forward
740  edge = edge->getToNode()->getOutgoingEdges()[0];
741  }
742  } else {
743  mustRecheck = false;
744  }
745  } else {
746  // we have the center edge - do not continue...
747  mustRecheck = false;
748  }
749  }
750  // compute position
751  Position p;
752  SUMOReal useLength = length - seenLength;
753  useLength = edge->getLength() - useLength;
754  std::string edgeID = edge->getID();
755  p = edge->getGeometry().positionAtOffset(useLength);
756  if (edgeID.substr(edgeID.length() - node->getID().length() - 1) == "_" + node->getID()) {
757  edgeID = edgeID.substr(0, edgeID.find('_'));
758  }
759  NBNode* rn = new NBNode(edgeID + "_" + toString((int) length) + "_" + node->getID(), p);
760  if (!myNetBuilder.getNodeCont().insert(rn)) {
761  throw ProcessError("Ups - could not insert node!");
762  }
763  std::string nid = edgeID + "_" + toString((int) length) + "_" + node->getID();
765  edge->getID(), nid, edge->getNumLanes() + 0, edge->getNumLanes() + 1);
766  NBEdge* nedge = myNetBuilder.getEdgeCont().retrieve(nid);
767  nedge = nedge->getToNode()->getOutgoingEdges()[0];
768  while (nedge->getID().substr(nedge->getID().length() - node->getID().length() - 1) == "_" + node->getID()) {
769  assert(nedge->getToNode()->getOutgoingEdges().size() > 0);
770  nedge->incLaneNo(1);
771  nedge = nedge->getToNode()->getOutgoingEdges()[0];
772  }
773  }
774 }
775 
776 
777 void
780  SUMOTime cycleTime = (SUMOTime) getNamedFloat("Umlaufzeit", "UMLZEIT");
781  SUMOTime intermediateTime = (SUMOTime) getNamedFloat("StdZwischenzeit", "STDZWZEIT");
782  bool phaseBased = myLineParser.know("PhasenBasiert")
783  ? TplConvert::_2bool(myLineParser.get("PhasenBasiert").c_str())
784  : false;
785  SUMOTime offset = myLineParser.know("ZEITVERSATZ") ? TIME2STEPS(getNamedFloat("ZEITVERSATZ")) : 0;
786  // add to the list
787  myTLS[myCurrentID] = new NIVisumTL(myCurrentID, cycleTime, offset, intermediateTime, phaseBased);
788 }
789 
790 
791 void
793  std::string node = myLineParser.get("KnotNr").c_str();
794  std::string trafficLight = myLineParser.get("LsaNr").c_str();
795  // add to the list
796  myTLS[trafficLight]->addNode(myNetBuilder.getNodeCont().retrieve(node));
797 }
798 
799 
800 void
803  std::string LSAid = NBHelpers::normalIDRepresentation(myLineParser.get("LsaNr"));
804  SUMOReal startTime = getNamedFloat("GzStart", "GRUENANF");
805  SUMOReal endTime = getNamedFloat("GzEnd", "GRUENENDE");
806  SUMOReal yellowTime = myLineParser.know("GELB") ? getNamedFloat("GELB") : -1;
807  // add to the list
808  if (myTLS.find(LSAid) == myTLS.end()) {
809  WRITE_ERROR("Could not find TLS '" + LSAid + "' for setting the signal group.");
810  return;
811  }
812  myTLS.find(LSAid)->second->addSignalGroup(myCurrentID, (SUMOTime) startTime, (SUMOTime) endTime, (SUMOTime) yellowTime);
813 }
814 
815 
816 void
818  // get the id
819  std::string SGid = getNamedString("SGNR", "SIGNALGRUPPENNR");
820  std::string LSAid = getNamedString("LsaNr");
821  // nodes
822  NBNode* from = myLineParser.know("VonKnot") ? getNamedNode("VonKnot") : 0;
823  NBNode* via = myLineParser.know("KNOTNR")
824  ? getNamedNode("KNOTNR")
825  : getNamedNode("UeberKnot", "UeberKnotNr");
826  NBNode* to = myLineParser.know("NachKnot") ? getNamedNode("NachKnot") : 0;
827  // edges
828  NBEdge* edg1 = 0;
829  NBEdge* edg2 = 0;
830  if (from == 0 && to == 0) {
831  edg1 = getNamedEdgeContinuating("VONSTRNR", via);
832  edg2 = getNamedEdgeContinuating("NACHSTRNR", via);
833  } else {
834  edg1 = getEdge(from, via);
835  edg2 = getEdge(via, to);
836  }
837  // add to the list
838  NIVisumTL::SignalGroup& SG = myTLS.find(LSAid)->second->getSignalGroup(SGid);
839  if (edg1 != 0 && edg2 != 0) {
840  if (!via->hasIncoming(edg1)) {
841  std::string sid;
842  if (edg1->getID()[0] == '-') {
843  sid = edg1->getID().substr(1);
844  } else {
845  sid = "-" + edg1->getID();
846  }
847  if (sid.find('_') != std::string::npos) {
848  sid = sid.substr(0, sid.find('_'));
849  }
851  }
852  if (!via->hasOutgoing(edg2)) {
853  std::string sid;
854  if (edg2->getID()[0] == '-') {
855  sid = edg2->getID().substr(1);
856  } else {
857  sid = "-" + edg2->getID();
858  }
859  if (sid.find('_') != std::string::npos) {
860  sid = sid.substr(0, sid.find('_'));
861  }
863  }
864  SG.connections().push_back(NBConnection(edg1, edg2));
865  }
866 }
867 
868 
869 void
871  long long int id = TplConvert::_2long(myLineParser.get("TFLAECHEID").c_str());
872  long long int edgeid = TplConvert::_2long(myLineParser.get("KANTEID").c_str());
873  if (myEdges.find(edgeid) == myEdges.end()) {
874  WRITE_ERROR("Unknown edge in TEILFLAECHENELEMENT");
875  return;
876  }
877  std::string dir = myLineParser.get("RICHTUNG");
878 // get index (unused)
879 // std::string indexS = NBHelpers::normalIDRepresentation(myLineParser.get("INDEX"));
880 // int index = -1;
881 // try {
882 // index = TplConvert::_2int(indexS.c_str()) - 1;
883 // } catch (NumberFormatException&) {
884 // WRITE_ERROR("An index for a TEILFLAECHENELEMENT is not numeric (id='" + toString(id) + "').");
885 // return;
886 // }
887  PositionVector shape;
888  shape.push_back(myPoints[myEdges[edgeid].first]);
889  shape.push_back(myPoints[myEdges[edgeid].second]);
890  if (dir.length() > 0 && dir[0] == '1') {
891  shape = shape.reverse();
892  }
893  if (mySubPartsAreas.find(id) == mySubPartsAreas.end()) {
894  WRITE_ERROR("Unkown are for area part '" + myCurrentID + "'.");
895  return;
896  }
897 
898  const std::vector<long long int>& areas = mySubPartsAreas.find(id)->second;
899  for (std::vector<long long int>::const_iterator i = areas.begin(); i != areas.end(); ++i) {
901  if (d == 0) {
902  continue;
903  }
904  if (myDistrictShapes.find(d) == myDistrictShapes.end()) {
906  }
907  if (dir.length() > 0 && dir[0] == '1') {
908  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].second]);
909  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].first]);
910  } else {
911  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].first]);
912  myDistrictShapes[d].push_back(myPoints[myEdges[edgeid].second]);
913  }
914  }
915 }
916 
917 
918 void
920  // get the id
921  std::string phaseid = NBHelpers::normalIDRepresentation(myLineParser.get("Nr"));
922  std::string LSAid = NBHelpers::normalIDRepresentation(myLineParser.get("LsaNr"));
923  SUMOReal startTime = getNamedFloat("GzStart", "GRUENANF");
924  SUMOReal endTime = getNamedFloat("GzEnd", "GRUENENDE");
925  SUMOReal yellowTime = myLineParser.know("GELB") ? getNamedFloat("GELB") : -1;
926  myTLS.find(LSAid)->second->addPhase(phaseid, (SUMOTime) startTime, (SUMOTime) endTime, (SUMOTime) yellowTime);
927 }
928 
929 
931  // get the id
932  std::string Phaseid = NBHelpers::normalIDRepresentation(myLineParser.get("PsNr"));
933  std::string LSAid = NBHelpers::normalIDRepresentation(myLineParser.get("LsaNr"));
934  std::string SGid = NBHelpers::normalIDRepresentation(myLineParser.get("SGNR"));
935  // insert
936  NIVisumTL* LSA = myTLS.find(LSAid)->second;
937  NIVisumTL::SignalGroup& SG = LSA->getSignalGroup(SGid);
938  NIVisumTL::Phase* PH = LSA->getPhases().find(Phaseid)->second;
939  SG.phases()[Phaseid] = PH;
940 }
941 
942 
944  // get the node
945  NBNode* node = getNamedNode("KNOTNR", "KNOT");
946  if (node == 0) {
947  return;
948  }
949  // get the from-edge
950  NBEdge* fromEdge = getNamedEdgeContinuating("VONSTRNR", "VONSTR", node);
951  NBEdge* toEdge = getNamedEdgeContinuating("NACHSTRNR", "NACHSTR", node);
952  if (fromEdge == 0 || toEdge == 0) {
953  return;
954  }
955 
956  int fromLaneOffset = 0;
957  if (!node->hasIncoming(fromEdge)) {
958  fromLaneOffset = fromEdge->getNumLanes();
959  fromEdge = getReversedContinuating(fromEdge, node);
960  } else {
961  fromEdge = getReversedContinuating(fromEdge, node);
962  NBEdge* tmp = myNetBuilder.getEdgeCont().retrieve(fromEdge->getID().substr(0, fromEdge->getID().find('_')));
963  fromLaneOffset = tmp->getNumLanes();
964  }
965 
966  int toLaneOffset = 0;
967  if (!node->hasOutgoing(toEdge)) {
968  toLaneOffset = toEdge->getNumLanes();
969  toEdge = getReversedContinuating(toEdge, node);
970  } else {
971  NBEdge* tmp = myNetBuilder.getEdgeCont().retrieve(toEdge->getID().substr(0, toEdge->getID().find('_')));
972  toLaneOffset = tmp->getNumLanes();
973  }
974  // get the from-lane
975  std::string fromLaneS = NBHelpers::normalIDRepresentation(myLineParser.get("VONFSNR"));
976  int fromLane = -1;
977  try {
978  fromLane = TplConvert::_2int(fromLaneS.c_str());
979  } catch (NumberFormatException&) {
980  WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is not numeric (" + fromLaneS + ").");
981  return;
982  }
983  fromLane -= 1;
984  if (fromLane < 0) {
985  WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is not positive (" + fromLaneS + ").");
986  return;
987  }
988  // get the from-lane
989  std::string toLaneS = NBHelpers::normalIDRepresentation(myLineParser.get("NACHFSNR"));
990  int toLane = -1;
991  try {
992  toLane = TplConvert::_2int(toLaneS.c_str());
993  } catch (NumberFormatException&) {
994  WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is not numeric (" + toLaneS + ").");
995  return;
996  }
997  toLane -= 1;
998  if (toLane < 0) {
999  WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is not positive (" + toLaneS + ").");
1000  return;
1001  }
1002  // !!! the next is probably a hack
1003  if (fromLane - fromLaneOffset < 0) {
1004  //fromLaneOffset = 0;
1005  } else {
1006  fromLane = (int)fromEdge->getNumLanes() - (fromLane - fromLaneOffset) - 1;
1007  }
1008  if (toLane - toLaneOffset < 0) {
1009  //toLaneOffset = 0;
1010  } else {
1011  toLane = (int)toEdge->getNumLanes() - (toLane - toLaneOffset) - 1;
1012  }
1013  //
1014  if ((int) fromEdge->getNumLanes() <= fromLane) {
1015  WRITE_ERROR("A from-lane number for edge '" + fromEdge->getID() + "' is larger than the edge's lane number (" + fromLaneS + ").");
1016  return;
1017  }
1018  if ((int) toEdge->getNumLanes() <= toLane) {
1019  WRITE_ERROR("A to-lane number for edge '" + toEdge->getID() + "' is larger than the edge's lane number (" + toLaneS + ").");
1020  return;
1021  }
1022  //
1023  fromEdge->addLane2LaneConnection(fromLane, toEdge, toLane, NBEdge::L2L_VALIDATED);
1024 }
1025 
1026 
1027 
1028 
1029 
1030 
1031 
1032 
1033 
1034 
1035 
1036 
1037 
1038 SUMOReal
1039 NIImporter_VISUM::getWeightedFloat(const std::string& name) {
1040  try {
1041  return TplConvert::_2SUMOReal(myLineParser.get(name).c_str());
1042  } catch (...) {}
1043  try {
1044  return TplConvert::_2SUMOReal(myLineParser.get((name + "(IV)")).c_str());
1045  } catch (...) {}
1046  return -1;
1047 }
1048 
1049 
1050 bool
1051 NIImporter_VISUM::getWeightedBool(const std::string& name) {
1052  try {
1053  return TplConvert::_2bool(myLineParser.get(name).c_str());
1054  } catch (...) {}
1055  try {
1056  return TplConvert::_2bool(myLineParser.get((name + "(IV)")).c_str());
1057  } catch (...) {}
1058  return false;
1059 }
1060 
1061 
1062 NBNode*
1063 NIImporter_VISUM::getNamedNode(const std::string& fieldName) {
1064  std::string nodeS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1065  NBNode* node = myNetBuilder.getNodeCont().retrieve(nodeS);
1066  if (node == 0) {
1067  WRITE_ERROR("The node '" + nodeS + "' is not known.");
1068  }
1069  return node;
1070 }
1071 
1072 
1073 NBNode*
1074 NIImporter_VISUM::getNamedNode(const std::string& fieldName1, const std::string& fieldName2) {
1075  if (myLineParser.know(fieldName1)) {
1076  return getNamedNode(fieldName1);
1077  } else {
1078  return getNamedNode(fieldName2);
1079  }
1080 }
1081 
1082 
1083 NBEdge*
1084 NIImporter_VISUM::getNamedEdge(const std::string& fieldName) {
1085  std::string edgeS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1086  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeS);
1087  if (edge == 0) {
1088  WRITE_ERROR("The edge '" + edgeS + "' is not known.");
1089  }
1090  return edge;
1091 }
1092 
1093 
1094 NBEdge*
1095 NIImporter_VISUM::getNamedEdge(const std::string& fieldName1, const std::string& fieldName2) {
1096  if (myLineParser.know(fieldName1)) {
1097  return getNamedEdge(fieldName1);
1098  } else {
1099  return getNamedEdge(fieldName2);
1100  }
1101 }
1102 
1103 
1104 
1105 NBEdge*
1107  std::string sid;
1108  if (edge->getID()[0] == '-') {
1109  sid = edge->getID().substr(1);
1110  } else {
1111  sid = "-" + edge->getID();
1112  }
1113  if (sid.find('_') != std::string::npos) {
1114  sid = sid.substr(0, sid.find('_'));
1115  }
1117 }
1118 
1119 
1120 NBEdge*
1122  if (begin == 0) {
1123  return 0;
1124  }
1125  NBEdge* ret = begin;
1126  std::string edgeID = ret->getID();
1127  // hangle forward
1128  while (ret != 0) {
1129  // ok, this is the edge we are looking for
1130  if (ret->getToNode() == node) {
1131  return ret;
1132  }
1133  const EdgeVector& nedges = ret->getToNode()->getOutgoingEdges();
1134  if (nedges.size() != 1) {
1135  // too many edges follow
1136  ret = 0;
1137  continue;
1138  }
1139  NBEdge* next = nedges[0];
1140  if (ret->getID().substr(0, edgeID.length()) != next->getID().substr(0, edgeID.length())) {
1141  // ok, another edge is next...
1142  ret = 0;
1143  continue;
1144  }
1145  if (next->getID().substr(next->getID().length() - node->getID().length()) != node->getID()) {
1146  ret = 0;
1147  continue;
1148  }
1149  ret = next;
1150  }
1151 
1152  ret = begin;
1153  // hangle backward
1154  while (ret != 0) {
1155  // ok, this is the edge we are looking for
1156  if (ret->getFromNode() == node) {
1157  return ret;
1158  }
1159  const EdgeVector& nedges = ret->getFromNode()->getIncomingEdges();
1160  if (nedges.size() != 1) {
1161  // too many edges follow
1162  ret = 0;
1163  continue;
1164  }
1165  NBEdge* next = nedges[0];
1166  if (ret->getID().substr(0, edgeID.length()) != next->getID().substr(0, edgeID.length())) {
1167  // ok, another edge is next...
1168  ret = 0;
1169  continue;
1170  }
1171  if (next->getID().substr(next->getID().length() - node->getID().length()) != node->getID()) {
1172  ret = 0;
1173  continue;
1174  }
1175  ret = next;
1176  }
1177  return 0;
1178 }
1179 
1180 
1181 NBEdge*
1182 NIImporter_VISUM::getNamedEdgeContinuating(const std::string& fieldName, NBNode* node) {
1183  std::string edgeS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1184  NBEdge* edge = myNetBuilder.getEdgeCont().retrieve(edgeS);
1185  if (edge == 0) {
1186  WRITE_ERROR("The edge '" + edgeS + "' is not known.");
1187  }
1188  return getNamedEdgeContinuating(edge, node);
1189 }
1190 
1191 
1192 NBEdge*
1193 NIImporter_VISUM::getNamedEdgeContinuating(const std::string& fieldName1, const std::string& fieldName2,
1194  NBNode* node) {
1195  if (myLineParser.know(fieldName1)) {
1196  return getNamedEdgeContinuating(fieldName1, node);
1197  } else {
1198  return getNamedEdgeContinuating(fieldName2, node);
1199  }
1200 }
1201 
1202 
1203 NBEdge*
1205  EdgeVector::const_iterator i;
1206  for (i = FromNode->getOutgoingEdges().begin(); i != FromNode->getOutgoingEdges().end(); i++) {
1207  if (ToNode == (*i)->getToNode()) {
1208  return (*i);
1209  }
1210  }
1212  return 0;
1213 }
1214 
1215 
1216 SUMOReal
1217 NIImporter_VISUM::getNamedFloat(const std::string& fieldName) {
1218  std::string valS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1219  return TplConvert::_2SUMOReal(valS.c_str());
1220 }
1221 
1222 
1223 SUMOReal
1224 NIImporter_VISUM::getNamedFloat(const std::string& fieldName, SUMOReal defaultValue) {
1225  try {
1226  std::string valS = NBHelpers::normalIDRepresentation(myLineParser.get(fieldName));
1227  return TplConvert::_2SUMOReal(valS.c_str());
1228  } catch (...) {
1229  return defaultValue;
1230  }
1231 }
1232 
1233 
1234 SUMOReal
1235 NIImporter_VISUM::getNamedFloat(const std::string& fieldName1, const std::string& fieldName2) {
1236  if (myLineParser.know(fieldName1)) {
1237  return getNamedFloat(fieldName1);
1238  } else {
1239  return getNamedFloat(fieldName2);
1240  }
1241 }
1242 
1243 
1244 SUMOReal
1245 NIImporter_VISUM::getNamedFloat(const std::string& fieldName1, const std::string& fieldName2,
1246  SUMOReal defaultValue) {
1247  if (myLineParser.know(fieldName1)) {
1248  return getNamedFloat(fieldName1, defaultValue);
1249  } else {
1250  return getNamedFloat(fieldName2, defaultValue);
1251  }
1252 }
1253 
1254 
1255 std::string
1256 NIImporter_VISUM::getNamedString(const std::string& fieldName) {
1258 }
1259 
1260 
1261 std::string
1262 NIImporter_VISUM::getNamedString(const std::string& fieldName1,
1263  const std::string& fieldName2) {
1264  if (myLineParser.know(fieldName1)) {
1265  return getNamedString(fieldName1);
1266  } else {
1267  return getNamedString(fieldName2);
1268  }
1269 }
1270 
1271 
1272 
1273 
1274 
1275 
1276 NBNode*
1277 NIImporter_VISUM::buildDistrictNode(const std::string& id, NBNode* dest,
1278  bool isSource) {
1279  // get the district
1281  if (dist == 0) {
1282  return 0;
1283  }
1284  // build the id
1285  std::string nid;
1286  nid = id + "-" + dest->getID();
1287  if (!isSource) {
1288  nid = "-" + nid;
1289  }
1290  // insert the node
1291  if (!myNetBuilder.getNodeCont().insert(nid, dist->getPosition())) {
1292  WRITE_ERROR("Could not build connector node '" + nid + "'.");
1293  }
1294  // return the node
1295  return myNetBuilder.getNodeCont().retrieve(nid);
1296 }
1297 
1298 
1299 bool
1301  if (from == 0) {
1302  WRITE_ERROR(" The from-node was not found within the net");
1303  }
1304  if (to == 0) {
1305  WRITE_ERROR(" The to-node was not found within the net");
1306  }
1307  if (from == to) {
1308  WRITE_ERROR(" Both nodes are the same");
1309  }
1310  return from != 0 && to != 0 && from != to;
1311 }
1312 
1313 
1314 /****************************************************************************/
1315 
std::map< std::string, Phase * > & phases()
Returns the phases map.
Definition: NIVisumTL.h:124
const EdgeVector & getIncomingEdges() const
Returns this node&#39;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:203
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&#39;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:70
void parse_PartOfArea()
Parses FLAECHENELEMENT.
bool hasOutgoing(const NBEdge *const e) const
Returns whether the given edge starts at this node.
Definition: NBNode.cpp:1207
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:94
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:205
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
Definition: NBNode.cpp:1201
SUMOReal getNamedFloat(const std::string &fieldName)
Returns the value from the named column as a float.
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, bool keepClear=true, SUMOReal contPos=UNSPECIFIED_CONTPOS)
Adds a connection between the specified this edge&#39;s lane and an approached one.
Definition: NBEdge.cpp:697
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:115
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&#39;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:673
void incLaneNo(int by)
Definition: NBEdge.cpp:2392
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:183
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:177
NBEdgeCont & getEdgeCont()
Returns the edge container.
Definition: NBNetBuilder.h:153
A list of positions.
void setAsMacroscopicConnector()
Marks this edge as a macroscopic connector.
Definition: NBEdge.h:876
int getPriority(const std::string &type) const
Returns the priority for the given type.
Definition: NBTypeCont.cpp:189
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:347
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.
void(NIImporter_VISUM::* ParsingFunction)()
Definition of a function for parsing a single line from a certain db.
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:1722
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:63
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: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: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:546
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&#39;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:213
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:566
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:560
#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:424
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