std::vector<MSLane*>
MS_E2_ZS_CollectorOverLanes::getLanePredeccessorLanes(MSLane *l) throw() {
    std::string eid = l->getEdge().getID();
    // get predecessing edges
    const std::vector<MSEdge*> &predEdges = l->getEdge().getIncomingEdges();
    std::vector<MSLane*> ret;
    // find predecessing lanes
    std::vector<MSEdge*>::const_iterator i=predEdges.begin();
    for (; i!=predEdges.end(); ++i) {
        MSEdge *e = *i;
        assert(e!=0);
        typedef std::vector<MSLane*> LaneVector;
        const LaneVector *cl = e->allowedLanes(l->getEdge(), SVC_UNKNOWN);
        bool fastAbort = false;
        if (cl!=0) {
            for (LaneVector::const_iterator j=cl->begin(); !fastAbort&&j!=cl->end(); j++) {
                const MSLinkCont &lc = (*j)->getLinkCont();
                for (MSLinkCont::const_iterator k=lc.begin(); !fastAbort&&k!=lc.end(); k++) {
                    if ((*k)->getLane()==l) {
                        ret.push_back(*j);
                        fastAbort = true;
                    }
                }
            }
        }
    }
    return ret;
}
Beispiel #2
0
// ===========================================================================
// method definitions
// ===========================================================================
MESegment::MESegment(const std::string& id,
                     const MSEdge& parent, MESegment* next,
                     SUMOReal length, SUMOReal speed,
                     unsigned int idx,
                     SUMOTime tauff, SUMOTime taufj,
                     SUMOTime taujf, SUMOTime taujj,
                     SUMOReal jamThresh, bool multiQueue, bool junctionControl,
                     SUMOReal lengthGeometryFactor) :
    Named(id), myEdge(parent), myNextSegment(next),
    myLength(length), myIndex(idx),
    myTau_ff((SUMOTime)(tauff / parent.getLanes().size())),
    myTau_fj((SUMOTime)(taufj / parent.getLanes().size())), // Eissfeldt p. 90 and 151 ff.
    myTau_jf((SUMOTime)(taujf / parent.getLanes().size())),
    myTau_jj((SUMOTime)(taujj / parent.getLanes().size())),
    myTau_length(MAX2(MESO_MIN_SPEED, speed) * parent.getLanes().size() / TIME2STEPS(1) ),
    myHeadwayCapacity(length / DEFAULT_VEH_LENGHT_WITH_GAP * parent.getLanes().size())/* Eissfeldt p. 69 */,
    myCapacity(length * parent.getLanes().size()),
    myOccupancy(0.f),
    myJunctionControl(junctionControl),
    myTLSPenalty(MSGlobals::gMesoTLSPenalty > 0 && myNextSegment == 0 && (
                     parent.getToJunction()->getType() == NODETYPE_TRAFFIC_LIGHT ||
                     parent.getToJunction()->getType() == NODETYPE_TRAFFIC_LIGHT_NOJUNCTION ||
                     parent.getToJunction()->getType() == NODETYPE_TRAFFIC_LIGHT_RIGHT_ON_RED)),
    myEntryBlockTime(SUMOTime_MIN),
    myLengthGeometryFactor(lengthGeometryFactor),
    myMeanSpeed(speed),
    myLastMeanSpeedUpdate(SUMOTime_MIN) {
    myCarQues.push_back(std::vector<MEVehicle*>());
    myBlockTimes.push_back(-1);
    const std::vector<MSLane*>& lanes = parent.getLanes();
    if (multiQueue && lanes.size() > 1) {
        unsigned int numFollower = parent.getNumSuccessors();
        if (numFollower > 1) {
            while (myCarQues.size() < lanes.size()) {
                myCarQues.push_back(std::vector<MEVehicle*>());
                myBlockTimes.push_back(-1);
            }
            for (unsigned int i = 0; i < numFollower; ++i) {
                const MSEdge* edge = parent.getSuccessors()[i];
                myFollowerMap[edge] = std::vector<size_t>();
                const std::vector<MSLane*>* allowed = parent.allowedLanes(*edge);
                assert(allowed != 0);
                assert(allowed->size() > 0);
                for (std::vector<MSLane*>::const_iterator j = allowed->begin(); j != allowed->end(); ++j) {
                    std::vector<MSLane*>::const_iterator it = find(lanes.begin(), lanes.end(), *j);
                    myFollowerMap[edge].push_back(distance(lanes.begin(), it));
                }
            }
        }
    }
    recomputeJamThreshold(jamThresh);
}