SUMOVehicle* MSVehicleControl::getWaitingVehicle(const MSEdge* const edge, const std::set<std::string>& lines, const SUMOReal position, const std::string ridingID) { if (myWaiting.find(edge) != myWaiting.end()) { // for every vehicle waiting vehicle at this edge std::vector<SUMOVehicle*> waitingTooFarAway; for (std::vector<SUMOVehicle*>::const_iterator it = myWaiting[edge].begin(); it != myWaiting[edge].end(); ++it) { const std::string& line = (*it)->getParameter().line == "" ? (*it)->getParameter().id : (*it)->getParameter().line; SUMOReal vehiclePosition = (*it)->getPositionOnLane(); // if the line of the vehicle is contained in the set of given lines and the vehicle is stopped and is positioned // in the interval [position - t, position + t] for a tolerance t=10 if (lines.count(line)) { if ((position - 10 <= vehiclePosition) && (vehiclePosition <= position + 10)) { return (*it); } else if ((*it)->isStoppedTriggered() || (*it)->getParameter().departProcedure == DEPART_TRIGGERED) { // maybe we are within the range of the stop MSVehicle* veh = static_cast<MSVehicle*>(*it); if (veh->isStoppedInRange(position)) { return (*it); } else { waitingTooFarAway.push_back(*it); } } } } for (std::vector<SUMOVehicle*>::iterator it = waitingTooFarAway.begin(); it != waitingTooFarAway.end(); ++it) { WRITE_WARNING(ridingID + " at edge '" + edge->getID() + "' position " + toString(position) + " cannot use waiting vehicle '" + (*it)->getID() + "' at position " + toString((*it)->getPositionOnLane()) + " because it is too far away."); } } return 0; }