46 #ifdef CHECK_MEMORY_LEAKS
48 #endif // CHECK_MEMORY_LEAKS
61 #ifndef HAVE_INTERNAL_LANES
89 const std::vector<MSLink*>& foeLinks,
90 const std::vector<MSLane*>& foeLanes,
91 MSLane* internalLaneBefore) {
97 #ifdef MSLink_DEBUG_CROSSING_POINTS
100 #ifdef HAVE_INTERNAL_LANES
102 if (internalLaneBefore != 0) {
104 lane = internalLaneBefore;
111 for (std::vector<MSLane*>::const_iterator it_lane =
myFoeLanes.begin(); it_lane !=
myFoeLanes.end(); ++it_lane) {
115 myLengthsBehindCrossing.push_back(std::make_pair(0, 0));
116 #ifdef MSLink_DEBUG_CROSSING_POINTS
118 <<
" " << lane->
getID()
119 <<
" merges with " << (*it_lane)->getID()
120 <<
" nextLane " << lane->
getLinkCont()[0]->getViaLaneOrLane()->getID()
121 <<
" dist1=" << myLengthsBehindCrossing.back().first
122 <<
" dist2=" << myLengthsBehindCrossing.back().second
128 if (intersections1.size() == 0) {
129 intersections1.push_back(10000.0);
130 }
else if (intersections1.size() > 1) {
131 std::sort(intersections1.begin(), intersections1.end());
133 std::vector<SUMOReal> intersections2 = (*it_lane)->getShape().intersectsAtLengths2D(lane->
getShape());
135 if (intersections2.size() == 0) {
136 intersections2.push_back(0);
137 }
else if (intersections2.size() > 1) {
138 std::sort(intersections2.begin(), intersections2.end());
140 myLengthsBehindCrossing.push_back(std::make_pair(
141 lane->
getLength() - intersections1.back(),
142 (*it_lane)->getLength() - intersections2.back()));
143 #ifdef MSLink_DEBUG_CROSSING_POINTS
145 <<
" intersection of " << lane->
getID()
147 <<
" with " << (*it_lane)->getID()
148 <<
" totalLength=" << (*it_lane)->getLength()
149 <<
" dist1=" << myLengthsBehindCrossing.back().first
150 <<
" dist2=" << myLengthsBehindCrossing.back().second
164 const bool setRequest,
const SUMOTime arrivalTimeBraking,
const SUMOReal arrivalSpeedBraking,
const SUMOTime waitingTime) {
168 arrivalTimeBraking, arrivalSpeedBraking, waitingTime)));
182 if ((*i)->isBlockingAnyone()) {
198 std::map<const SUMOVehicle*, ApproachingVehicleInformation>::const_iterator i =
myApproachingVehicles.find(veh);
217 std::vector<const SUMOVehicle*>* collectFoes)
const {
236 if ((*i)->blockedAtTime(arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
myLane == (*i)->getLane(),
237 impatience, decel, waitingTime, collectFoes)) {
248 std::vector<const SUMOVehicle*>* collectFoes)
const {
250 if (!i->second.willPass) {
254 assert(waitingTime > 0);
255 if (waitingTime > i->second.waitingTime) {
258 if (waitingTime == i->second.waitingTime && arrivalTime < i->second.arrivalTime) {
262 const SUMOTime foeArrivalTime = (
SUMOTime)((1.0 - impatience) * i->second.arrivalTime + impatience * i->second.arrivalTimeBraking);
263 if (i->second.leavingTime < arrivalTime) {
265 if (sameTargetLane && (arrivalTime - i->second.leavingTime <
myLookaheadTime
267 i->first->getVehicleType().getCarFollowModel().getMaxDecel(), decel))) {
268 if (collectFoes == 0) {
271 collectFoes->push_back(i->first);
274 }
else if (foeArrivalTime > leaveTime) {
278 decel, i->first->getVehicleType().getCarFollowModel().getMaxDecel()))) {
279 if (collectFoes == 0) {
282 collectFoes->push_back(i->first);
287 if (collectFoes == 0) {
290 collectFoes->push_back(i->first);
311 assert(distLeft > 0);
322 if ((*i)->blockedAtTime(arrivalTime, leaveTime, speed, speed,
myLane == (*i)->getLane(), 0, decel, 0)) {
327 if ((*i)->getVehicleNumber() > 0 || (*i)->getPartialOccupator() != 0) {
355 #ifdef HAVE_INTERNAL_LANES
356 if (myJunctionInlane == 0 ||
myAmCont) {
366 assert(predLink != 0);
381 #ifdef HAVE_INTERNAL_LANES
382 const std::string via = getViaLane() == 0 ?
"" : getViaLane()->getID();
384 const std::string via =
"";
388 std::vector<std::pair<SUMOTime, const SUMOVehicle*> > toSort;
390 toSort.push_back(std::make_pair(it->second.arrivalTime, it->first));
392 std::sort(toSort.begin(), toSort.end());
393 for (std::vector<std::pair<SUMOTime, const SUMOVehicle*> >::const_iterator it = toSort.begin(); it != toSort.end(); ++it) {
412 #ifdef HAVE_INTERNAL_LANES
414 MSLink::getViaLane()
const {
415 return myJunctionInlane;
420 MSLink::getLeaderInfo(
SUMOReal dist,
SUMOReal minGap, std::vector<const MSPerson*>* collectBlockers)
const {
425 || (myJunctionInlane != 0 && myJunctionInlane->getLogicalPredecessorLane()->getEdge().isInternal()))) {
428 for (
size_t i = 0; i <
myFoeLanes.size(); ++i) {
431 const SUMOReal distToCrossing = dist - myLengthsBehindCrossing[i].first;
433 if (distToCrossing < 0) {
436 const SUMOReal foeDistToCrossing = foeLane->
getLength() - myLengthsBehindCrossing[i].second;
445 const bool cannotIgnore = contLane || sameTarget;
448 for (MSLane::VehCont::const_iterator it_veh = vehicles.begin(); it_veh != vehicles.end(); ++it_veh) {
458 const SUMOReal leaderBackDist = foeDistToCrossing - leaderBack;
460 if (leaderBackDist < 0) {
465 gap = distToCrossing - leaderBackDist - (sameTarget ? minGap : 0);
467 result.push_back(LinkLeader(leader, gap, cannotIgnore ? -1 : distToCrossing));
482 if (leaderBackDist < 0) {
487 gap = distToCrossing - leaderBackDist - (sameTarget ? minGap : 0);
489 result.push_back(LinkLeader(leader, gap, sameTarget ? -1 : distToCrossing));
495 result.push_back(LinkLeader((
MSVehicle*)0, -1, distToPeds));
506 #ifdef HAVE_INTERNAL_LANES
507 if (myJunctionInlane != 0) {
508 return myJunctionInlane;