void MSParkingArea::enter(SUMOVehicle* what, SUMOReal beg, SUMOReal end) { if (myLastFreeLot >= 1 && myLastFreeLot <= (int)mySpaceOccupancies.size()) { mySpaceOccupancies[myLastFreeLot].vehicle = what; myEndPositions[what] = std::pair<SUMOReal, SUMOReal>(beg, end); computeLastFreePos(); } }
// =========================================================================== // method definitions // =========================================================================== MSBusStop::MSBusStop(const std::string& id, const std::vector<std::string> &lines, MSLane& lane, SUMOReal begPos, SUMOReal endPos) : MSTrigger(id), myLines(lines), myLane(lane), myBegPos(begPos), myEndPos(endPos), myLastFreePos(endPos) { computeLastFreePos(); }
void MSParkingArea::leaveFrom(SUMOVehicle* what) { assert(myEndPositions.find(what) != myEndPositions.end()); std::map<unsigned int, LotSpaceDefinition >::iterator i; for (i = mySpaceOccupancies.begin(); i != mySpaceOccupancies.end(); i++) { if ((*i).second.vehicle == what) { (*i).second.vehicle = 0; break; } } myEndPositions.erase(myEndPositions.find(what)); computeLastFreePos(); }
// =========================================================================== // method definitions // =========================================================================== MSParkingArea::MSParkingArea(const std::string& id, const std::vector<std::string>& lines, MSLane& lane, double begPos, double endPos, unsigned int capacity, double width, double length, double angle, const std::string& name) : MSStoppingPlace(id, lines, lane, begPos, endPos, name), myCapacity(capacity), myWidth(width), myLength(length), myAngle(angle) { // initialize unspecified defaults if (myWidth == 0) { myWidth = SUMO_const_laneWidth; } if (myLength == 0) { myLength = getSpaceDim(); } const double offset = MSNet::getInstance()->lefthand() ? -1 : 1; myShape = lane.getShape().getSubpart( lane.interpolateLanePosToGeometryPos(begPos), lane.interpolateLanePosToGeometryPos(endPos)); myShape.move2side((lane.getWidth() / 2. + myWidth / 2.) * offset); // Initialize space occupancies if there is a road-side capacity // The overall number of lots is fixed and each lot accepts one vehicle regardless of size if (myCapacity > 0) { for (int i = 1; i <= myCapacity; ++i) { mySpaceOccupancies[i] = LotSpaceDefinition(); mySpaceOccupancies[i].index = i; mySpaceOccupancies[i].vehicle = 0; mySpaceOccupancies[i].myWidth = myWidth; mySpaceOccupancies[i].myLength = myLength; mySpaceOccupancies[i].myEndPos = myBegPos + getSpaceDim() * i; const Position& f = myShape.positionAtOffset(getSpaceDim() * (i - 1)); const Position& s = myShape.positionAtOffset(getSpaceDim() * (i)); double lot_angle = ((double) atan2((s.x() - f.x()), (f.y() - s.y())) * (double) 180.0 / (double) M_PI) + myAngle; mySpaceOccupancies[i].myRotation = lot_angle; if (myAngle == 0) { // parking parallel to the road mySpaceOccupancies[i].myPosition = s; } else { // angled parking mySpaceOccupancies[i].myPosition = (f + s) * 0.5; } } } computeLastFreePos(); }
void MSParkingArea::addLotEntry(SUMOReal x, SUMOReal y, SUMOReal z, SUMOReal width, SUMOReal length, SUMOReal angle) { const int i = (int)mySpaceOccupancies.size() + 1; mySpaceOccupancies[i] = LotSpaceDefinition(); mySpaceOccupancies[i].index = i; mySpaceOccupancies[i].vehicle = 0; mySpaceOccupancies[i].myPosition = Position(x, y, z); mySpaceOccupancies[i].myWidth = width; mySpaceOccupancies[i].myLength = length; mySpaceOccupancies[i].myRotation = angle; mySpaceOccupancies[i].myEndPos = myEndPos; myCapacity = (int)mySpaceOccupancies.size(); computeLastFreePos(); }
void MSBusStop::leaveFrom(void* what) { assert(myEndPositions.find(what) != myEndPositions.end()); myEndPositions.erase(myEndPositions.find(what)); computeLastFreePos(); }
void MSBusStop::enter(void* what, SUMOReal beg, SUMOReal end) { myEndPositions[what] = std::pair<SUMOReal, SUMOReal>(beg, end); computeLastFreePos(); }