Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NIImporter_VISUM.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
19// A VISUM network importer
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
24#include <string>
25#include <map>
26#include <vector>
31#include "NIVisumTL.h"
32
33
34// ===========================================================================
35// class declaration
36// ===========================================================================
37class OptionsCont;
38class NBNetBuilder;
39class NBNodeCont;
40class NBEdgeCont;
41class NBNode;
42class NBEdge;
43
44
45// ===========================================================================
46// class declaration
47// ===========================================================================
67public:
79 static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
80
81
82protected:
93 NIImporter_VISUM(NBNetBuilder& nb, const std::string& file,
94 NBCapacity2Lanes capacity2Lanes, bool useVisumPrio,
95 const std::string& languageFile);
96
97
100
101
112 void load();
113
114private:
123 double getNamedFloat(const std::string& fieldName);
124
134 double getNamedFloat(const std::string& fieldName1, const std::string& fieldName2);
135
136
143 double getNamedFloat(const std::string& fieldName, double defaultValue);
144
152 double getNamedFloat(const std::string& fieldName1, const std::string& fieldName2,
153 double defaultValue);
154
155
166 std::string getNamedString(const std::string& fieldName);
167
177 std::string getNamedString(const std::string& fieldName1, const std::string& fieldName2);
178
179
189 double getWeightedFloat(const std::string& name, const std::string& suffix);
190
192 double getWeightedFloat2(const std::string& name, const std::string& name2, const std::string& suffix);
193
195 SVCPermissions getPermissions(const std::string& name, const std::string& edgeType, SVCPermissions unknown);
196
206 bool getWeightedBool(const std::string& name);
207
208
221 NBNode* getNamedNode(const std::string& fieldName);
222 NBNode* getNamedNodeSecure(const std::string& fieldName, NBNode* fallback = 0);
223
233 NBNode* getNamedNode(const std::string& fieldName1, const std::string& fieldName2);
234
235
248 NBEdge* getNamedEdge(const std::string& fieldName);
249
259 NBEdge* getNamedEdge(const std::string& fieldName1, const std::string& fieldName2);
260
261
276 NBEdge* getNamedEdgeContinuating(const std::string& fieldName, NBNode* node);
277
288 NBEdge* getNamedEdgeContinuating(const std::string& fieldName1, const std::string& fieldName2,
289 NBNode* node);
290
298
299
306 NBEdge* getEdge(NBNode* FromNode, NBNode* ToNode);
307
308
320
321
334 NBNode* buildDistrictNode(const std::string& id, NBNode* dest, bool isSource);
335
336
345 bool checkNodes(NBNode* from, NBNode* to);
346
347
348private:
356
361 struct TypeParser {
365 std::string name;
366
371
377
381 std::string pattern;
382
383 };
384
385
387 void parse_Network();
388
390 void parse_VSysTypes();
391
393 void parse_Types();
394
396 void parse_Nodes();
397
399 void parse_Districts();
400
402 void parse_Point();
403
404
406 void parse_Edges();
407
409 void parse_PartOfArea();
410
412 void parse_Kante();
413
414
416 void parse_Connectors();
418
420 void parse_Turns();
421
423 void parse_EdgePolys();
424
426 void parse_Lanes();
427
429 void parse_TrafficLights();
430
433
435 void parse_SignalGroups();
436
439
442
444 void parse_Phases();
445
448
451
453 void parse_stopPoints();
454
460 void addParser(const std::string& name, ParsingFunction function);
461
462private:
463
465 static bool isSplitEdge(NBEdge* edge, NBNode* node);
466
467
468private:
471
473 std::string myFileName;
474
477
482
485
487 struct VSysType {
488 VSysType(const std::string& _type, const std::string& _name) : type(_type), name(_name) {}
489 const std::string type;
490 const std::string name;
491 };
492 typedef std::map<std::string, VSysType> VSysTypeNames;
495
497 typedef std::vector<TypeParser> ParserVector;
500
502 typedef std::map<std::string, NIVisumTL*> NIVisumTL_Map;
505
507 std::vector<std::string > myTouchedEdges;
508
511
513 std::string myCurrentID;
514
515
517 std::map<long long int, Position> myPoints;
518
520 std::map<long long int, std::pair<long long int, long long int> > myEdges;
521
523 std::map<long long int, NBDistrict*> myShapeDistrictMap;
524
526 std::map<long long int, std::vector<long long int> > mySubPartsAreas;
527
529 std::map<NBDistrict*, PositionVector> myDistrictShapes;
530
532
533protected:
589
592
595
596 void loadLanguage(const std::string& file);
597};
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Retrieves a file linewise and reports the lines to a handler.
Definition LineReader.h:48
A helper class which computes the lane number from given capacity.
Storage for edges, including some functionality operating on multiple edges.
Definition NBEdgeCont.h:59
The representation of a single edge during network building.
Definition NBEdge.h:92
Instance responsible for building networks.
Container for nodes during the netbuilding process.
Definition NBNodeCont.h:57
Represents a single node (junction) during network building.
Definition NBNode.h:66
void load()
Parses the VISUM-network file storing the parsed structures within myNetBuilder.
void parse_Phases()
Parses LSAPHASE/PHASE.
NBCapacity2Lanes myCapacity2Lanes
The converter to compute the lane number of edges from their capacity.
static StringBijection< VISUM_KEY > KEYS
link directions
NBNetBuilder & myNetBuilder
The network builder to fill with loaded values.
SVCPermissions myDefaultPermissions
void parse_Edges()
Parses STRECKE/STRECKEN.
double getWeightedFloat2(const std::string &name, const std::string &name2, const std::string &suffix)
as above but with two alternative names
~NIImporter_VISUM()
destructor
std::vector< std::string > myTouchedEdges
Already read edges.
void(NIImporter_VISUM::* ParsingFunction)()
Definition of a function for parsing a single line from a certain db.
NBEdge * getNamedEdge(const std::string &fieldName)
Tries to get the edge which name is stored in the given field.
double getWeightedFloat(const std::string &name, const std::string &suffix)
tries to get a double which is possibly assigned to a certain modality
void parse_VSysTypes()
Parses VSYS.
void parse_NodesToTrafficLights()
Parses KNOTENZULSA/SIGNALANLAGEZUKNOTEN.
void parse_PartOfArea()
Parses FLAECHENELEMENT.
void parse_Network()
Parses meta data (i.e. projection).
void parse_TrafficLights()
Parses LSA/SIGNALANLAGE.
NBNode * getNamedNodeSecure(const std::string &fieldName, NBNode *fallback=0)
void parse_Point()
Parses PUNKT.
void parse_Districts()
Parses BEZIRK.
VSysTypeNames myVSysTypes
The used vsystypes.
std::string myCurrentID
The name of the currently parsed item used for error reporting.
std::map< std::string, VSysType > VSysTypeNames
bool getWeightedBool(const std::string &name)
tries to get a bool which is possibly assigned to a certain modality
void parse_stopPoints()
Parses HALTEPUNKT (public transport stop locations).
std::map< NBDistrict *, PositionVector > myDistrictShapes
A temporary storage for district shapes as they are filled incrementally.
std::string myFileName
The name of the parsed file, for error reporting.
std::map< long long int, Position > myPoints
A map of point ids to positions.
void addParser(const std::string &name, ParsingFunction function)
Adds a parser into the sorted list of parsers to use.
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder.
NIImporter_VISUM(NBNetBuilder &nb, const std::string &file, NBCapacity2Lanes capacity2Lanes, bool useVisumPrio, const std::string &languageFile)
constructor
static StringBijection< VISUM_KEY >::Entry KEYS_DE[]
Strings for the keywords.
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.
void parse_EdgePolys()
Parses STRECKENPOLY.
LineReader myLineReader
The line reader to use to read from the file.
bool myUseVisumPrio
Information whether VISUM priority information shall be used.
SVCPermissions getPermissions(const std::string &name, const std::string &edgeType, SVCPermissions unknown)
parse permissions
void loadLanguage(const std::string &file)
bool checkNodes(NBNode *from, NBNode *to)
Returns whether both nodes are a valid combination of from/to-nodes.
std::map< std::string, NIVisumTL * > NIVisumTL_Map
Definition of a map for loaded traffic lights (id->tls).
NBEdge * getReversedContinuating(NBEdge *edge, NBNode *node)
Returns the opposite direction of the given edge.
ParserVector mySingleDataParsers
List of known parsers.
void parse_SignalGroupsToPhases()
Parses LSASIGNALGRUPPEZULSAPHASE.
NBNode * getNamedNode(const std::string &fieldName)
Tries to get the node which name is stored in the given field.
void parse_Kante()
Parses FLAECHENELEMENT.
void parse_SignalGroups()
Parses LSASIGNALGRUPPE/SIGNALGRUPPE.
NBNode * buildDistrictNode(const std::string &id, NBNode *dest, bool isSource)
Builds a node for the given district and returns it.
void parse_Lanes()
Parses FAHRSTREIFEN.
NBEdge * getEdge(NBNode *FromNode, NBNode *ToNode)
Returns the edge that connects both nodes.
NamedColumnsParser myLineParser
the parser to parse the information from the data lines
double getNamedFloat(const std::string &fieldName)
Returns the value from the named column as a float.
std::map< long long int, NBDistrict * > myShapeDistrictMap
A map from district shape definition name to the district.
void parse_Turns()
Parses ABBIEGEBEZIEHUNG/ABBIEGER.
void parse_Nodes()
Parses KNOTEN.
void parse_TurnsToSignalGroups()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
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...
std::string getNamedString(const std::string &fieldName)
Returns the value from the named column as a normalised string.
void parse_LanesConnections()
Parses FAHRSTREIFENABBIEGER.
static bool isSplitEdge(NBEdge *edge, NBNode *node)
whether the edge id ends with _nodeID
void parse_Types()
Parses STRECKENTYP.
void parse_Connectors()
Parses ANBINDUNG.
void parse_AreaSubPartElement()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
std::map< long long int, std::vector< long long int > > mySubPartsAreas
A map from area parts to area ids.
std::vector< TypeParser > ParserVector
Definition of the list of known parsers.
NIVisumTL_Map myTLS
List of visum traffic lights.
A parser to retrieve information from a table with known columns.
A storage for options typed value containers).
Definition OptionsCont.h:89
A complete call description for parsing a single db.
ParsingFunction function
Pointer to the function used for parsing.
std::string name
The name of the db.
long position
Position of the according db within the file.
std::string pattern
The column names.
VSysType(const std::string &_type, const std::string &_name)
bijection entry