Definition in file duarouter_main.cpp.
#include <config.h>
#include <xercesc/sax/SAXException.hpp>
#include <xercesc/sax/SAXParseException.hpp>
#include <utils/common/TplConvert.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <ctime>
#include <router/ROLoader.h>
#include <router/RONet.h>
#include <router/ROEdge.h>
#include <utils/common/DijkstraRouterTT.h>
#include <utils/common/DijkstraRouterEffort.h>
#include "RODUAEdgeBuilder.h"
#include <router/ROFrame.h>
#include <utils/common/MsgHandler.h>
#include <utils/options/Option.h>
#include <utils/options/OptionsCont.h>
#include <utils/options/OptionsIO.h>
#include <utils/common/UtilExceptions.h>
#include <utils/common/SystemFrame.h>
#include <utils/common/RandHelper.h>
#include <utils/common/ToString.h>
#include <utils/xml/XMLSubSys.h>
#include "RODUAFrame.h"
#include <utils/iodevices/OutputDevice.h>
Go to the source code of this file.
Functions | |
| void | computeRoutes (RONet &net, ROLoader &loader, OptionsCont &oc) |
| void | initNet (RONet &net, ROLoader &loader, OptionsCont &oc) |
| int | main (int argc, char **argv) |
| void computeRoutes | ( | RONet & | net, | |
| ROLoader & | loader, | |||
| OptionsCont & | oc | |||
| ) |
Computes the routes saving them
Definition at line 96 of file duarouter_main.cpp.
References RONet::closeOutput(), OptionsCont::getBool(), ROEdge::getCO2Effort(), ROEdge::getCOEffort(), RONet::getEdgeNo(), ROEdge::getFuelEffort(), ROEdge::getHCEffort(), ROEdge::getNoiseEffort(), ROEdge::getNOxEffort(), ROEdge::getPMxEffort(), OptionsCont::getString(), ROEdge::getTravelTime(), RONet::hasRestrictions(), RONet::openOutput(), ROLoader::openRoutes(), ROLoader::processAllRoutes(), ROLoader::processRoutesStepWise(), and string2time().
Referenced by main().
00096 { 00097 // initialise the loader 00098 loader.openRoutes(net); 00099 // prepare the output 00100 try { 00101 net.openOutput(oc.getString("output"), true); 00102 } catch (IOError &e) { 00103 throw e; 00104 } 00105 // build the router 00106 SUMOAbstractRouter<ROEdge, ROVehicle> *router; 00107 std::string measure = oc.getString("measure"); 00108 if (measure=="traveltime") { 00109 if (net.hasRestrictions()) { 00110 router = new DijkstraRouterTT_Direct<ROEdge, ROVehicle, prohibited_withRestrictions<ROEdge, ROVehicle> >( 00111 net.getEdgeNo(), oc.getBool("continue-on-unbuild"), &ROEdge::getTravelTime); 00112 } else { 00113 router = new DijkstraRouterTT_Direct<ROEdge, ROVehicle, prohibited_noRestrictions<ROEdge, ROVehicle> >( 00114 net.getEdgeNo(), oc.getBool("continue-on-unbuild"), &ROEdge::getTravelTime); 00115 } 00116 } else { 00117 DijkstraRouterEffort_Direct<ROEdge, ROVehicle, prohibited_withRestrictions<ROEdge, ROVehicle> >::Operation op; 00118 if (measure=="CO") { 00119 op = &ROEdge::getCOEffort; 00120 } else if (measure=="CO2") { 00121 op = &ROEdge::getCO2Effort; 00122 } else if (measure=="PMx") { 00123 op = &ROEdge::getPMxEffort; 00124 } else if (measure=="HC") { 00125 op = &ROEdge::getHCEffort; 00126 } else if (measure=="NOx") { 00127 op = &ROEdge::getNOxEffort; 00128 } else if (measure=="fuel") { 00129 op = &ROEdge::getFuelEffort; 00130 } else if (measure=="noise") { 00131 op = &ROEdge::getNoiseEffort; 00132 } 00133 if (net.hasRestrictions()) { 00134 router = new DijkstraRouterEffort_Direct<ROEdge, ROVehicle, prohibited_withRestrictions<ROEdge, ROVehicle> >( 00135 net.getEdgeNo(), oc.getBool("continue-on-unbuild"), op, &ROEdge::getTravelTime); 00136 } else { 00137 router = new DijkstraRouterEffort_Direct<ROEdge, ROVehicle, prohibited_noRestrictions<ROEdge, ROVehicle> >( 00138 net.getEdgeNo(), oc.getBool("continue-on-unbuild"), op, &ROEdge::getTravelTime); 00139 } 00140 } 00141 // process route definitions 00142 try { 00143 // the routes are sorted - process stepwise 00144 if (!oc.getBool("unsorted")) { 00145 loader.processRoutesStepWise(string2time(oc.getString("begin")), string2time(oc.getString("end")), net, *router); 00146 } 00147 // the routes are not sorted: load all and process 00148 else { 00149 loader.processAllRoutes(string2time(oc.getString("begin")), string2time(oc.getString("end")), net, *router); 00150 } 00151 // end the processing 00152 net.closeOutput(); 00153 delete router; 00154 } catch (ProcessError &) { 00155 net.closeOutput(); 00156 delete router; 00157 throw; 00158 } 00159 }
| void initNet | ( | RONet & | net, | |
| ROLoader & | loader, | |||
| OptionsCont & | oc | |||
| ) |
loads the net The net is in this meaning made up by the net itself and the dynamic weights which may be supplied in a separate file
Definition at line 77 of file duarouter_main.cpp.
References OptionsCont::getBool(), OptionsCont::getString(), OptionsCont::isSet(), ROLoader::loadNet(), and ROLoader::loadWeights().
Referenced by main().
00077 { 00078 // load the net 00079 RODUAEdgeBuilder builder(oc.getBool("expand-weights"), oc.getBool("interpolate")); 00080 loader.loadNet(net, builder); 00081 // load the weights when wished/available 00082 if (oc.isSet("weights")) { 00083 loader.loadWeights(net, "weights", oc.getString("measure"), false); 00084 } 00085 if (oc.isSet("lane-weights")) { 00086 loader.loadWeights(net, "lane-weights", oc.getString("measure"), true); 00087 } 00088 }
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 166 of file duarouter_main.cpp.
References RODUAFrame::checkOptions(), SystemFrame::close(), OutputDevice::closeAll(), computeRoutes(), RODUAFrame::fillOptions(), MsgHandler::getErrorInstance(), OptionsIO::getOptions(), OptionsCont::getOptions(), MsgHandler::inform(), XMLSubSys::init(), initNet(), MsgHandler::initOutputOptions(), RandHelper::initRandGlobal(), OptionsCont::processMetaOptions(), OptionsCont::setApplicationDescription(), OptionsCont::setApplicationName(), toString(), and MsgHandler::wasInformed().
00166 { 00167 OptionsCont &oc = OptionsCont::getOptions(); 00168 // give some application descriptions 00169 oc.setApplicationDescription("Shortest path router and DUE computer for the microscopic road traffic simulation SUMO."); 00170 oc.setApplicationName("duarouter", "SUMO duarouter Version " + (std::string)VERSION_STRING); 00171 int ret = 0; 00172 RONet *net = 0; 00173 try { 00174 XMLSubSys::init(false); 00175 RODUAFrame::fillOptions(); 00176 OptionsIO::getOptions(true, argc, argv); 00177 if (oc.processMetaOptions(argc < 2)) { 00178 SystemFrame::close(); 00179 return 0; 00180 } 00181 MsgHandler::initOutputOptions(); 00182 if (!RODUAFrame::checkOptions()) throw ProcessError(); 00183 RandHelper::initRandGlobal(); 00184 // load data 00185 ROLoader loader(oc, false); 00186 net = new RONet(); 00187 initNet(*net, loader, oc); 00188 // build routes 00189 try { 00190 computeRoutes(*net, loader, oc); 00191 } catch (SAXParseException &e) { 00192 MsgHandler::getErrorInstance()->inform(toString(e.getLineNumber())); 00193 ret = 1; 00194 } catch (SAXException &e) { 00195 MsgHandler::getErrorInstance()->inform(TplConvert<XMLCh>::_2str(e.getMessage())); 00196 ret = 1; 00197 } 00198 if (MsgHandler::getErrorInstance()->wasInformed()||ret!=0) { 00199 throw ProcessError(); 00200 } 00201 } catch (ProcessError &e) { 00202 if (std::string(e.what())!=std::string("Process Error") && std::string(e.what())!=std::string("")) { 00203 MsgHandler::getErrorInstance()->inform(e.what()); 00204 } 00205 MsgHandler::getErrorInstance()->inform("Quitting (on error).", false); 00206 ret = 1; 00207 #ifndef _DEBUG 00208 } catch (...) { 00209 MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false); 00210 ret = 1; 00211 #endif 00212 } 00213 delete net; 00214 OutputDevice::closeAll(); 00215 SystemFrame::close(); 00216 if (ret==0) { 00217 std::cout << "Success." << std::endl; 00218 } 00219 return ret; 00220 }
1.5.6