int AGActivity::availableTranspMeans(AGPosition from, AGPosition to) { int FOOT = 1; int BUS = 2; int available = 0; if (from.distanceTo(to) <= myStatData->maxFootDistance) { available += FOOT; } if (from.minDistanceTo(myStatData->busStations) <= myStatData->maxFootDistance && to.minDistanceTo(myStatData->busStations) <= myStatData->maxFootDistance) { available += BUS; } return available; }
bool AGChild::allocateASchool(std::list<AGSchool>* schools, AGPosition housePos) { SUMOReal minDist = std::numeric_limits<SUMOReal>::infinity(); AGSchool* sch = NULL; if (schools->size() == 0) { return false; } std::list<AGSchool>::iterator it; for (it = schools->begin(); it != schools->end(); ++it) { if (it->acceptThisAge(age) && it->getPlaces() > 0 && housePos.distanceTo(it->getPosition()) < minDist) { minDist = housePos.distanceTo(it->getPosition()); sch = &(*it); } } return setSchool(sch); }
int AGTrip::getTimeTrip(SUMOReal secPerKm) { SUMOReal dist = 0; std::list<AGPosition> positions; positions.push_back(myFrom); std::list<AGPosition>::iterator it; for (it = myPassBy.begin(); it != myPassBy.end(); ++it) { positions.push_back(*it); } positions.push_back(myTo); AGPosition* temp = &positions.front(); for (it = positions.begin(), ++it; it != positions.end(); ++it) { dist += temp->distanceTo(*it); temp = &*it; } return (int)(secPerKm * (dist / 1000.0)); }
int AGActivity::possibleTranspMean(AGPosition destination) { int FOOT = 1; int BUS = 2; int CAR = 4; int transp = 0; if (destination.distanceTo(myHousehold->getPosition()) <= myStatData->maxFootDistance) { transp = FOOT; if (myHousehold->getCarNbr() != 0) { transp += CAR; } if (destination.minDistanceTo(myStatData->busStations) <= myStatData->maxFootDistance && myHousehold->getPosition().minDistanceTo(myStatData->busStations) <= myStatData->maxFootDistance) { transp += BUS; } } else if (myHousehold->getCarNbr() == 0) { SUMOReal d1 = destination.distanceTo(myHousehold->getPosition()); SUMOReal d2 = destination.minDistanceTo(myStatData->busStations) + myHousehold->getPosition().minDistanceTo(myStatData->busStations); if (d1 > d2) { transp = BUS; } else { transp = FOOT; } } else if (myHousehold->getCarNbr() != 0) { //all other cases if (destination.minDistanceTo(myStatData->busStations) > myStatData->maxFootDistance || myHousehold->getPosition().minDistanceTo(myStatData->busStations) > myStatData->maxFootDistance) { transp = CAR; } else { transp = CAR + BUS; } } return transp; }
int AGActivity::timeToDrive(AGPosition from, AGPosition to) { SUMOReal dist = from.distanceTo(to); return (int)(timePerKm * dist / 1000.0); }
void AGTrip::setDep(AGPosition departure) { myFrom = *new AGPosition(departure.getStreet(), departure.getPosition()); }
void AGTrip::setArr(AGPosition arrival) { myTo = *new AGPosition(arrival.getStreet(), arrival.getPosition()); }