 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
138 "desSpeedDistribution",
142 "speedDistributionDataPoint",
146 "vehicleRoutingDecisionStatic",
150 "vehicleRouteStatic",
194 if (!oc.
isSet(
"vissim-file")) {
208 vissimAttrs, VISSIM_ATTR_NOTHING,
210 myElemData(elemData),
232 myElemData[
"name"].push_back(attrs.
get<std::string>(
VISSIM_ATTR_NAME,
nullptr, ok,
false));
246 if (isConnector !=
true) {
252 myElemData[
"from_pos"].push_back(attrs.
get<std::string>(
VISSIM_ATTR_POS,
nullptr, ok));
253 myElemData[
"from_id"].push_back(from[0]);
254 myElemData[
"from_lane"].push_back(from[1]);
262 myElemData[
"to_id"].push_back(to[0]);
263 myElemData[
"to_lane"].push_back(to[1]);
269 std::string sep(
" ");
276 if (z.length() > 0) {
280 myElemData[
"pos"].push_back(posS);
292 std::vector<int> assignedVehicles;
297 while (!myElemData[
"pos"].empty()) {
299 myElemData[
"pos"].front(),
" ").getVector());
300 myElemData[
"pos"].pop_front();
301 std::vector<double> pos_v(3);
304 std::transform(sPos_v.begin(), sPos_v.end(), pos_v.begin(),
309 double length(geom.
length());
311 if (isConnector ==
false) {
313 std::vector<double> laneWidths;
314 for (std::string& w : myElemData[
"width"]) {
318 myElemData[
"name"].front(),
319 myElemData[
"type"].front(),
326 int numLanes = (int)myElemData[
"width"].size();
327 std::vector<int> laneVec(numLanes);
334 for (std::vector<int>::iterator each = ++laneVec.begin(); each != laneVec.end(); ++each) {
335 *each = *(each - 1) + 1;
348 for (std::vector<int>::iterator each = ++laneVec.begin(); each != laneVec.end(); ++each) {
349 *each = *(each - 1) + 1;
360 myElemData[
"name"].front(),
362 geom, assignedVehicles, clv);
425 std::vector<std::pair<int, int> > assignedVehicles;
428 std::vector<int> districts;
430 std::vector<double> percentages;
452 myElemData(elemData),
453 myHierarchyLevel(0) {
466 myElemData[
"name"].push_back(attrs.
get<std::string>(
VISSIM_ATTR_NAME,
nullptr, ok,
false));
468 for (
int pos = (
int)colorStr.size() - 2; pos > 0; pos -= 2) {
469 colorStr.insert(pos,
" ");
471 myElemData[
"color"].push_back(colorStr);
485 std::istringstream iss(myElemData[
"color"].front());
487 myElemData[
"color"].front(),
" ").getVector());
488 std::vector<int> myColorVector(sCol_v.size());
491 color =
RGBColor((
unsigned char)myColorVector[0],
492 (
unsigned char)myColorVector[1],
493 (
unsigned char)myColorVector[2],
494 (
unsigned char)myColorVector[3]);
495 std::vector<int> types;
496 while (!myElemData[
"types"].empty()) {
498 myElemData[
"types"].pop_front();
502 myElemData[
"name"].front(),
517 myElemData(elemData),
518 myHierarchyLevel(0) {
534 std::string sep(
" ");
538 myElemData[
"points"].push_back(posS);
548 while (!myElemData[
"points"].empty()) {
550 myElemData[
"points"].front(),
" ").getVector());
551 myElemData[
"points"].pop_front();
567 myElemData(elemData),
568 myHierarchyLevel(0) {
579 myElemData[
"name"].push_back(attrs.
get<std::string>(
VISSIM_ATTR_NAME,
nullptr, ok,
false));
598 myElemData(elemData),
599 myHierarchyLevel(0) {
611 myElemData[
"startPos"].push_back(attrs.
get<std::string>(
VISSIM_ATTR_POS,
nullptr, ok));
648 if (status !=
"PASSIVE") {
663 : myVissimParent(parent) {}
680 const std::string& excl) {
682 std::string tmp = myRead(from);
688 (tmp.substr(0, 2) ==
"--" || !myVissimParent.admitContinue(tmp))
698 const std::vector<std::string>& excl) {
699 std::vector<std::string> myExcl;
700 std::vector<std::string>::const_iterator i;
701 for (i = excl.begin(); i != excl.end(); i++) {
703 myExcl.push_back(mes);
705 std::string tmp = myRead(from);
711 for (i = myExcl.begin(); i != myExcl.end() && !equals; i++) {
718 (tmp.substr(0, 2) ==
"--" || !myVissimParent.admitContinue(tmp))
728 const std::string& tag) {
735 if (tmp ==
"beschriftung") {
737 if (tmp ==
"keine") {
758 std::istream& from,
const std::string& next) {
759 std::string tmp = readEndSecure(from);
760 std::vector<int> ret;
765 while (tmp !=
"DATAEND" && tmp != next) {
767 tmp = readEndSecure(from);
775 std::istream& from) {
781 std::vector<int> lanes;
782 while (tag !=
"bei") {
783 tag = readEndSecure(from);
786 lanes.push_back(lane - 1);
791 std::vector<int> dummy;
800 if (name[0] ==
'"') {
801 while (name[name.length() - 1] !=
'"') {
804 name = name +
" " + tmp;
806 name = name.substr(1, name.length() - 2);
814 const std::string& name) {
816 while (tag != name) {
823 const std::string& name) {
825 while (tag != name) {
828 while (tag !=
"DATAEND") {
829 tag = readEndSecure(from);
884 const std::string file = options.
getString(
"vissim-file");
886 std::ifstream strm(file.c_str());
888 WRITE_ERROR(
"Could not open vissim-file '" + file +
"'.");
919 XMLHandler_Geschwindigkeitsverteilung.
setFileName(file);
928 XMLHandler_Fahrzeugklassendefinition.
setFileName(file);
952 strm.seekg(strm.beg);
976 while (strm.good() && ok) {
985 while (!parsed && strm.good() && ok) {
988 ToParserMap::iterator j =
myParsers.find((*i).second);
991 ok = parser->
parse(strm);
1000 getline(strm, line);
1001 }
while (strm.good() && (line ==
"" || line[0] ==
' ' || line[0] ==
'-'));
NIVissimExtendedEdgePoint readExtEdgePointDef(std::istream &from)
static const RGBColor GREY
static StringBijection< int >::Entry vissimAttrs[]
The names of VISSIM-XML attributes (for passing to GenericSAXHandler)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static void dict_BuildDistrictNodes(NBDistrictCont &dc, NBNodeCont &nc)
Builds the nodes that belong to a district.
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
static void dict_assignToEdges()
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.
static void buildConnectionClusters()
Clusters connections of each edge.
~NIVissimXMLHandler_ConflictArea()
Destructor.
std::vector< NIVissimClosedLaneDef * > NIVissimClosedLanesVector
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
bool skipOverreading(std::istream &from, const std::string &name="")
Overreads the named parameter (if) given and skips the rest until "DATAEND".
virtual ~VissimSingleTypeParser()
Destructor.
static bool dictionary(const std::string &type, const std::string &id, Distribution *d)
Adds a distribution of the given type and name to the container.
A temporary storage for edges imported from Vissim.
Instance responsible for building networks.
static void buildNBNodes(NBNodeCont &nc)
NIVissimXMLHandler_ConflictArea()
Constructor.
static const RGBColor BLACK
~NIVissimXMLHandler_Parkplatzdefinition()
Destructor.
NIVissimXMLHandler_Parkplatzdefinition()
Constructor.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
static const RGBColor YELLOW
std::string readName(std::istream &from)
Reads the structures name We cannot use the "<<" operator, as names may contain more than one word wh...
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static void dict_BuildDistrictConnections()
bool admitContinue(const std::string &tag)
static const RGBColor CYAN
~NIVissimXMLHandler_Fahrzeugklassendefinition()
Destructor.
static std::string to_lower_case(std::string str)
Transfers the content to lower case.
Importer for networks stored in Vissim format.
static bool dictionary(int id, const std::string &name, const std::vector< int > &districts, const std::vector< double > &percentages, int edgeid, double position, const std::vector< std::pair< int, int > > &assignedVehicles)
Inserts the connection into the dictionary after building it.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Position getPosition(std::istream &from)
returns the 2d-position saved as next within the stream
static OptionsCont & getOptions()
Retrieves the options.
static bool dictionary(const std::string &id, const std::string &name, const std::string &edgeid)
ToElemIDMap myKnownElements
Map from element names to their numerical representation.
void insertKnownElements()
adds name-to-id - relationships of known elements into myKnownElements
double length() const
Returns the length.
static void dict_BuildDistricts(NBDistrictCont &dc, NBEdgeCont &ec, NBNodeCont &nc)
Builds the districts.
NIVissimXMLHandler_Streckendefinition(nodeMap &elemData)
Constructor.
bool readContents(std::istream &strm)
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
NBEdgeCont & getEdgeCont()
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
static std::string convertUmlaute(std::string str)
Converts german "Umlaute" to their latin-version.
static bool dict_SetSignals(NBTrafficLightLogicCont &tlc, NBEdgeCont &ec)
static bool dictionary(int id, const std::string &name, const std::string &type, int noLanes, double zuschlag1, double zuschlag2, double length, const PositionVector &geom, const NIVissimClosedLanesVector &clv)
Adds the described item to the dictionary Builds the edge first.
static const RGBColor MAGENTA
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
void push_back_noDoublePos(const Position &p)
insert in back a non double position
std::string readEndSecure(std::istream &from, const std::string &excl="")
as myRead, but returns "DATAEND" when the current field has ended
static bool endsWith(const std::string &str, const std::string suffix)
Checks whether a given string ends with the suffix.
void load(const OptionsCont &options)
loads the vissim file
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
ToParserMap myParsers
Parsers by element id.
virtual bool parse(std::istream &from)=0
Parses a single data type. Returns whether no error occurred.
static void clearDict()
Clears the dictionary.
static void reportUnsetSpeeds()
Writes edges with unset speeds to the warnings message log instance.
A point in 2D or 3D with translation and scaling methods.
static const RGBColor RED
named colors
A storage for options typed value containers)
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
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
~NIVissimXMLHandler_VWunschentscheidungsdefinition()
Destructor.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static void dict_CheckEdgeEnds()
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static void dict_buildNBEdges(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec, double offset)
Builds NBEdges from the VissimEdges within the dictionary.
static bool dictionary(int id, const std::string &name, const RGBColor &color, std::vector< int > &types)
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.
static void dict_buildNBEdgeConnections(NBEdgeCont &ec)
static int hexToInt(const std::string &sData)
converts a string with a hex value into the integer value described by it by calling the char-type co...
NBNetBuilder & myNetBuilder
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
NIVissimXMLHandler_VWunschentscheidungsdefinition(nodeMap &elemData)
Constructor.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
void readUntil(std::istream &from, const std::string &name)
Reads from the stream until the keywor occurs.
#define PROGRESS_BEGIN_MESSAGE(msg)
NIImporter_Vissim(NBNetBuilder &nb)
constructor
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
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,...
static void closeLoading()
static void dict_propagateSpeeds()
NIVissimXMLHandler_Fahrzeugklassendefinition(nodeMap &elemData)
Constructor.
NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition(nodeMap &elemData)
Constructor.
#define PROGRESS_DONE_MESSAGE()
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
~NIVissimXMLHandler_Streckendefinition()
Destructor.
static void dict_checkEdges2Join()
static void dict_SetDisturbances()
std::string overrideOptionalLabel(std::istream &from, const std::string &tag="")
overrides the optional label definition; returns the next tag as done by readEndSecure
std::vector< std::string > getVector()
return vector of strings
static void buildNodeClusters()
void buildParsers()
adds id-to-parser - relationships of elements to parse into myParsers
void postLoadBuild(double offset)
static bool dictionary(int id, NIVissimConnection *o)
static void setPriorityRegulation(NBEdgeCont &ec)
Sets the priority regulation according to the VISSIM conflict area data.
static void dict_addDisturbances(NBDistrictCont &dc, NBNodeCont &nc, NBEdgeCont &ec)
static void setCurrentVirtID(int id)
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
static const RGBColor GREEN
std::string myRead(std::istream &from)
reads from the stream and returns the lower case version of the read value
std::map< std::string, std::list< std::string > > nodeMap
NIVissimXMLHandler_Routenentscheidungsdefinition(nodeMap &elemData)
Constructor.
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;.
~NIVissimXMLHandler_Zuflussdefinition()
Destructor.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
A handler which converts occuring elements and attributes into enums.
~NIVissimXMLHandler_Geschwindigkeitsverteilungsdefinition()
Destructor.
~NIVissimXMLHandler_Routenentscheidungsdefinition()
Destructor.
~NIImporter_Vissim()
destructor
Encapsulated SAX-Attributes.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads network definition from the assigned option and stores it in the given network builder.
VissimSingleTypeParser(NIImporter_Vissim &parent)
Constructor.
NIVissimXMLHandler_Zuflussdefinition()
Constructor.
static void joinBySameEdges(double offset)
Tries to joind clusters participating within a node This is done by joining clusters which overlap.
static void clearDict()
Clears the dictionary.
void setFileName(const std::string &name)
Sets the current file name.
static const RGBColor WHITE