void ROLoader::loadNet(RONet& toFill, ROAbstractEdgeBuilder& eb) { std::string file = myOptions.getString("net-file"); if (file == "") { throw ProcessError("Missing definition of network to load!"); } if (!FileHelpers::exists(file)) { throw ProcessError("The network file '" + file + "' could not be found."); } PROGRESS_BEGIN_MESSAGE("Loading net"); RONetHandler handler(toFill, eb); handler.setFileName(file); if (!XMLSubSys::runParser(handler, file)) { PROGRESS_FAILED_MESSAGE(); throw ProcessError(); } else { PROGRESS_DONE_MESSAGE(); } if (myOptions.isSet("taz-files", false)) { // dfrouter does not register this option file = myOptions.getString("taz-files"); if (!FileHelpers::exists(file)) { throw ProcessError("The districts file '" + file + "' could not be found."); } PROGRESS_BEGIN_MESSAGE("Loading districts"); handler.setFileName(file); if (!XMLSubSys::runParser(handler, file)) { PROGRESS_FAILED_MESSAGE(); throw ProcessError(); } else { PROGRESS_DONE_MESSAGE(); } } }
void ROLoader::loadNet(RONet& toFill, ROAbstractEdgeBuilder& eb) { std::string file = myOptions.getString("net-file"); if (file == "") { throw ProcessError("Missing definition of network to load!"); } if (!FileHelpers::isReadable(file)) { throw ProcessError("The network file '" + file + "' is not accessible."); } PROGRESS_BEGIN_MESSAGE("Loading net"); RONetHandler handler(toFill, eb); handler.setFileName(file); if (!XMLSubSys::runParser(handler, file, true)) { PROGRESS_FAILED_MESSAGE(); throw ProcessError(); } else { PROGRESS_DONE_MESSAGE(); } if (!deprecatedVehicleClassesSeen.empty()) { WRITE_WARNING("Deprecated vehicle classes '" + toString(deprecatedVehicleClassesSeen) + "' in input network."); deprecatedVehicleClassesSeen.clear(); } if (myOptions.isSet("additional-files", false)) { // dfrouter does not register this option std::vector<std::string> files = myOptions.getStringVector("additional-files"); for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { if (!FileHelpers::isReadable(*fileIt)) { throw ProcessError("The additional file '" + *fileIt + "' is not accessible."); } PROGRESS_BEGIN_MESSAGE("Loading additional file '" + *fileIt + "' "); handler.setFileName(*fileIt); if (!XMLSubSys::runParser(handler, *fileIt)) { PROGRESS_FAILED_MESSAGE(); throw ProcessError(); } else { PROGRESS_DONE_MESSAGE(); } } } }
void ODDistrictCont::loadDistricts(std::string districtfile) { if (!FileHelpers::exists(districtfile)) { throw ProcessError("Could not find network '" + districtfile + "' to load."); } PROGRESS_BEGIN_MESSAGE("Loading districts from '" + districtfile + "'"); // build the xml-parser and handler ODDistrictHandler handler(*this, districtfile); if (!XMLSubSys::runParser(handler, districtfile)) { PROGRESS_FAILED_MESSAGE(); } else { PROGRESS_DONE_MESSAGE(); } }
void ODMatrix::loadRoutes(OptionsCont& oc, SUMOSAXHandler& handler) { std::vector<std::string> routeFiles = oc.getStringVector("route-files"); for (std::vector<std::string>::iterator i = routeFiles.begin(); i != routeFiles.end(); ++i) { if (!FileHelpers::isReadable(*i)) { throw ProcessError("Could not access route file '" + *i + "' to load."); } PROGRESS_BEGIN_MESSAGE("Loading routes and trips from '" + *i + "'"); if (!XMLSubSys::runParser(handler, *i)) { PROGRESS_FAILED_MESSAGE(); } else { PROGRESS_DONE_MESSAGE(); } } }
// =========================================================================== // method definitions // =========================================================================== void AGActivityGen::importInfoCity() { AGActivityGenHandler handler(city, net); PROGRESS_BEGIN_MESSAGE("Reading input"); if (!XMLSubSys::runParser(handler, inputFile)) { PROGRESS_FAILED_MESSAGE(); throw ProcessError(); } else { PROGRESS_DONE_MESSAGE(); } PROGRESS_BEGIN_MESSAGE("Consolidating statistics"); city.statData.consolidateStat(); //some maps are still not PROGRESS_DONE_MESSAGE(); PROGRESS_BEGIN_MESSAGE("Building street representation"); city.completeStreets(); PROGRESS_DONE_MESSAGE(); PROGRESS_BEGIN_MESSAGE("Generating work positions"); city.generateWorkPositions(); PROGRESS_DONE_MESSAGE(); PROGRESS_BEGIN_MESSAGE("Building bus lines"); city.completeBusLines(); PROGRESS_DONE_MESSAGE(); PROGRESS_BEGIN_MESSAGE("Generating population"); city.generatePopulation(); PROGRESS_DONE_MESSAGE(); PROGRESS_BEGIN_MESSAGE("Allocating schools"); city.schoolAllocation(); PROGRESS_DONE_MESSAGE(); PROGRESS_BEGIN_MESSAGE("Allocating work places"); city.workAllocation(); PROGRESS_DONE_MESSAGE(); PROGRESS_BEGIN_MESSAGE("Allocating car places"); city.carAllocation(); PROGRESS_DONE_MESSAGE(); }
void ODMatrix::loadMatrix(OptionsCont& oc) { std::vector<std::string> files = oc.getStringVector("od-matrix-files"); for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) { LineReader lr(*i); if (!lr.good()) { throw ProcessError("Could not open '" + (*i) + "'."); } std::string type = lr.readLine(); // get the type only if (type.find(';') != std::string::npos) { type = type.substr(0, type.find(';')); } // parse type-dependant if (type.length() > 1 && type[1] == 'V') { // process ptv's 'V'-matrices if (type.find('N') != std::string::npos) { throw ProcessError("'" + *i + "' does not contain the needed information about the time described."); } readV(lr, oc.getFloat("scale"), oc.getString("vtype"), type.find('M') != std::string::npos); } else if (type.length() > 1 && type[1] == 'O') { // process ptv's 'O'-matrices if (type.find('N') != std::string::npos) { throw ProcessError("'" + *i + "' does not contain the needed information about the time described."); } readO(lr, oc.getFloat("scale"), oc.getString("vtype"), type.find('M') != std::string::npos); } else { throw ProcessError("'" + *i + "' uses an unknown matrix type '" + type + "'."); } } std::vector<std::string> amitranFiles = oc.getStringVector("od-amitran-files"); for (std::vector<std::string>::iterator i = amitranFiles.begin(); i != amitranFiles.end(); ++i) { if (!FileHelpers::isReadable(*i)) { throw ProcessError("Could not access matrix file '" + *i + "' to load."); } PROGRESS_BEGIN_MESSAGE("Loading matrix in Amitran format from '" + *i + "'"); ODAmitranHandler handler(*this, *i); if (!XMLSubSys::runParser(handler, *i)) { PROGRESS_FAILED_MESSAGE(); } else { PROGRESS_DONE_MESSAGE(); } } }
/* ------------------------------------------------------------------------- * data processing methods * ----------------------------------------------------------------------- */ void readDetectors(RODFDetectorCon& detectors, OptionsCont& oc, RODFNet* optNet) { if (!oc.isSet("detector-files")) { throw ProcessError("No detector file given (use --detector-files <FILE>)."); } // read definitions stored in XML-format std::vector<std::string> files = oc.getStringVector("detector-files"); for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { if (!FileHelpers::exists(*fileIt)) { throw ProcessError("Could not open detector file '" + *fileIt + "'"); } PROGRESS_BEGIN_MESSAGE("Loading detector definitions from '" + *fileIt + "'"); RODFDetectorHandler handler(optNet, oc.getBool("ignore-invalid-detectors"), detectors, *fileIt); if (XMLSubSys::runParser(handler, *fileIt)) { PROGRESS_DONE_MESSAGE(); } else { PROGRESS_FAILED_MESSAGE(); throw ProcessError(); } } if (detectors.getDetectors().empty()) { throw ProcessError("No detectors found."); } }