46 #ifdef CHECK_MEMORY_LEAKS
48 #endif // CHECK_MEMORY_LEAKS
60 if (!oc.
isSet(
"visum-file")) {
66 oc.
getBool(
"visum.use-type-priority"));
76 const std::string& file,
79 : myNetBuilder(nb), myFileName(file),
80 myCapacity2Lanes(capacity2Lanes), myUseVisumPrio(useVisumPrio) {
133 for (NIVisumTL_Map::iterator j =
myTLS.begin(); j !=
myTLS.end(); j++) {
158 if (line.length() > 0 && line[0] ==
'$') {
159 ParserVector::iterator i;
161 std::string dataName =
"$" + (*i).name +
":";
162 if (line.substr(0, dataName.length()) == dataName) {
164 (*i).pattern = line.substr(dataName.length());
172 if ((*i).position < 0) {
184 bool singleDataEndFound =
false;
187 if (line.length() == 0 || line[0] ==
'*' || line[0] ==
'$') {
188 singleDataEndFound =
true;
193 (this->*(*i).function)();
195 WRITE_ERROR(
"Too short value line in " + (*i).name +
" occured.");
199 WRITE_ERROR(
"One of the needed values ('" + std::string(e.what()) +
"') is missing in " + (*i).name +
".");
207 for (NIVisumTL_Map::iterator j =
myTLS.begin(); j !=
myTLS.end(); j++) {
212 (*k).first->addShape((*k).second);
328 if (speedS.find(
"km/h") != std::string::npos) {
329 speedS = speedS.substr(0, speedS.find(
"km/h"));
362 bool oneway_checked = oneway;
367 oneway_checked =
false;
370 oneway_checked =
false;
378 oneway_checked =
false;
382 if (nolanes != 0 && speed != 0) {
399 if (nolanes != 0 && speed != 0) {
418 myEdges[id] = std::make_pair(from, to);
464 std::string
id = bez +
"-" + dest->getID();
467 if (dir.length() == 0) {
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;
479 if (!hasContinuation) {
481 WRITE_WARNING(
"Incoming connector '" +
id +
"' will not be build - would be not connected to network.");
485 WRITE_ERROR(
"The district '" + bez +
"' could not be built.");
488 NBEdge* edge =
new NBEdge(
id, src, dest,
"VisumConnector",
495 WRITE_ERROR(
"A duplicate edge id occured (ID='" +
id +
"').");
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;
513 if (!hasPredeccessor) {
515 WRITE_WARNING(
"Outgoing connector '" +
id +
"' will not be build - would be not connected to network.");
519 WRITE_ERROR(
"The district '" + bez +
"' could not be built.");
523 NBEdge* edge =
new NBEdge(
id, dest, src,
"VisumConnector",
530 WRITE_ERROR(
"A duplicate edge id occured (ID='" +
id +
"').");
552 if (from == 0 || via == 0 || to == 0) {
612 WRITE_ERROR(
"Error in geometry description from node '" + from->
getID() +
"' to node '" + to->
getID() +
"'.");
617 WRITE_ERROR(
"Unable to project coordinates for node '" + from->
getID() +
"'.");
655 if (node == 0 || edge == 0) {
666 WRITE_ERROR(
"A lane number for edge '" + edge->
getID() +
"' is not numeric (" + laneS +
").");
671 WRITE_ERROR(
"A lane number for edge '" + edge->
getID() +
"' is not positive (" + laneS +
").");
687 WRITE_ERROR(
"A lane length for edge '" + edge->
getID() +
"' is not numeric (" + lengthS +
").");
691 WRITE_ERROR(
"A lane length for edge '" + edge->
getID() +
"' is not positive (" + lengthS +
").");
708 if (edge->
getID().substr(edge->
getID().length() - node->
getID().length() - 1) ==
"_" + node->
getID()) {
721 bool mustRecheck =
true;
723 while (mustRecheck) {
724 if (edge->
getID().substr(edge->
getID().length() - node->
getID().length() - 1) ==
"_" + node->
getID()) {
726 std::string sub = edge->
getID();
727 sub = sub.substr(sub.rfind(
'_', sub.rfind(
'_') - 1));
728 sub = sub.substr(1, sub.find(
'_', 1) - 1);
749 SUMOReal useLength = length - seenLength;
750 useLength = edge->
getLength() - useLength;
751 std::string edgeID = edge->
getID();
753 if (edgeID.substr(edgeID.length() - node->
getID().length() - 1) ==
"_" + node->
getID()) {
754 edgeID = edgeID.substr(0, edgeID.find(
'_'));
760 std::string nid = edgeID +
"_" +
toString((
size_t) length) +
"_" + node->
getID();
765 while (nedge->
getID().substr(nedge->
getID().length() - node->
getID().length() - 1) ==
"_" + node->
getID()) {
806 WRITE_ERROR(
"Could not find TLS '" + LSAid +
"' for setting the signal group.");
827 if (from == 0 && to == 0) {
836 if (edg1 != 0 && edg2 != 0) {
839 if (edg1->
getID()[0] ==
'-') {
840 sid = edg1->
getID().substr(1);
842 sid =
"-" + edg1->
getID();
844 if (sid.find(
'_') != std::string::npos) {
845 sid = sid.substr(0, sid.find(
'_'));
851 if (edg2->
getID()[0] ==
'-') {
852 sid = edg2->
getID().substr(1);
854 sid =
"-" + edg2->
getID();
856 if (sid.find(
'_') != std::string::npos) {
857 sid = sid.substr(0, sid.find(
'_'));
871 WRITE_ERROR(
"Unknown edge in TEILFLAECHENELEMENT");
887 if (dir.length() > 0 && dir[0] ==
'1') {
896 for (std::vector<SUMOLong>::const_iterator i = areas.begin(); i != areas.end(); ++i) {
904 if (dir.length() > 0 && dir[0] ==
'1') {
936 SG.
phases()[Phaseid] = PH;
949 if (fromEdge == 0 || toEdge == 0) {
953 int fromLaneOffset = 0;
963 int toLaneOffset = 0;
977 WRITE_ERROR(
"A from-lane number for edge '" + fromEdge->
getID() +
"' is not numeric (" + fromLaneS +
").");
982 WRITE_ERROR(
"A from-lane number for edge '" + fromEdge->
getID() +
"' is not positive (" + fromLaneS +
").");
991 WRITE_ERROR(
"A to-lane number for edge '" + toEdge->
getID() +
"' is not numeric (" + toLaneS +
").");
996 WRITE_ERROR(
"A to-lane number for edge '" + toEdge->
getID() +
"' is not positive (" + toLaneS +
").");
1000 if (fromLane - fromLaneOffset < 0) {
1003 fromLane = fromEdge->
getNumLanes() - (fromLane - fromLaneOffset) - 1;
1005 if (toLane - toLaneOffset < 0) {
1008 toLane = toEdge->
getNumLanes() - (toLane - toLaneOffset) - 1;
1012 WRITE_ERROR(
"A from-lane number for edge '" + fromEdge->
getID() +
"' is larger than the edge's lane number (" + fromLaneS +
").");
1016 WRITE_ERROR(
"A to-lane number for edge '" + toEdge->
getID() +
"' is larger than the edge's lane number (" + toLaneS +
").");
1064 WRITE_ERROR(
"The node '" + nodeS +
"' is not known.");
1085 WRITE_ERROR(
"The edge '" + edgeS +
"' is not known.");
1105 if (edge->
getID()[0] ==
'-') {
1106 sid = edge->
getID().substr(1);
1108 sid =
"-" + edge->
getID();
1110 if (sid.find(
'_') != std::string::npos) {
1111 sid = sid.substr(0, sid.find(
'_'));
1123 std::string edgeID = ret->
getID();
1131 if (nedges.size() != 1) {
1136 NBEdge* next = nedges[0];
1137 if (ret->
getID().substr(0, edgeID.length()) != next->
getID().substr(0, edgeID.length())) {
1157 if (nedges.size() != 1) {
1162 NBEdge* next = nedges[0];
1163 if (ret->
getID().substr(0, edgeID.length()) != next->
getID().substr(0, edgeID.length())) {
1183 WRITE_ERROR(
"The edge '" + edgeS +
"' is not known.");
1202 EdgeVector::const_iterator i;
1204 if (ToNode == (*i)->getToNode()) {
1226 return defaultValue;
1260 const std::string& fieldName2) {
1283 nid =
id +
"-" + dest->
getID();
1289 WRITE_ERROR(
"Could not build connector node '" + nid +
"'.");
1299 WRITE_ERROR(
" The from-node was not found within the net");
1302 WRITE_ERROR(
" The to-node was not found within the net");
1307 return from != 0 && to != 0 && from != to;
std::map< std::string, Phase * > & phases()
Returns the phases map.
std::map< SUMOLong, Position > myPoints
A map of point ids to positions.
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges.
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.
A signal group can be defined either by a time period or by phases.
static const SUMOReal UNSPECIFIED_WIDTH
unspecified lane width
NBTypeCont & getTypeCont()
Returns 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.
std::map< NBDistrict *, PositionVector > myDistrictShapes
A temporary storage for district shapes as they are filled incrementally.
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
Position positionAtOffset(SUMOReal pos) const
Returns the position at the given length.
LineReader myLineReader
The line reader to use to read from the file.
std::vector< std::string > myTouchedEdges
Already read edges.
const Position & getPosition() const
Returns the position of this district's center.
NBEdge * getNamedEdgeContinuating(const std::string &fieldName, NBNode *node)
Tries to get the edge which name is stored in the given field continuating the search for a subedge t...
bool readLine(LineHandler &lh)
Reads a single (the next) line from the file and reports it to the given LineHandler.
static SUMOReal _2SUMOReal(const E *const data)
std::string myCurrentID
The name of the currently parsed item used for error reporting.
static bool _2bool(const E *const data)
void parse_Turns()
Parses ABBIEGEBEZIEHUNG/ABBIEGER.
VSysTypeNames myVSysTypes
The used vsystypes.
NBNode * getNamedNode(const std::string &fieldName)
Tries to get the node which name is stored in the given field.
void parse_TrafficLights()
Parses LSA/SIGNALANLAGE.
A helper class which computes the lane number from given capacity.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
The representation of a single edge during network building.
void parse_PartOfArea()
Parses FLAECHENELEMENT.
void incLaneNo(unsigned int by)
bool insert(const std::string &id, int noLanes, SUMOReal maxSpeed, int prio, SUMOReal width, SUMOVehicleClass vClasses=SVC_UNKNOWN, bool oneWayIsDefault=false)
Adds a type into the list. This is a simplified convenience form of insert, if only one allowed vehic...
bool hasOutgoing(const NBEdge *const e) const
Returns whether the given edge starts at this node.
std::string get(const std::string &name, bool prune=false) const
Returns the named information.
static SUMOReal _2SUMORealSec(const E *const data, SUMOReal def)
bool addLane2LaneConnection(unsigned int fromLane, NBEdge *dest, unsigned int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false)
Adds a connection between the specified this edge's lane and an approached one.
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.
bool addSink(const std::string &dist, NBEdge *const destination, SUMOReal weight)
Adds a sink to the named district.
void parse_EdgePolys()
Parses STRECKENPOLY.
bool splitAt(NBDistrictCont &dc, NBEdge *edge, NBNode *node)
Splits the edge at the position nearest to the given node.
void parse_Phases()
Parses LSAPHASE/PHASE.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
static SUMOLong _2long(const E *const data)
std::string myFileName
The name of the parsed file, for error reporting.
void parse_AreaSubPartElement()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
static const SUMOReal UNSPECIFIED_OFFSET
unspecified lane offset
bool hasIncoming(const NBEdge *const e) const
Returns whether the given edge ends at this node.
SUMOReal getNamedFloat(const std::string &fieldName)
Returns the value from the named column as a float.
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.
PositionVector reverse() const
void parse_TurnsToSignalGroups()
Parses ABBZULSASIGNALGRUPPE/SIGNALGRUPPEZUABBIEGER.
A class representing a single district.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges.
SUMOReal getWeightedFloat(const std::string &name)
tries to get a SUMOReal which is possibly assigned to a certain modality
const std::string & getID() const
Returns the id.
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.
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)
SUMOReal getSpeed(const std::string &type) const
Returns the maximal velocity for the given type [m/s].
A complete call description for parsing a single db.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
NIVisumTL_Map myTLS
List of visum traffic lights.
void parse_Connectors()
Parses ANBINDUNG.
A point in 2D or 3D with translation and scaling methods.
int getNumLanes(const std::string &type) const
Returns the number of lanes for the given type.
NBEdgeCont & getEdgeCont()
Returns the edge container.
unsigned int getNumLanes() const
Returns the number of lanes.
void setAsMacroscopicConnector()
Marks this edge as a macroscopic connector.
int getPriority(const std::string &type) const
Returns the priority for the given type.
#define PROGRESS_BEGIN_MESSAGE(msg)
void parse_Districts()
Parses BEZIRK.
void addParser(const std::string &name, ParsingFunction function)
Adds a parser into the sorted list of parsers to use.
ParserVector mySingleDataParsers
List of known parsers.
void parse_Point()
Parses PUNKT.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
NBEdge * getEdge(NBNode *FromNode, NBNode *ToNode)
Returns the edge that connects both nodes.
NBEdge * getConnectionTo(NBNode *n) const
void parse_VSysTypes()
Parses VSYS.
std::map< SUMOLong, NBDistrict * > myShapeDistrictMap
A map from district shape definition name to the district.
std::map< SUMOLong, std::vector< SUMOLong > > mySubPartsAreas
A map from area parts to area ids.
void parse_Types()
Parses STRECKENTYP.
bool insert(NBDistrict *const district)
Adds a district to the dictionary.
void parse_Nodes()
Parses KNOTEN.
void push_back(const PositionVector &p)
Appends all positions from the given vector.
int get(SUMOReal capacity) const
Returns the number of lanes computed from the given capacity.
bool know(const std::string &name) const
Returns the information whether the named column is known.
void parse_Lanes()
Parses FAHRSTREIFEN.
static int _2int(const E *const data)
NBNode * getToNode() const
Returns the destination node of the edge.
~NIImporter_VISUM()
destructor
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
NBNodeCont & getNodeCont()
Returns the node container.
Instance responsible for building networks.
std::vector< NBEdge * > EdgeVector
NamedColumnsParser myLineParser
the parser to parse the information from the data lines
const PositionVector & getGeometry() const
Returns the geometry of the edge.
A storage for options typed value containers)
bool addSource(const std::string &dist, NBEdge *const source, SUMOReal weight)
Adds a source to the named district.
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
NBNode * buildDistrictNode(const std::string &id, NBNode *dest, bool isSource)
Builds a node for the given district and returns it.
std::string name
The name of the db.
NBTrafficLightLogicCont & getTLLogicCont()
Returns the traffic light logics container.
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.
std::map< SUMOLong, std::pair< SUMOLong, SUMOLong > > myEdges
A map of edge (not road, but "edge" in this case) ids to from/to-points.
void parse_Edges()
Parses STRECKE/STRECKEN.
NBNetBuilder & myNetBuilder
The network builder to fill with loaded values.
bool hasMore() const
Returns whether another line may be read (the file was not read completely)
void addGeometryPoint(int index, const Position &p)
Adds a further geometry point.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
#define PROGRESS_DONE_MESSAGE()
ParsingFunction function
Pointer to the function used for parsing.
static int _2intSec(const E *const data, int def)
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 the districts container.
void parseLine(const std::string &line)
Parses the contents of the line.
NBCapacity2Lanes myCapacity2Lanes
The converter to compute the lane number of edges from their capacity.
NBDistrict * retrieve(const std::string &id) const
Returns the districts with the given id.
SUMOReal getLength() const
Returns the computed length of the edge.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void parse_LanesConnections()
Parses FAHRSTREIFENABBIEGER.
NBNode * getFromNode() const
Returns the origin node of the edge.