53 #ifdef CHECK_MEMORY_LEAKS
55 #endif // CHECK_MEMORY_LEAKS
62 : myDistricts(dc), myNoLoaded(0), myNoWritten(0), myNoDiscarded(0) {}
75 SUMOTime end,
const std::string& origin,
const std::string& destination,
76 const std::string& vehicleType) {
79 WRITE_WARNING(
"Missing origin '" + origin +
"' and destination '" + destination +
"' (" +
toString(vehicleNumber) +
" vehicles).");
83 }
else if (
myDistricts.
get(destination) == 0 && vehicleNumber > 0) {
84 WRITE_ERROR(
"Missing destination '" + destination +
"' (" +
toString(vehicleNumber) +
" vehicles).");
88 WRITE_ERROR(
"District '" + origin +
"' has no source.");
91 WRITE_ERROR(
"District '" + destination +
"' has no sink.");
109 size_t& vehName, std::vector<ODVehicle>& into,
110 bool uniform,
const std::string& prefix) {
116 if (vehicles2insert == 0) {
121 for (
int i = 0; i < vehicles2insert; ++i) {
142 const ODCell*
const cell) {
148 if (oc.
isSet(
"departlane") && oc.
getString(
"departlane") !=
"default") {
151 if (oc.
isSet(
"departpos")) {
154 if (oc.
isSet(
"departspeed") && oc.
getString(
"departspeed") !=
"default") {
157 if (oc.
isSet(
"arrivallane")) {
160 if (oc.
isSet(
"arrivalpos")) {
163 if (oc.
isSet(
"arrivalspeed")) {
171 OutputDevice& dev,
const bool uniform,
const bool noVtype,
172 const std::string& prefix,
const bool stepLog) {
176 std::map<std::pair<std::string, std::string>,
SUMOReal> fractionLeft;
181 std::vector<ODCell*>::iterator next =
myContainer.begin();
182 std::vector<ODVehicle> vehicles;
185 for (
SUMOTime t = begin; t != end;) {
186 if (stepLog && t - lastOut >=
DELTA_T) {
187 std::cout <<
"Parsing time " +
time2string(t) <<
'\r';
191 bool changed =
false;
192 while (next !=
myContainer.end() && (*next)->begin <= t && (*next)->end > t) {
193 std::pair<std::string, std::string> odID = std::make_pair((*next)->origin, (*next)->destination);
195 if (fractionLeft.find(odID) != fractionLeft.end()) {
196 (*next)->vehicleNumber += fractionLeft[odID];
197 fractionLeft[odID] = 0;
200 const size_t oldSize = vehicles.size();
202 if (oldSize != vehicles.size()) {
206 fractionLeft[odID] = fraction;
213 for (std::vector<ODVehicle>::reverse_iterator i = vehicles.rbegin(); i != vehicles.rend() && (*i).depart == t; ++i) {
220 while (vehicles.size() != 0 && vehicles.back().depart == t) {
223 if (!vehicles.empty()) {
224 t = vehicles.back().depart;
226 if (next !=
myContainer.end() && (t > (*next)->begin || vehicles.empty())) {
229 if (next ==
myContainer.end() && vehicles.empty()) {
239 const std::string& prefix) {
247 const ODCell*
const c = *i;
248 if (c->
end > begin && c->
begin < end) {
264 if (line[0] !=
'*') {
274 if (time.find(
'.') == std::string::npos) {
277 std::string hours = time.substr(0, time.find(
'.'));
278 std::string minutes = time.substr(time.find(
'.') + 1);
283 std::pair<SUMOTime, SUMOTime>
291 throw ProcessError(
"Begin time is larger than end time.");
293 return std::make_pair(begin, end);
295 throw ProcessError(
"Broken period definition '" + line +
"'.");
297 throw ProcessError(
"Broken period definition '" + line +
"'.");
315 std::string vehType,
bool matrixHasVehType) {
319 if (matrixHasVehType) {
327 std::pair<SUMOTime, SUMOTime> times =
readTime(lr);
338 std::vector<std::string> names;
343 names.push_back(st2.
next());
345 }
while ((
int) names.size() != districtNo);
348 for (std::vector<std::string>::iterator si = names.begin(); si != names.end(); ++si) {
349 std::vector<std::string>::iterator di = names.begin();
353 if (line.length() == 0) {
359 assert(di != names.end());
361 if (vehNumber != 0) {
362 add(vehNumber, begin, end, *si, *di, vehType);
364 if (di == names.end()) {
365 throw ProcessError(
"More entries than districts found.");
370 throw ProcessError(
"Not numeric vehicle number in line '" + line +
"'.");
375 }
while (di != names.end());
383 std::string vehType,
bool matrixHasVehType) {
387 if (matrixHasVehType) {
396 std::pair<SUMOTime, SUMOTime> times =
readTime(lr);
406 if (line.length() == 0) {
410 if (st2.
size() == 0) {
414 std::string sourceD = st2.
next();
415 std::string destD = st2.
next();
417 if (vehNumber != 0) {
418 add(vehNumber, begin, end, sourceD, destD, vehType);
421 throw ProcessError(
"Missing at least one information in line '" + line +
"'.");
423 throw ProcessError(
"Not numeric vehicle number in line '" + line +
"'.");
451 for (
size_t i = 0; i < ps.
getAreaNo(); ++i) {
459 newCells.push_back(ncell);
468 for (std::vector<ODCell*>::iterator i = oldCells.begin(); i != oldCells.end(); ++i) {
469 std::vector<ODCell*> newCells;
471 copy(newCells.begin(), newCells.end(), back_inserter(
myContainer));
478 std::vector<std::string> files = oc.
getStringVector(
"od-matrix-files");
479 for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) {
486 if (type.find(
';') != std::string::npos) {
487 type = type.substr(0, type.find(
';'));
490 if (type.length() > 1 && type[1] ==
'V') {
492 if (type.find(
'N') != std::string::npos) {
493 throw ProcessError(
"'" + *i +
"' does not contain the needed information about the time described.");
496 }
else if (type.length() > 1 && type[1] ==
'O') {
498 if (type.find(
'N') != std::string::npos) {
499 throw ProcessError(
"'" + *i +
"' does not contain the needed information about the time described.");
503 throw ProcessError(
"'" + *i +
"' uses an unknown matrix type '" + type +
"'.");
506 std::vector<std::string> amitranFiles = oc.
getStringVector(
"od-amitran-files");
507 for (std::vector<std::string>::iterator i = amitranFiles.begin(); i != amitranFiles.end(); ++i) {
509 throw ProcessError(
"Could not access matrix file '" + *i +
"' to load.");
524 bool interpolating = !timelineDayInHours;
527 if (timelineDayInHours) {
528 if (def.size() != 24) {
529 throw ProcessError(
"Assuming 24 entries for a day timeline, but got " +
toString(def.size()) +
".");
531 for (
int chour = 0; chour < 24; ++chour) {
538 while (i < def.size()) {
540 if (st2.
size() != 2) {
541 throw ProcessError(
"Broken time line definition: missing a value in '" + def[i - 1] +
"'.");