50 #ifdef CHECK_MEMORY_LEAKS
52 #endif // CHECK_MEMORY_LEAKS
59 : myDistricts(dc), myNoLoaded(0), myNoWritten(0), myNoDiscarded(0) {}
72 SUMOTime end,
const std::string& origin,
const std::string& destination,
73 const std::string& vehicleType) {
76 WRITE_WARNING(
"Missing origin '" + origin +
"' and destination '" + destination +
"' (" +
toString(vehicleNumber) +
" vehicles).");
80 }
else if (
myDistricts.
get(destination) == 0 && vehicleNumber > 0) {
81 WRITE_ERROR(
"Missing destination '" + destination +
"' (" +
toString(vehicleNumber) +
" vehicles).");
85 WRITE_ERROR(
"District '" + origin +
"' has no source.");
88 WRITE_ERROR(
"District '" + destination +
"' has no sink.");
106 size_t& vehName, std::vector<ODVehicle>& into,
107 bool uniform,
const std::string& prefix) {
116 for (
int i = 0; i < vehicles2insert; ++i) {
137 const ODCell*
const cell) {
143 if (oc.
isSet(
"departlane") && oc.
getString(
"departlane") !=
"default") {
146 if (oc.
isSet(
"departpos")) {
149 if (oc.
isSet(
"departspeed") && oc.
getString(
"departspeed") !=
"default") {
152 if (oc.
isSet(
"arrivallane")) {
155 if (oc.
isSet(
"arrivalpos")) {
158 if (oc.
isSet(
"arrivalspeed")) {
166 OutputDevice& dev,
const bool uniform,
const bool noVtype,
167 const std::string& prefix,
const bool stepLog) {
171 std::map<std::pair<std::string, std::string>,
SUMOReal> fractionLeft;
176 std::vector<ODCell*>::iterator next =
myContainer.begin();
177 std::vector<ODVehicle> vehicles;
180 for (
SUMOTime t = begin; t != end;) {
181 if (stepLog && t - lastOut >=
DELTA_T) {
182 std::cout <<
"Parsing time " +
time2string(t) <<
'\r';
186 bool changed =
false;
187 while (next !=
myContainer.end() && (*next)->begin <= t && (*next)->end > t) {
188 std::pair<std::string, std::string> odID = std::make_pair((*next)->origin, (*next)->destination);
190 if (fractionLeft.find(odID) != fractionLeft.end()) {
191 (*next)->vehicleNumber += fractionLeft[odID];
192 fractionLeft[odID] = 0;
195 const size_t oldSize = vehicles.size();
197 if (oldSize != vehicles.size()) {
201 fractionLeft[odID] = fraction;
208 for (std::vector<ODVehicle>::reverse_iterator i = vehicles.rbegin(); i != vehicles.rend() && (*i).depart == t; ++i) {
215 while (vehicles.size() != 0 && vehicles.back().depart == t) {
218 if (!vehicles.empty()) {
219 t = vehicles.back().depart;
221 if (next !=
myContainer.end() && (t > (*next)->begin || vehicles.empty())) {
224 if (next ==
myContainer.end() && vehicles.empty()) {
234 const std::string& prefix) {
242 const ODCell*
const c = *i;
243 if (c->
end > begin && c->
begin < end) {
259 if (line[0] !=
'*') {
269 if (time.find(
'.') == std::string::npos) {
272 std::string hours = time.substr(0, time.find(
'.'));
273 std::string minutes = time.substr(time.find(
'.') + 1);
278 std::pair<SUMOTime, SUMOTime>
286 throw ProcessError(
"Begin time is larger than end time.");
288 return std::make_pair(begin, end);
290 throw ProcessError(
"Broken period definition '" + line +
"'.");
292 throw ProcessError(
"Broken period definition '" + line +
"'.");
310 std::string vehType,
bool matrixHasVehType) {
314 if (matrixHasVehType) {
322 std::pair<SUMOTime, SUMOTime> times =
readTime(lr);
333 std::vector<std::string> names;
338 names.push_back(st2.
next());
340 }
while ((
int) names.size() != districtNo);
343 for (std::vector<std::string>::iterator si = names.begin(); si != names.end(); ++si) {
344 std::vector<std::string>::iterator di = names.begin();
348 if (line.length() == 0) {
354 assert(di != names.end());
356 if (vehNumber != 0) {
357 add(vehNumber, begin, end, *si, *di, vehType);
359 if (di == names.end()) {
360 throw ProcessError(
"More entries than districts found.");
365 throw ProcessError(
"Not numeric vehicle number in line '" + line +
"'.");
370 }
while (di != names.end());
378 std::string vehType,
bool matrixHasVehType) {
382 if (matrixHasVehType) {
391 std::pair<SUMOTime, SUMOTime> times =
readTime(lr);
401 if (line.length() == 0) {
405 if (st2.
size() == 0) {
409 std::string sourceD = st2.
next();
410 std::string destD = st2.
next();
412 if (vehNumber != 0) {
413 add(vehNumber, begin, end, sourceD, destD, vehType);
416 throw ProcessError(
"Missing at least one information in line '" + line +
"'.");
418 throw ProcessError(
"Not numeric vehicle number in line '" + line +
"'.");
446 for (
size_t i = 0; i < ps.
getAreaNo(); ++i) {
454 newCells.push_back(ncell);
463 for (std::vector<ODCell*>::iterator i = oldCells.begin(); i != oldCells.end(); ++i) {
464 std::vector<ODCell*> newCells;
466 copy(newCells.begin(), newCells.end(), back_inserter(
myContainer));
475 if (files.size() == 0) {
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 +
"'.");
511 bool interpolating = !timelineDayInHours;
514 if (timelineDayInHours) {
515 if (def.size() != 24) {
516 throw ProcessError(
"Assuming 24 entries for a day timeline, but got " +
toString(def.size()) +
".");
518 for (
int chour = 0; chour < 24; ++chour) {
525 while (i < def.size()) {
527 if (st2.
size() != 2) {
528 throw ProcessError(
"Broken time line definition: missing a value in '" + def[i - 1] +
"'.");