43 #include <xercesc/parsers/SAXParser.hpp>
44 #include <xercesc/sax2/SAX2XMLReader.hpp>
68 #ifdef CHECK_MEMORY_LEAKS
70 #endif // CHECK_MEMORY_LEAKS
79 oc.
addCallExample(
"-c <CONFIGURATION>",
"run with configuration file");
94 oc.
addDescription(
"net-file",
"Input",
"Loads network (districts) from FILE");
99 oc.
addDescription(
"od-matrix-files",
"Input",
"Loads O/D-files from FILE(s)");
105 oc.
addDescription(
"output-file",
"Output",
"Writes trip definitions into FILE");
108 oc.
addSynonyme(
"ignore-vehicle-type",
"no-vtype",
true);
109 oc.
addDescription(
"ignore-vehicle-type",
"Output",
"Does not save vtype information");
114 oc.
addDescription(
"begin",
"Time",
"Defines the begin time; Previous trips will be discarded");
117 oc.
addDescription(
"end",
"Time",
"Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent");
122 oc.
addDescription(
"scale",
"Processing",
"Scales the loaded flows by FLOAT");
125 oc.
addDescription(
"spread.uniform",
"Processing",
"Spreads trips uniformly over each time period");
128 oc.
addDescription(
"vtype",
"Processing",
"Defines the name of the vehicle type to use");
131 oc.
addDescription(
"prefix",
"Processing",
"Defines the prefix for vehicle names");
134 oc.
addDescription(
"timeline",
"Processing",
"Uses STR as a timeline definition");
137 oc.
addDescription(
"timeline.day-in-hours",
"Processing",
"Uses STR as a 24h-timeline definition");
140 oc.
addDescription(
"dismiss-loading-errors",
"Processing",
"Continue on broken input");
143 oc.
addDescription(
"no-step-log",
"Processing",
"Disable console output of current time step");
148 oc.
addDescription(
"departlane",
"Defaults",
"Assigns a default depart lane");
151 oc.
addDescription(
"departpos",
"Defaults",
"Assigns a default depart position");
154 oc.
addDescription(
"departspeed",
"Defaults",
"Assigns a default depart speed");
157 oc.
addDescription(
"arrivallane",
"Defaults",
"Assigns a default arrival lane");
160 oc.
addDescription(
"arrivalpos",
"Defaults",
"Assigns a default arrival position");
163 oc.
addDescription(
"arrivalspeed",
"Defaults",
"Assigns a default arrival speed");
171 parseTimeLine(
const std::vector<std::string> &def,
bool timelineDayInHours) {
172 bool interpolating = !timelineDayInHours;
175 if (timelineDayInHours) {
176 if (def.size() != 24) {
177 throw ProcessError(
"Assuming 24 entries for a day timeline, but got " +
toString(def.size()) +
".");
179 for (
int chour = 0; chour < 24; ++chour) {
186 while (i < def.size()) {
188 if (st2.
size() != 2) {
189 throw ProcessError(
"Broken time line definition: missing a value in '" + def[i - 1] +
"'.");
204 if (!oc.
isSet(
"net-file")) {
208 if (!oc.
isSet(
"od-matrix-files")) {
212 if (!oc.
isSet(
"output-file")) {
213 WRITE_ERROR(
"No trip table output file (-o) specified.");
230 if (!oc.
isSet(
"net-file")) {
235 std::string file = oc.
getString(
"net-file");
237 throw ProcessError(
"Could not find network '" + file +
"' to load.");
255 if (line[0] !=
'*') {
265 if (time.find(
'.') == std::string::npos) {
268 std::string hours = time.substr(0, time.find(
'.'));
269 std::string minutes = time.substr(time.find(
'.') + 1);
274 std::pair<SUMOTime, SUMOTime>
282 throw ProcessError(
"Begin time is larger than end time.");
284 return std::make_pair(begin, end);
286 throw ProcessError(
"Broken period definition '" + line +
"'.");
288 throw ProcessError(
"Broken period definition '" + line +
"'.");
309 std::string vehType,
bool matrixHasVehType) {
313 if (matrixHasVehType) {
321 std::pair<SUMOTime, SUMOTime> times =
readTime(lr);
332 std::vector<std::string> names;
337 names.push_back(st2.
next());
339 }
while ((
int) names.size() != districtNo);
342 for (std::vector<std::string>::iterator si = names.begin(); si != names.end(); ++si) {
343 std::vector<std::string>::iterator di = names.begin();
347 if (line.length() == 0) {
353 assert(di != names.end());
355 if (vehNumber != 0) {
356 into.
add(vehNumber, begin, end, *si, *di, vehType);
358 if (di == names.end()) {
359 throw ProcessError(
"More entries than districts found.");
364 throw ProcessError(
"Not numeric vehicle number in line '" + line +
"'.");
369 }
while (di != names.end());
377 std::string vehType,
bool matrixHasVehType) {
381 if (matrixHasVehType) {
390 std::pair<SUMOTime, SUMOTime> times =
readTime(lr);
400 if (line.length() == 0) {
404 if (st2.
size() == 0) {
408 std::string sourceD = st2.
next();
409 std::string destD = st2.
next();
411 if (vehNumber != 0) {
412 into.
add(vehNumber, begin, end, sourceD, destD, vehType);
415 throw ProcessError(
"Missing at least one information in line '" + line +
"'.");
417 throw ProcessError(
"Not numeric vehicle number in line '" + line +
"'.");
428 if (files.size() == 0) {
432 for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) {
439 if (type.find(
';') != std::string::npos) {
440 type = type.substr(0, type.find(
';'));
443 if (type.length() > 1 && type[1] ==
'V') {
445 if (type.find(
'N') != std::string::npos) {
446 throw ProcessError(
"'" + *i +
"' does not contain the needed information about the time described.");
449 }
else if (type.length() > 1 && type[1] ==
'O') {
451 if (type.find(
'N') != std::string::npos) {
452 throw ProcessError(
"'" + *i +
"' does not contain the needed information about the time described.");
456 throw ProcessError(
"'" + *i +
"' uses an unknown matrix type '" + type +
"'.");
490 if (districts.
size() == 0) {
504 if (oc.
isSet(
"timeline")) {
517 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
531 std::cout <<
"Success." << std::endl;