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