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