43 #include <xercesc/parsers/SAXParser.hpp>
44 #include <xercesc/sax2/SAX2XMLReader.hpp>
66 #ifdef CHECK_MEMORY_LEAKS
68 #endif // CHECK_MEMORY_LEAKS
77 oc.
addCallExample(
"-c <CONFIGURATION>",
"run with configuration file");
92 oc.
addDescription(
"net-file",
"Input",
"Loads network (districts) from FILE");
97 oc.
addDescription(
"od-matrix-files",
"Input",
"Loads O/D-files from FILE(s)");
103 oc.
addDescription(
"output-file",
"Output",
"Writes trip definitions into FILE");
106 oc.
addSynonyme(
"ignore-vehicle-type",
"no-vtype",
true);
107 oc.
addDescription(
"ignore-vehicle-type",
"Output",
"Does not save vtype information");
112 oc.
addDescription(
"begin",
"Time",
"Defines the begin time; Previous trips will be discarded");
115 oc.
addDescription(
"end",
"Time",
"Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
120 oc.
addDescription(
"scale",
"Processing",
"Scales the loaded flows by FLOAT");
123 oc.
addDescription(
"spread.uniform",
"Processing",
"Spreads trips uniformly over each time period");
126 oc.
addDescription(
"vtype",
"Processing",
"Defines the name of the vehicle type to use");
129 oc.
addDescription(
"prefix",
"Processing",
"Defines the prefix for vehicle names");
132 oc.
addDescription(
"timeline",
"Processing",
"Uses STR as a timeline definition");
135 oc.
addDescription(
"timeline.day-in-hours",
"Processing",
"Uses STR as a 24h-timeline definition");
138 oc.
addDescription(
"dismiss-loading-errors",
"Processing",
"Continue on broken input");
141 oc.
addDescription(
"no-step-log",
"Processing",
"Disable console output of current time step");
146 oc.
addDescription(
"departlane",
"Defaults",
"Assigns a default depart lane");
149 oc.
addDescription(
"departpos",
"Defaults",
"Assigns a default depart position");
152 oc.
addDescription(
"departspeed",
"Defaults",
"Assigns a default depart speed");
155 oc.
addDescription(
"arrivallane",
"Defaults",
"Assigns a default arrival lane");
158 oc.
addDescription(
"arrivalpos",
"Defaults",
"Assigns a default arrival position");
161 oc.
addDescription(
"arrivalspeed",
"Defaults",
"Assigns a default arrival speed");
169 parseTimeLine(
const std::vector<std::string>& def,
bool timelineDayInHours) {
170 bool interpolating = !timelineDayInHours;
173 if (timelineDayInHours) {
174 if (def.size() != 24) {
175 throw ProcessError(
"Assuming 24 entries for a day timeline, but got " +
toString(def.size()) +
".");
177 for (
int chour = 0; chour < 24; ++chour) {
184 while (i < def.size()) {
186 if (st2.
size() != 2) {
187 throw ProcessError(
"Broken time line definition: missing a value in '" + def[i - 1] +
"'.");
202 if (!oc.
isSet(
"net-file")) {
206 if (!oc.
isSet(
"od-matrix-files")) {
210 if (!oc.
isSet(
"output-file")) {
211 WRITE_ERROR(
"No trip table output file (-o) specified.");
248 if (!oc.
isSet(
"net-file")) {
253 std::string file = oc.
getString(
"net-file");
255 throw ProcessError(
"Could not find network '" + file +
"' to load.");
273 if (line[0] !=
'*') {
283 if (time.find(
'.') == std::string::npos) {
286 std::string hours = time.substr(0, time.find(
'.'));
287 std::string minutes = time.substr(time.find(
'.') + 1);
292 std::pair<SUMOTime, SUMOTime>
300 throw ProcessError(
"Begin time is larger than end time.");
302 return std::make_pair(begin, end);
304 throw ProcessError(
"Broken period definition '" + line +
"'.");
306 throw ProcessError(
"Broken period definition '" + line +
"'.");
327 std::string vehType,
bool matrixHasVehType) {
331 if (matrixHasVehType) {
339 std::pair<SUMOTime, SUMOTime> times =
readTime(lr);
350 std::vector<std::string> names;
355 names.push_back(st2.
next());
357 }
while ((
int) names.size() != districtNo);
360 for (std::vector<std::string>::iterator si = names.begin(); si != names.end(); ++si) {
361 std::vector<std::string>::iterator di = names.begin();
365 if (line.length() == 0) {
371 assert(di != names.end());
373 if (vehNumber != 0) {
374 into.
add(vehNumber, begin, end, *si, *di, vehType);
376 if (di == names.end()) {
377 throw ProcessError(
"More entries than districts found.");
382 throw ProcessError(
"Not numeric vehicle number in line '" + line +
"'.");
387 }
while (di != names.end());
395 std::string vehType,
bool matrixHasVehType) {
399 if (matrixHasVehType) {
408 std::pair<SUMOTime, SUMOTime> times =
readTime(lr);
418 if (line.length() == 0) {
422 if (st2.
size() == 0) {
426 std::string sourceD = st2.
next();
427 std::string destD = st2.
next();
429 if (vehNumber != 0) {
430 into.
add(vehNumber, begin, end, sourceD, destD, vehType);
433 throw ProcessError(
"Missing at least one information in line '" + line +
"'.");
435 throw ProcessError(
"Not numeric vehicle number in line '" + line +
"'.");
446 if (files.size() == 0) {
450 for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) {
457 if (type.find(
';') != std::string::npos) {
458 type = type.substr(0, type.find(
';'));
461 if (type.length() > 1 && type[1] ==
'V') {
463 if (type.find(
'N') != std::string::npos) {
464 throw ProcessError(
"'" + *i +
"' does not contain the needed information about the time described.");
467 }
else if (type.length() > 1 && type[1] ==
'O') {
469 if (type.find(
'N') != std::string::npos) {
470 throw ProcessError(
"'" + *i +
"' does not contain the needed information about the time described.");
474 throw ProcessError(
"'" + *i +
"' uses an unknown matrix type '" + type +
"'.");
508 if (districts.
size() == 0) {
522 if (oc.
isSet(
"timeline")) {
531 dev, oc.
getBool(
"spread.uniform"), oc.
getBool(
"ignore-vehicle-type"),
536 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
542 }
catch (
const std::exception& e) {
543 if (std::string(e.what()) != std::string(
"")) {
555 std::cout <<
"Success." << std::endl;