124 #ifdef CHECK_MEMORY_LEAKS 126 #endif // CHECK_MEMORY_LEAKS 148 "desSpeedDistribution",
152 "speedDistributionDataPoint",
156 "vehicleRoutingDecisionStatic",
160 "vehicleRouteStatic",
204 if (!oc.
isSet(
"vissim-file")) {
210 if ((oc.
getString(
"vissim-file").find(
".inpx") != std::string::npos))
215 loader.myInputIsLegacyFormat =
false;
219 loader.myInputIsLegacyFormat =
true;
233 myElemData(elemData),
253 myElemData[
"id"].push_back(attrs.
get<std::string>(VISSIM_ATTR_NO, 0, ok));
292 std::string sep(
" ");
299 if (z.length() > 0) {
315 std::vector<int> assignedVehicles;
324 std::vector<SUMOReal> pos_v(3);
327 std::transform(sPos_v.begin(), sPos_v.end(), pos_v.begin(),
344 if (
id == 85 ||
id == 91) {
345 std::cout <<
id <<
"\n";
346 std::cout <<
myElemData[
"width"].size() <<
"\n";
347 std::cout << length <<
"\n";
348 std::cout << geom <<
"\n";
351 int numLanes = (int)
myElemData[
"width"].size();
352 std::vector<int> laneVec(numLanes);
359 for (std::vector<int>::iterator each = ++laneVec.begin(); each != laneVec.end(); ++each) {
360 *each = *(each - 1) + 1;
373 for (std::vector<int>::iterator each = ++laneVec.begin(); each != laneVec.end(); ++each) {
374 *each = *(each - 1) + 1;
387 geom, assignedVehicles, clv);
448 std::vector<std::pair<int, int> > assignedVehicles;
451 std::vector<int> districts;
453 std::vector<SUMOReal> percentages;
475 myElemData(elemData),
476 myHierarchyLevel(0) {
491 for (
size_t pos = colorStr.size() - 2; pos > 0; pos -= 2) {
492 colorStr.insert(pos,
" ");
508 std::istringstream iss(
myElemData[
"color"].front());
510 myElemData[
"color"].front(),
" ").getVector());
511 std::vector<int> myColorVector(sCol_v.size());
512 std::transform(sCol_v.begin(), sCol_v.end(), myColorVector.begin(),
515 color =
RGBColor((
unsigned char)myColorVector[0],
516 (
unsigned char)myColorVector[1],
517 (
unsigned char)myColorVector[2],
518 (
unsigned char)myColorVector[3]);
519 std::vector<int> types;
558 std::string sep(
" ");
574 myElemData[
"points"].front(),
" ").getVector());
576 std::vector<SUMOReal> pos_v(2);
579 std::transform(sPos_v.begin(), sPos_v.end(), pos_v.begin(),
680 if (status !=
"PASSIVE") {
695 : myVissimParent(parent) {}
712 const std::string& excl) {
714 std::string tmp =
myRead(from);
730 const std::vector<std::string>& excl) {
731 std::vector<std::string> myExcl;
732 std::vector<std::string>::const_iterator i;
733 for (i = excl.begin(); i != excl.end(); i++) {
735 myExcl.push_back(mes);
737 std::string tmp =
myRead(from);
743 for (i = myExcl.begin(); i != myExcl.end() && !equals; i++) {
760 const std::string& tag) {
767 if (tmp ==
"beschriftung") {
769 if (tmp ==
"keine") {
790 std::istream& from,
const std::string& next) {
792 std::vector<int> ret;
797 while (tmp !=
"DATAEND" && tmp != next) {
807 std::istream& from) {
813 std::vector<int> lanes;
814 while (tag !=
"bei") {
818 lanes.push_back(lane - 1);
823 std::vector<int> dummy;
832 if (name[0] ==
'"') {
833 while (name[name.length() - 1] !=
'"') {
836 name = name +
" " + tmp;
838 name = name.substr(1, name.length() - 2);
846 const std::string& name) {
848 while (tag != name) {
855 const std::string& name) {
857 while (tag != name) {
860 while (tag !=
"DATAEND") {
920 std::ifstream strm(options.
getString(
"vissim-file").c_str());
934 std::string file = options.
getString(
"vissim-file");
943 WRITE_ERROR(
"Could not open vissim-file '" + file +
"'.");
964 XMLHandler_Geschwindigkeitsverteilung.
setFileName(file);
973 XMLHandler_Fahrzeugklassendefinition.
setFileName(file);
1015 while (strm.good() && ok) {
1023 bool parsed =
false;
1024 while (!parsed && strm.good() && ok) {
1027 ToParserMap::iterator j =
myParsers.find((*i).second);
1030 ok = parser->
parse(strm);
1039 getline(strm, line);
1040 }
while (strm.good() && (line ==
"" || line[0] ==
' ' || line[0] ==
'-'));
~NIVissimXMLHandler_Zuflussdefinition()
Destructor.
void readUntil(std::istream &from, const std::string &name)
Reads from the stream until the keywor occurs.
int myHierarchyLevel
The current hierarchy level.
static void dict_BuildDistricts(NBDistrictCont &dc, NBEdgeCont &ec, NBNodeCont &nc)
Builds the districts.
static SUMOReal _str2SUMOReal(const std::string &sData)
static bool dictionary(int id, const std::string &name, const RGBColor &color, std::vector< int > &types)
static void dict_buildNBEdgeConnections(NBEdgeCont &ec)
static bool isReadable(std::string path)
Checks whether the given file is readable.
NIVissimXMLHandler_Parkplatzdefinition()
Constructor.
static void joinBySameEdges(SUMOReal offset)
Tries to joind clusters participating within a node This is done by joining clusters which overlap...
NIVissimXMLHandler_Streckendefinition(nodeMap &elemData)
Constructor.
static const RGBColor WHITE
static bool dictionary(int id, const std::string &link1, const std::string &link2, const std::string &status)
Adds the described item to the dictionary Builds the conflict area first.
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
static void dict_checkEdges2Join()
NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition(nodeMap &elemData)
Constructor.
~NIVissimXMLHandler_Routenentscheidungsdefinition()
Destructor.
static void reportUnsetSpeeds()
Writes edges with unset speeds to the warnings message log instance.
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
std::vector< NIVissimClosedLaneDef * > NIVissimClosedLanesVector
~NIImporter_Vissim()
destructor
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static StringBijection< int >::Entry vissimAttrs[]
The names of VISSIM-XML attributes (for passing to GenericSAXHandler)
NIVissimXMLHandler_Zuflussdefinition()
Constructor.
static bool dictionary(const std::string &type, const std::string &id, Distribution *d)
~NIVissimXMLHandler_Parkplatzdefinition()
Destructor.
~NIVissimXMLHandler_VWunschentscheidungsdefinition()
Destructor.
Importer for networks stored in Vissim format.
VissimSingleTypeParser(NIImporter_Vissim &parent)
Constructor.
virtual ~VissimSingleTypeParser()
Destructor.
NIVissimXMLHandler_Routenentscheidungsdefinition(nodeMap &elemData)
Constructor.
virtual bool parse(std::istream &from)=0
Parses a single data type. Returns whether no error occured.
bool readContents(std::istream &strm)
static void closeLoading()
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
static const RGBColor BLACK
~NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition()
Destructor.
static bool dictionary(int id, NIVissimConnection *o)
int myLastNodeID
ID of the currently parsed node, for reporting mainly.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
#define UNUSED_PARAMETER(x)
NIImporter_Vissim & myVissimParent
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static void setPriorityRegulation(NBEdgeCont &ec)
Sets the priority regulation according to the VISSIM conflict area data.
int myHierarchyLevel
The current hierarchy level.
static OptionsCont & getOptions()
Retrieves the options.
A temporary storage for edges imported from Vissim.
void loadXML(const OptionsCont &options, NBNetBuilder &nb)
ToParserMap myParsers
Parsers by element id.
static void dict_CheckEdgeEnds()
static void dict_assignToEdges()
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void insertKnownElements()
adds name-to-id - relationships of known elements into myKnownElements
ToElemIDMap myKnownElements
Map from element names to their numerical representation.
~NIVissimXMLHandler_Fahrzeugklassendefinition()
Destructor.
static void dict_BuildDistrictConnections()
A handler which converts occuring elements and attributes into enums.
static void setCurrentVirtID(int id)
static const RGBColor GREEN
static const RGBColor GREY
void setFileName(const std::string &name)
Sets the current file name.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
bool myInputIsLegacyFormat
NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream &from)
static void dict_addDisturbances(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec)
Encapsulated SAX-Attributes.
static void dict_propagateSpeeds()
void load(const OptionsCont &options)
loads the vissim file
static void clearDict()
Clears the dictionary.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
A point in 2D or 3D with translation and scaling methods.
NBEdgeCont & getEdgeCont()
Returns the edge container.
static StringBijection< int >::Entry vissimTags[]
The names of VISSIM-XML elements (for passing to GenericSAXHandler)
ColorMap myColorMap
a map from color names to color definitions
~NIVissimXMLHandler_Streckendefinition()
Destructor.
static void buildNodeClusters()
static int _str2int(const std::string &sData)
static bool dict_SetSignals(NBTrafficLightLogicCont &tlc, NBEdgeCont &ec)
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static const RGBColor MAGENTA
#define PROGRESS_BEGIN_MESSAGE(msg)
bool isConnector
check if the link is a connector
Position getPosition(std::istream &from)
returns the 2d-position saved as next within the stream
int myHierarchyLevel
The current hierarchy level.
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
void postLoadBuild(SUMOReal offset)
static std::string convertUmlaute(std::string str)
Converts german "Umlaute" to their latin-version.
static bool dictionary(int id, const std::string &name, const std::vector< int > &districts, const std::vector< SUMOReal > &percentages, int edgeid, SUMOReal position, const std::vector< std::pair< int, int > > &assignedVehicles)
Inserts the connection into the dictionary after building it.
std::vector< std::string > getVector()
void buildParsers()
adds id-to-parser - relationships of elements to parse into myParsers
NIVissimXMLHandler_Fahrzeugklassendefinition(nodeMap &elemData)
Constructor.
static void clearDict()
Clears the dictionary.
SUMOReal length() const
Returns the length.
static void buildConnectionClusters()
Clusters connections of each edge.
static std::string to_lower_case(std::string str)
Transfers the content to lower case.
static const RGBColor YELLOW
static int _2int(const E *const data)
static const RGBColor RED
static const RGBColor CYAN
std::map< std::string, std::list< std::string > > nodeMap
~NIVissimXMLHandler_ConflictArea()
Destructor.
NIImporter_Vissim(NBNetBuilder &nb, const std::string &file)
constructor
NBNodeCont & getNodeCont()
Returns the node container.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Instance responsible for building networks.
int myHierarchyLevel
The current hierarchy level.
A storage for options typed value containers)
bool skipOverreading(std::istream &from, const std::string &name="")
Overreads the named parameter (if) given and skips the rest until "DATAEND".
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder...
NBTrafficLightLogicCont & getTLLogicCont()
Returns the traffic light logics container.
static void buildNBNodes(NBNodeCont &nc)
static bool dictionary(int id, const std::string &name, const std::string &type, int noLanes, SUMOReal zuschlag1, SUMOReal zuschlag2, SUMOReal length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Adds the described item to the dictionary Builds the edge first.
NIVissimXMLHandler_VWunschentscheidungsdefinition(nodeMap &elemData)
Constructor.
static void dict_SetDisturbances()
void push_back_noDoublePos(const Position &p)
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
NBNetBuilder & myNetBuilder
NIVissimXMLHandler_ConflictArea()
Constructor.
#define PROGRESS_DONE_MESSAGE()
static int _strHex2int(const std::string &sData)
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
int myHierarchyLevel
The current hierarchy level.
NBDistrictCont & getDistrictCont()
Returns the districts container.
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
bool admitContinue(const std::string &tag)
static void dict_buildNBEdges(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, SUMOReal offset)
Builds NBEdges from the VissimEdges within the dictionary.
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure ...
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
std::vector< int > parseAssignedVehicleTypes(std::istream &from, const std::string &next)
parses a listof vehicle types assigned to the current data field One should remeber, that -1 means "all" vehicle types
static bool dictionary(const std::string &id, const std::string &name, const std::string &edgeid)
static void dict_BuildDistrictNodes(NBDistrictCont &dc, NBNodeCont &nc)
Builds the nodes that belong to a district.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.