void AGActivityTripWriter::addTrip(const AGTrip& trip) { int time = (trip.getDay() - 1) * 86400 + trip.getTime(); myTripOutput.openTag(SUMO_TAG_TRIP) .writeAttr(SUMO_ATTR_ID, trip.getVehicleName()) .writeAttr(SUMO_ATTR_TYPE, trip.getType()) .writeAttr(SUMO_ATTR_DEPART, time) .writeAttr(SUMO_ATTR_DEPARTPOS, trip.getDep().getPosition()) .writeAttr(SUMO_ATTR_ARRIVALPOS, trip.getArr().getPosition()) .writeAttr(SUMO_ATTR_ARRIVALSPEED, 0.) .writeAttr(SUMO_ATTR_FROM, trip.getDep().getStreet().getID()); if (!trip.getPassed()->empty()) { std::ostringstream oss; for (std::list<AGPosition>::const_iterator it = trip.getPassed()->begin(); it != trip.getPassed()->end(); ++it) { if (it != trip.getPassed()->begin()) { oss << " "; } oss << it->getStreet().getID(); } myTripOutput.writeAttr(SUMO_ATTR_VIA, oss.str()); } myTripOutput.writeAttr(SUMO_ATTR_TO, trip.getArr().getStreet().getID()); myTripOutput.closeTag(); }
// =========================================================================== // method definitions // =========================================================================== bool AGTrip::operator <(const AGTrip& trip) const { if (getDay() < trip.getDay()) { return true; } if (getDay() == trip.getDay()) if (getTime() < trip.getTime()) { return true; } return false; }
bool AGActivityGen::timeTripValidation(AGTrip trip) { if (trip.getDay() > durationInDays + 1) { return false; } if (trip.getDay() == 1) { //first day if (trip.getTime() < beginTime) { return false; } if (durationInDays == 0 && trip.getTime() > endTime) { return false; } } if (trip.getDay() == durationInDays + 1) { //last day if (trip.getTime() > endTime) { return false; } if (durationInDays == 0 && trip.getTime() < beginTime) { return false; } } return true; }
void AGActivityGen::varDepTime(AGTrip& trip) { if (trip.getType() != "default") { return; } //buses are on time and random are already spread int variation = (int)RandHelper::randNorm(0, city.statData.departureVariation); AGTime depTime(trip.getDay(), 0, 0, trip.getTime()); depTime += variation; if (depTime.getDay() > 0) { trip.setDay(depTime.getDay()); trip.setDepTime(depTime.getSecondsInCurrentDay()); } else { trip.setDay(1); trip.setDepTime(0); } }