/* ------------------------------------------------------------------------- * main * ----------------------------------------------------------------------- */ int main(int argc, char **argv) { OptionsCont &oc = OptionsCont::getOptions(); // give some application descriptions oc.setApplicationDescription("Router for the microscopic road traffic simulation SUMO based on junction turning ratios."); oc.setApplicationName("jtrrouter", "SUMO jtrrouter Version " + (std::string)VERSION_STRING); int ret = 0; RONet *net = 0; try { // initialise the application system (messaging, xml, options) XMLSubSys::init(false); ROJTRFrame::fillOptions(); OptionsIO::getOptions(true, argc, argv); if (oc.processMetaOptions(argc < 2)) { SystemFrame::close(); return 0; } MsgHandler::initOutputOptions(); if (!ROJTRFrame::checkOptions()) throw ProcessError(); RandHelper::initRandGlobal(); std::vector<SUMOReal> defs = getTurningDefaults(oc); // load data ROLoader loader(oc, true); net = new RONet(); initNet(*net, loader, oc, defs); try { // parse and set the turn defaults first loadJTRDefinitions(*net, oc); // build routes computeRoutes(*net, loader, oc); } catch (SAXParseException &e) { MsgHandler::getErrorInstance()->inform(toString(e.getLineNumber())); ret = 1; } catch (SAXException &e) { MsgHandler::getErrorInstance()->inform(TplConvert<XMLCh>::_2str(e.getMessage())); ret = 1; } if (MsgHandler::getErrorInstance()->wasInformed()) { throw ProcessError(); } } catch (ProcessError &e) { if (std::string(e.what())!=std::string("Process Error") && std::string(e.what())!=std::string("")) { MsgHandler::getErrorInstance()->inform(e.what()); } MsgHandler::getErrorInstance()->inform("Quitting (on error).", false); ret = 1; #ifndef _DEBUG } catch (...) { MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false); ret = 1; #endif } delete net; OutputDevice::closeAll(); SystemFrame::close(); if (ret==0) { std::cout << "Success." << std::endl; } return ret; }
/* ------------------------------------------------------------------------- * main * ----------------------------------------------------------------------- */ int main(int argc, char** argv) { OptionsCont& oc = OptionsCont::getOptions(); // give some application descriptions oc.setApplicationDescription("Router for the microscopic, multi-modal traffic simulation SUMO based on junction turning ratios."); oc.setApplicationName("jtrrouter", "Eclipse SUMO jtrrouter Version " VERSION_STRING); int ret = 0; RONet* net = 0; try { // initialise the application system (messaging, xml, options) XMLSubSys::init(); ROJTRFrame::fillOptions(); OptionsIO::setArgs(argc, argv); OptionsIO::getOptions(); if (oc.processMetaOptions(argc < 2)) { SystemFrame::close(); return 0; } XMLSubSys::setValidation(oc.getString("xml-validation"), oc.getString("xml-validation.net")); MsgHandler::initOutputOptions(); if (!(ROJTRFrame::checkOptions() && SystemFrame::checkOptions())) { throw ProcessError(); } RandHelper::initRandGlobal(); std::vector<double> defs = getTurningDefaults(oc); // load data ROLoader loader(oc, true, !oc.getBool("no-step-log")); net = new RONet(); initNet(*net, loader, defs); try { // parse and set the turn defaults first loadJTRDefinitions(*net, oc); // build routes computeRoutes(*net, loader, oc); } catch (XERCES_CPP_NAMESPACE::SAXParseException& e) { WRITE_ERROR(toString(e.getLineNumber())); ret = 1; } catch (XERCES_CPP_NAMESPACE::SAXException& e) { WRITE_ERROR(TplConvert::_2str(e.getMessage())); ret = 1; } if (MsgHandler::getErrorInstance()->wasInformed()) { throw ProcessError(); } } catch (const ProcessError& e) { if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) { WRITE_ERROR(e.what()); } MsgHandler::getErrorInstance()->inform("Quitting (on error).", false); ret = 1; #ifndef _DEBUG } catch (const std::exception& e) { if (std::string(e.what()) != std::string("")) { WRITE_ERROR(e.what()); } MsgHandler::getErrorInstance()->inform("Quitting (on error).", false); ret = 1; } catch (...) { MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false); ret = 1; #endif } delete net; SystemFrame::close(); if (ret == 0) { std::cout << "Success." << std::endl; } return ret; }