50 if (!oc.
isSet(
"visum-file")) {
56 oc.
getBool(
"visum.use-type-priority"));
66 const std::string& file,
123 for (NIVisumTL_Map::iterator j =
myTLS.begin(); j !=
myTLS.end(); j++) {
148 if (line.length() > 0 && line[0] ==
'$') {
149 ParserVector::iterator i;
151 std::string dataName =
"$" + (*i).name +
":";
152 if (line.substr(0, dataName.length()) == dataName) {
154 (*i).pattern = line.substr(dataName.length());
162 if ((*i).position < 0) {
174 bool singleDataEndFound =
false;
177 if (line.length() == 0 || line[0] ==
'*' || line[0] ==
'$') {
178 singleDataEndFound =
true;
183 (this->*(*i).function)();
185 WRITE_ERROR(
"Too short value line in " + (*i).name +
" occurred.");
189 WRITE_ERROR(
"One of the needed values ('" + std::string(e.what()) +
"') is missing in " + (*i).name +
".");
197 for (NIVisumTL_Map::iterator j =
myTLS.begin(); j !=
myTLS.end(); j++) {
202 (*k).first->addShape((*k).second);
227 }
else if (speed < 0) {
330 if (speedS.find(
"km/h") != std::string::npos) {
331 speedS = speedS.substr(0, speedS.find(
"km/h"));
363 bool oneway_checked = oneway;
365 if (previous !=
nullptr) {
368 oneway_checked =
false;
371 oneway_checked =
false;
376 if (previous !=
nullptr) {
379 oneway_checked =
false;
384 if (nolanes != 0 && speed != 0) {
402 if (nolanes != 0 && speed != 0) {
422 myEdges[id] = std::make_pair(from, to);
447 if (dest ==
nullptr) {
466 std::string
id = bez +
"-" + dest->getID();
469 if (dir.length() == 0) {
473 if (dir.find(
'Q') != std::string::npos) {
474 const EdgeVector& edges = dest->getOutgoingEdges();
475 bool hasContinuation =
false;
476 for (EdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
477 if (!(*i)->isMacroscopicConnector()) {
478 hasContinuation =
true;
481 if (!hasContinuation) {
483 WRITE_WARNING(
"Incoming connector '" +
id +
"' will not be build - would be not connected to network.");
486 if (src ==
nullptr) {
487 WRITE_ERROR(
"The district '" + bez +
"' could not be built.");
490 NBEdge* edge =
new NBEdge(
id, src, dest,
"VisumConnector",
497 WRITE_ERROR(
"A duplicate edge id occurred (ID='" +
id +
"').");
501 if (edge !=
nullptr) {
507 if (dir.find(
'Z') != std::string::npos) {
508 const EdgeVector& edges = dest->getIncomingEdges();
509 bool hasPredeccessor =
false;
510 for (EdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
511 if (!(*i)->isMacroscopicConnector()) {
512 hasPredeccessor =
true;
515 if (!hasPredeccessor) {
517 WRITE_WARNING(
"Outgoing connector '" +
id +
"' will not be build - would be not connected to network.");
520 if (src ==
nullptr) {
521 WRITE_ERROR(
"The district '" + bez +
"' could not be built.");
525 NBEdge* edge =
new NBEdge(
id, dest, src,
"VisumConnector",
532 WRITE_ERROR(
"A duplicate edge id occurred (ID='" +
id +
"').");
536 if (edge !=
nullptr) {
554 if (from ==
nullptr || via ==
nullptr || to ==
nullptr) {
566 if (src ==
nullptr) {
572 if (dest ==
nullptr) {
601 WRITE_ERROR(
"Error in geometry description from node '" + from->
getID() +
"' to node '" + to->
getID() +
"'.");
606 WRITE_ERROR(
"Unable to project coordinates for node '" + from->
getID() +
"'.");
637 if (baseEdge ==
nullptr) {
643 if (node ==
nullptr) {
649 if (edge ==
nullptr) {
660 WRITE_ERROR(
"A lane number for edge '" + edge->
getID() +
"' is not numeric (" + laneS +
").");
665 WRITE_ERROR(
"A lane number for edge '" + edge->
getID() +
"' is not positive (" + laneS +
").");
684 WRITE_ERROR(
"A lane length for edge '" + edge->
getID() +
"' is not numeric (" + lengthS +
").");
688 WRITE_ERROR(
"A lane length for edge '" + edge->
getID() +
"' is not positive (" + lengthS +
").");
718 bool mustRecheck =
true;
719 double seenLength = 0;
720 while (mustRecheck) {
723 std::string sub = edge->
getID();
724 sub = sub.substr(sub.rfind(
'_', sub.rfind(
'_') - 1));
725 sub = sub.substr(1, sub.find(
'_', 1) - 1);
746 double useLength = length - seenLength;
747 useLength = edge->
getLength() - useLength;
748 if (useLength < 0 || useLength > edge->
getLength()) {
752 std::string edgeID = edge->
getID();
755 edgeID = edgeID.substr(0, edgeID.find(
'_'));
761 std::string nid = edgeID +
"_" +
toString((
int) length) +
"_" + node->
getID();
799 auto tlIt =
myTLS.find(trafficLight);
800 if (n !=
nullptr && tlIt !=
myTLS.end()) {
801 tlIt->second->addNode(n);
803 WRITE_ERROR(
"Could not assign" + std::string(n ==
nullptr ?
" missing" :
"") +
" node '" + node
804 +
"' to" + std::string(tlIt ==
myTLS.end() ?
" missing" :
"") +
" traffic light '" + trafficLight +
"'");
818 WRITE_ERROR(
"Could not find TLS '" + LSAid +
"' for setting the signal group.");
831 WRITE_WARNING(
"Ignoring SIGNALGRUPPEZUFSABBIEGER because LsaNr is not known");
844 if (from ==
nullptr && to ==
nullptr) {
853 if (edg1 !=
nullptr && edg2 !=
nullptr) {
856 if (edg1->
getID()[0] ==
'-') {
857 sid = edg1->
getID().substr(1);
859 sid =
"-" + edg1->
getID();
861 if (sid.find(
'_') != std::string::npos) {
862 sid = sid.substr(0, sid.find(
'_'));
868 if (edg2->
getID()[0] ==
'-') {
869 sid = edg2->
getID().substr(1);
871 sid =
"-" + edg2->
getID();
873 if (sid.find(
'_') != std::string::npos) {
874 sid = sid.substr(0, sid.find(
'_'));
888 WRITE_ERROR(
"Unknown edge in TEILFLAECHENELEMENT");
904 if (dir.length() > 0 && dir[0] ==
'1') {
912 const std::vector<long long int>& areas =
mySubPartsAreas.find(
id)->second;
913 for (std::vector<long long int>::const_iterator i = areas.begin(); i != areas.end(); ++i) {
921 if (dir.length() > 0 && dir[0] ==
'1') {
953 SG.
phases()[Phaseid] = PH;
959 NBEdge* fromEdge =
nullptr;
966 if (fromEdge ==
nullptr) {
970 WRITE_WARNING(
"Ignoring lane-to-lane connection (not yet implemented for this format version)");
974 if (node ==
nullptr) {
980 if (fromEdge ==
nullptr || toEdge ==
nullptr) {
984 int fromLaneOffset = 0;
994 int toLaneOffset = 0;
1008 WRITE_ERROR(
"A from-lane number for edge '" + fromEdge->
getID() +
"' is not numeric (" + fromLaneS +
").");
1013 WRITE_ERROR(
"A from-lane number for edge '" + fromEdge->
getID() +
"' is not positive (" + fromLaneS +
").");
1022 WRITE_ERROR(
"A to-lane number for edge '" + toEdge->
getID() +
"' is not numeric (" + toLaneS +
").");
1027 WRITE_ERROR(
"A to-lane number for edge '" + toEdge->
getID() +
"' is not positive (" + toLaneS +
").");
1031 if (fromLane - fromLaneOffset < 0) {
1034 fromLane = (int)fromEdge->
getNumLanes() - (fromLane - fromLaneOffset) - 1;
1036 if (toLane - toLaneOffset < 0) {
1039 toLane = (int)toEdge->
getNumLanes() - (toLane - toLaneOffset) - 1;
1043 WRITE_ERROR(
"A from-lane number for edge '" + fromEdge->
getID() +
"' is larger than the edge's lane number (" + fromLaneS +
").");
1047 WRITE_ERROR(
"A to-lane number for edge '" + toEdge->
getID() +
"' is larger than the edge's lane number (" + toLaneS +
").");
1070 if (val.find(suffix) != std::string::npos) {
1071 val = val.substr(0, val.find(suffix));
1105 std::transform(v.begin(), v.end(), v.begin(), tolower);
1108 }
else if (v ==
"walk" || v ==
"w" || v ==
"f") {
1110 }
else if (v ==
"l" || v ==
"lkw" || v ==
"h" || v ==
"hgv" || v ==
"lw" || v ==
"truck" || v ==
"tru") {
1112 }
else if (v ==
"b" || v ==
"bike") {
1114 }
else if (v ==
"train") {
1116 }
else if (v ==
"tram") {
1118 }
else if (v ==
"p" || v ==
"pkw" || v ==
"car" || v ==
"c") {
1134 if (node ==
nullptr) {
1135 WRITE_ERROR(
"The node '" + nodeS +
"' is not known.");
1144 if (node ==
nullptr) {
1165 if (edge ==
nullptr) {
1166 WRITE_ERROR(
"The edge '" + edgeS +
"' is not known.");
1186 if (edge->
getID()[0] ==
'-') {
1187 sid = edge->
getID().substr(1);
1189 sid =
"-" + edge->
getID();
1191 if (sid.find(
'_') != std::string::npos) {
1192 sid = sid.substr(0, sid.find(
'_'));
1200 if (begin ==
nullptr) {
1204 std::string edgeID = ret->
getID();
1206 while (ret !=
nullptr) {
1212 if (nedges.size() != 1) {
1217 NBEdge* next = nedges[0];
1218 if (ret->
getID().substr(0, edgeID.length()) != next->
getID().substr(0, edgeID.length())) {
1232 while (ret !=
nullptr) {
1238 if (nedges.size() != 1) {
1243 NBEdge* next = nedges[0];
1244 if (ret->
getID().substr(0, edgeID.length()) != next->
getID().substr(0, edgeID.length())) {
1263 if (edge ==
nullptr) {
1264 WRITE_ERROR(
"The edge '" + edgeS +
"' is not known.");
1283 EdgeVector::const_iterator i;
1285 if (ToNode == (*i)->getToNode()) {
1298 value = value.substr(0, value.length() - 4);
1309 return defaultValue;
1326 double defaultValue) {
1343 const std::string& fieldName2) {
1361 if (dist ==
nullptr) {
1366 nid =
id +
"-" + dest->
getID();
1372 WRITE_ERROR(
"Could not build connector node '" + nid +
"'.");
1381 if (from ==
nullptr) {
1382 WRITE_ERROR(
" The from-node was not found within the net");
1384 if (to ==
nullptr) {
1385 WRITE_ERROR(
" The to-node was not found within the net");
1390 return from !=
nullptr && to !=
nullptr && from != to;
1395 return (edge->
getID().length() > node->
getID().length() + 1
1396 && (edge->
getID().substr(edge->
getID().length() - node->
getID().length() - 1) ==
"_" + node->
getID()));
std::map< std::string, Phase * > & phases()
Returns the phases map.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
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.
double getLength() const
Returns the computed length of the edge.
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.
void parse_NodesToTrafficLights()
Parses KNOTENZULSA/SIGNALANLAGEZUKNOTEN.
double getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
A signal group can be defined either by a time period or by phases.
NBTypeCont & getTypeCont()
Returns a reference to the type container.
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...
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.
static bool isSplitEdge(NBEdge *edge, NBNode *node)
whether the edge id ends with _nodeID
std::string myCurrentID
The name of the currently parsed item used for error reporting.
void parse_Turns()
Parses ABBIEGEBEZIEHUNG/ABBIEGER.
vehicle is a not electrified rail
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.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
The representation of a single edge during network building.
void parse_PartOfArea()
Parses FLAECHENELEMENT.
int getPriority(const std::string &type) const
Returns the priority for the given type.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
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.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given ...
void parse_EdgePolys()
Parses STRECKENPOLY.
bool markAsSet(const std::string &id, const SumoXMLAttr attr)
Marks an attribute of a type as set.
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
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.
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.
std::string myFileName
The name of the parsed file, for error reporting.
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
NBEdge * getReversedContinuating(NBEdge *edge, NBNode *node)
Returns the opposite direction of the given edge.
#define WRITE_WARNING(msg)
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.
static OptionsCont & getOptions()
Retrieves the options.
A VISUM network importer.
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter ...
vehicle is a large transport vehicle
void parse_TurnsToSignalGroups()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
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, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED)
Adds a connection between the specified this edge's lane and an approached one.
A class representing a single district.
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
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.
void incLaneNo(int by)
increment lane
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
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.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
int getNumLanes() const
Returns the number of lanes.
A point in 2D or 3D with translation and scaling methods.
NBEdgeCont & getEdgeCont()
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void setAsMacroscopicConnector()
double getWeightedFloat2(const std::string &name, const std::string &name2, const std::string &suffix)
as above but with two alternative names
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)
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_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.
ParserVector mySingleDataParsers
List of known parsers.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter...
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.
vehicle is a passenger car (a "normal" car)
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
SVCPermissions getPermissions(const std::string &name, bool warn=false, SVCPermissions unknown=SVCAll)
parse permissions
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.
void parse_Lanes()
Parses FAHRSTREIFEN.
~NIImporter_VISUM()
destructor
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
NBNodeCont & getNodeCont()
Returns a reference to the node container.
bool hasMore() const
Returns whether another line may be read (the file was not read completely)
Instance responsible for building networks.
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter, which
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.
std::map< long long int, NBDistrict * > myShapeDistrictMap
A map from district shape definition name to the district.
A storage for options typed value containers)
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
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.
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
Intermediate class for storing visum traffic lights during their import.
NBConnectionVector & connections()
Returns the connections vector.
void reinit()
Reinitialises the reading (of the previous file)
Represents a single node (junction) during network building.
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.
void parse_Edges()
Parses STRECKE/STRECKEN.
NBNetBuilder & myNetBuilder
The network builder to fill with loaded values.
void addGeometryPoint(int index, const Position &p)
Adds a further geometry point.
NBNode * getFromNode() const
Returns the origin node of the edge.
#define PROGRESS_DONE_MESSAGE()
ParsingFunction function
Pointer to the function used for parsing.
const Position & getPosition() const
Returns the position of this district's center.
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
#define WRITE_MESSAGE(msg)
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.
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.
SVCPermissions getPermissions(const std::string &type) const
Returns allowed vehicle classes for the given type.
void parse_LanesConnections()
Parses FAHRSTREIFENABBIEGER.
NBNode * getNamedNodeSecure(const std::string &fieldName, NBNode *fallback=0)