 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
107 if (!oc.
isSet(
"itsumo-files")) {
115 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
118 WRITE_ERROR(
"Could not open itsumo-file '" + *file +
"'.");
135 :
GenericSAXHandler(itsumoTags, ITSUMO_TAG_NOTHING, itsumoAttrs, ITSUMO_ATTR_NOTHING,
"itsumo - file"), myNetBuilder(toFill) {
163 myParameter[
"id"] = mc;
166 myParameter[
"name"] = mc;
169 myParameter[
"x"] = mc;
172 myParameter[
"y"] = mc;
176 myParameter[
"sectionID"] = mc;
180 myParameter[
"lanesetID"] = mc;
183 myParameter[
"pos"] = mc;
186 myParameter[
"from"] = mc;
189 myParameter[
"to"] = mc;
193 myParameter[
"laneID"] = mc;
196 myParameter[
"i"] = mc;
199 myParameter[
"v"] = mc;
211 for (std::vector<Section*>::iterator i = mySections.begin(); i != mySections.end(); ++i) {
212 for (std::vector<LaneSet*>::iterator j = (*i)->laneSets.begin(); j != (*i)->laneSets.end(); ++j) {
215 if (!myNetBuilder.getEdgeCont().insert(edge)) {
217 WRITE_ERROR(
"Could not add edge '" + ls->
id +
"'. Probably declared twice.");
227 std::string
id = myParameter[
"id"];
232 WRITE_ERROR(
"Unable to project coordinates for node '" +
id +
"'.");
235 if (!myNetBuilder.getNodeCont().insert(node)) {
237 WRITE_ERROR(
"Could not add node '" +
id +
"'. Probably declared twice.");
240 WRITE_ERROR(
"Not numeric position information for node '" + myParameter[
"id"] +
"'.");
242 WRITE_ERROR(
"Missing data in node '" + myParameter[
"id"] +
"'.");
247 mySections.push_back(
new Section(myParameter[
"sectionID"], myCurrentLaneSets));
248 myCurrentLaneSets.clear();
253 std::string
id = myParameter[
"lanesetID"];
255 std::string fromID = myParameter[
"from"];
256 std::string toID = myParameter[
"to"];
257 NBNode* from = myNetBuilder.getNodeCont().retrieve(fromID);
258 NBNode* to = myNetBuilder.getNodeCont().retrieve(toID);
259 if (from ==
nullptr || to ==
nullptr) {
260 WRITE_ERROR(
"Missing node in laneset '" + myParameter[
"lanesetID"] +
"'.");
262 if (myLaneSets.find(
id) != myLaneSets.end()) {
263 WRITE_ERROR(
"Fond laneset-id '" +
id +
"' twice.");
266 for (std::vector<Lane>::iterator j = myCurrentLanes.begin(); j != myCurrentLanes.end(); ++j) {
269 vSum /= (double) myCurrentLanes.size();
272 myCurrentLaneSets.push_back(ls);
273 myCurrentLanes.clear();
277 WRITE_ERROR(
"Not numeric value in laneset '" + myParameter[
"lanesetID"] +
"'.");
279 WRITE_ERROR(
"Missing data in laneset '" + myParameter[
"lanesetID"] +
"'.");
285 std::string
id = myParameter[
"laneID"];
288 myCurrentLanes.push_back(
Lane(
id, (
int) i, v));
290 WRITE_ERROR(
"Not numeric value in lane '" + myParameter[
"laneID"] +
"'.");
292 WRITE_ERROR(
"Missing data in lane '" + myParameter[
"laneID"] +
"'.");
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static const double UNSPECIFIED_OFFSET
unspecified lane offset
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.
Instance responsible for building networks.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
std::vector< Lane > lanes
Handler(NBNetBuilder &toFill)
Contructor.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
static StringBijection< int >::Entry itsumoTags[]
The names of MATSIM-XML elements (for passing to GenericSAXHandler)
The representation of a single edge during network building.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
A point in 2D or 3D with translation and scaling methods.
A storage for options typed value containers)
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given ITSUMO network files.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
#define PROGRESS_BEGIN_MESSAGE(msg)
void myEndElement(int element)
Callback method for a closing tag to implement by derived classes.
#define PROGRESS_DONE_MESSAGE()
static const double UNSPECIFIED_WIDTH
unspecified lane width
static bool isReadable(std::string path)
Checks whether the given file is readable.
void myCharacters(int element, const std::string &chars)
Callback method for characters to implement by derived classes.
Represents a single node (junction) during network building.
A handler which converts occuring elements and attributes into enums.
Encapsulated SAX-Attributes.
static StringBijection< int >::Entry itsumoAttrs[]
The names of MATSIM-XML attributes (for passing to GenericSAXHandler)
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String)
void setFileName(const std::string &name)
Sets the current file name.