 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
106 if (!oc.
isSet(
"itsumo-files")) {
114 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
117 WRITE_ERROR(
"Could not open itsumo-file '" + *file +
"'.");
134 :
GenericSAXHandler(itsumoTags, ITSUMO_TAG_NOTHING, itsumoAttrs, ITSUMO_ATTR_NOTHING,
"itsumo - file"), myNetBuilder(toFill) {
162 myParameter[
"id"] = mc;
165 myParameter[
"name"] = mc;
168 myParameter[
"x"] = mc;
171 myParameter[
"y"] = mc;
175 myParameter[
"sectionID"] = mc;
179 myParameter[
"lanesetID"] = mc;
182 myParameter[
"pos"] = mc;
185 myParameter[
"from"] = mc;
188 myParameter[
"to"] = mc;
192 myParameter[
"laneID"] = mc;
195 myParameter[
"i"] = mc;
198 myParameter[
"v"] = mc;
210 for (std::vector<Section*>::iterator i = mySections.begin(); i != mySections.end(); ++i) {
211 for (std::vector<LaneSet*>::iterator j = (*i)->laneSets.begin(); j != (*i)->laneSets.end(); ++j) {
214 if (!myNetBuilder.getEdgeCont().insert(edge)) {
216 WRITE_ERROR(
"Could not add edge '" + ls->
id +
"'. Probably declared twice.");
226 std::string
id = myParameter[
"id"];
231 WRITE_ERROR(
"Unable to project coordinates for node '" +
id +
"'.");
234 if (!myNetBuilder.getNodeCont().insert(node)) {
236 WRITE_ERROR(
"Could not add node '" +
id +
"'. Probably declared twice.");
239 WRITE_ERROR(
"Not numeric position information for node '" + myParameter[
"id"] +
"'.");
241 WRITE_ERROR(
"Missing data in node '" + myParameter[
"id"] +
"'.");
246 mySections.push_back(
new Section(myParameter[
"sectionID"], myCurrentLaneSets));
247 myCurrentLaneSets.clear();
252 std::string
id = myParameter[
"lanesetID"];
254 std::string fromID = myParameter[
"from"];
255 std::string toID = myParameter[
"to"];
256 NBNode* from = myNetBuilder.getNodeCont().retrieve(fromID);
257 NBNode* to = myNetBuilder.getNodeCont().retrieve(toID);
258 if (from ==
nullptr || to ==
nullptr) {
259 WRITE_ERROR(
"Missing node in laneset '" + myParameter[
"lanesetID"] +
"'.");
261 if (myLaneSets.find(
id) != myLaneSets.end()) {
262 WRITE_ERROR(
"Fond laneset-id '" +
id +
"' twice.");
265 for (std::vector<Lane>::iterator j = myCurrentLanes.begin(); j != myCurrentLanes.end(); ++j) {
268 vSum /= (double) myCurrentLanes.size();
271 myCurrentLaneSets.push_back(ls);
272 myCurrentLanes.clear();
276 WRITE_ERROR(
"Not numeric value in laneset '" + myParameter[
"lanesetID"] +
"'.");
278 WRITE_ERROR(
"Missing data in laneset '" + myParameter[
"lanesetID"] +
"'.");
284 std::string
id = myParameter[
"laneID"];
287 myCurrentLanes.push_back(
Lane(
id, (
int) i, v));
289 WRITE_ERROR(
"Not numeric value in lane '" + myParameter[
"laneID"] +
"'.");
291 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.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
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)
void setFileName(const std::string &name)
Sets the current file name.