SUMOReal MSLane::getMeanSpeed() const throw() { //ashu modification 16 november int temp=0; if (getVehicleNumber()==0) { //return myMaxSpeed; return 0; } SUMOReal v = 0; for (StripContConstIter i=myStrips.begin(); i!=myStrips.end(); ++i) { v += (*i)->getMeanSpeed(); if ((*i)->getMeanSpeed() == 0) { temp++; } } SUMOReal ret = v / (SUMOReal) (myStrips.size() - temp); releaseVehicles(); return ret; }
void GUILane::drawGL(const GUIVisualizationSettings& s) const { glPushMatrix(); const bool isInternal = myEdge->getPurpose() == MSEdge::EDGEFUNCTION_INTERNAL; bool mustDrawMarkings = false; const bool drawDetails = s.scale * s.laneWidthExaggeration > 5; if (isInternal) { // draw internal lanes on top of junctions glTranslated(0, 0, GLO_JUNCTION + 0.1); } else { glTranslated(0, 0, getType()); } // set lane color if (!MSGlobals::gUseMesoSim) { setColor(s); glPushName(getGlID()); // do not register for clicks in MESOSIM } // draw lane // check whether it is not too small if (s.scale * s.laneWidthExaggeration < 1.) { GLHelper::drawLine(myShape); if (!MSGlobals::gUseMesoSim) { glPopName(); } glPopMatrix(); } else { if (isRailway(myPermissions)) { // draw as railway const SUMOReal halfRailWidth = 0.725 * s.laneWidthExaggeration; GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfRailWidth); glColor3d(1, 1, 1); glTranslated(0, 0, .1); GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, halfRailWidth - 0.2); drawCrossties(s, s.laneWidthExaggeration); } else { const SUMOReal laneWidth = isInternal ? myQuarterLaneWidth : myHalfLaneWidth; mustDrawMarkings = !isInternal; GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, laneWidth * s.laneWidthExaggeration); } if (!MSGlobals::gUseMesoSim) { glPopName(); } glPopMatrix(); // draw ROWs (not for inner lanes) if (!isInternal && drawDetails) { glPushMatrix(); glTranslated(0, 0, GLO_JUNCTION); // must draw on top of junction shape GUINet* net = (GUINet*) MSNet::getInstance(); glTranslated(0, 0, .2); drawLinkRules(*net); if (s.showLinkDecals && !isRailway(myPermissions)) { drawArrows(); } if (s.showLane2Lane) { // this should be independent to the geometry: // draw from end of first to the begin of second drawLane2LaneConnections(); } glTranslated(0, 0, .1); if (s.drawLinkJunctionIndex) { drawLinkNo(); } if (s.drawLinkTLIndex) { drawTLSLinkNo(*net); } glPopMatrix(); } } if (mustDrawMarkings && drawDetails) { // needs matrix reset drawMarkings(s, s.laneWidthExaggeration); } // draw vehicles if (s.scale > s.minVehicleSize) { // retrieve vehicles from lane; disallow simulation const MSLane::VehCont& vehicles = getVehiclesSecure(); for (MSLane::VehCont::const_iterator v = vehicles.begin(); v != vehicles.end(); ++v) { if ((*v)->getLane() == this) { static_cast<const GUIVehicle* const>(*v)->drawGL(s); } // else: this is the shadow during a continuous lane change } // draw parking vehicles const std::set<const MSVehicle*> parking = MSVehicleTransfer::getInstance()->getParkingVehicles(this); for (std::set<const MSVehicle*>::const_iterator v = parking.begin(); v != parking.end(); ++v) { static_cast<const GUIVehicle* const>(*v)->drawGL(s); } // allow lane simulation releaseVehicles(); } }