105 if (!oc.
isSet(
"itsumo-files")) {
114 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++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) {
215 if (!myNetBuilder.getEdgeCont().insert(edge)) {
217 WRITE_ERRORF(
TL(
"Could not add edge '%'. Probably declared twice."), ls->
id);
227 std::string
id = myParameter[
"id"];
232 WRITE_ERRORF(
TL(
"Unable to project coordinates for node '%'."),
id);
235 if (!myNetBuilder.getNodeCont().insert(node)) {
237 WRITE_ERRORF(
TL(
"Could not add node '%'. Probably declared twice."),
id);
240 WRITE_ERRORF(
TL(
"Not numeric position information for 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_ERRORF(
TL(
"Missing node in laneset '%'."), myParameter[
"lanesetID"]);
262 if (myLaneSets.find(
id) != myLaneSets.end()) {
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_ERRORF(
TL(
"Not numeric value in laneset '%'."), myParameter[
"lanesetID"]);
279 WRITE_ERRORF(
TL(
"Missing data in laneset '%'."), myParameter[
"lanesetID"]);
285 std::string
id = myParameter[
"laneID"];
288 myCurrentLanes.push_back(
Lane(
id, (
int) i, v));
290 WRITE_ERRORF(
TL(
"Not numeric value in lane '%'."), myParameter[
"laneID"]);
292 WRITE_ERRORF(
TL(
"Missing data in lane '%'."), myParameter[
"laneID"]);
#define WRITE_ERRORF(...)
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
static bool isReadable(std::string path)
Checks whether the given file is readable.
A handler which converts occurring elements and attributes into enums.
void needsCharacterData(const bool value=true)
void setFileName(const std::string &name)
Sets the current file name.
The representation of a single edge during network building.
static const double UNSPECIFIED_FRICTION
unspecified lane friction
static const double UNSPECIFIED_WIDTH
unspecified lane width
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Instance responsible for building networks.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
Represents a single node (junction) during network building.
void myCharacters(int element, const std::string &chars)
Callback method for characters to implement by derived classes.
Handler(NBNetBuilder &toFill)
Contructor.
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.
static StringBijection< int >::Entry itsumoAttrs[]
The names of MATSIM-XML attributes (for passing to GenericSAXHandler)
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given ITSUMO network files.
@ ITSUMO_TAG_LANE_POSITION
@ ITSUMO_TAG_IS_PREFERENCIAL
@ ITSUMO_TAG_DELIMITING_NODE
@ ITSUMO_TAG_MAXIMUM_SPEED
@ ITSUMO_TAG_TRAFFIC_LIGHTS
@ ITSUMO_TAG_DECELERATION_PROB
@ ITSUMO_TAG_TURNING_PROBABILITIES
@ ITSUMO_TAG_DESTINATION_LANESET
@ ITSUMO_TAG_SECTION_NAME
@ ITSUMO_TAG_NETWORK_NAME
@ ITSUMO_TAG_LANESET_POSITION
static StringBijection< int >::Entry itsumoTags[]
The names of MATSIM-XML elements (for passing to GenericSAXHandler)
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
A point in 2D or 3D with translation and scaling methods.
Encapsulated SAX-Attributes.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false, const bool isExternal=false, const bool catchExceptions=true)
Runs the given handler on the given file; returns if everything's ok.
std::vector< Lane > lanes