Skip to content

Commit

Permalink
[JuPedSim] Corrected a bug when multiple vanishing areas are present.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoueraud87 authored and behrisch committed Mar 1, 2024
1 parent abb5b85 commit 16a9a14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/microsim/transportables/MSPModel_JuPedSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,12 @@ MSPModel_JuPedSim::execute(SUMOTime time) {
}

// Remove pedestrians that are in a predefined area, at a predefined rate.
for (const AreaData& area : myAreas) {
for (AreaData& area : myAreas) {
const std::vector<JPS_Point>& areaBoundary = area.areaBoundary;
JPS_AgentIdIterator agentsInArea = JPS_Simulation_AgentsInPolygon(myJPSSimulation, areaBoundary.data(), areaBoundary.size());
if (area.areaType == "vanishing_area") {
const SUMOTime period = area.params.count("period") > 0 ? string2time(area.params.at("period")) : 1000;
if (time - myLastRemovalTime >= period) {
if (time - area.lastRemovalTime >= period) {
const JPS_AgentId agentID = JPS_AgentIdIterator_Next(agentsInArea);
if (agentID != 0) {
auto lambda = [agentID](const PState * const p) {
Expand All @@ -385,7 +385,7 @@ MSPModel_JuPedSim::execute(SUMOTime time) {
registerArrived();
JPS_Simulation_MarkAgentForRemoval(myJPSSimulation, agentID, nullptr);
myPedestrianStates.erase(iterator);
myLastRemovalTime = time;
area.lastRemovalTime = time;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/microsim/transportables/MSPModel_JuPedSim.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ class MSPModel_JuPedSim : public MSPModel {
const std::string areaType;
const std::vector<JPS_Point> areaBoundary;
const Parameterised::Map params;

/// @brief The last time a pedestrian was removed in a vanishing area.
SUMOTime lastRemovalTime = 0;
};

/// @brief Array of special areas.
std::vector<AreaData> myAreas;

/// @brief The last time a pedestrian was removed in a vanishing area.
SUMOTime myLastRemovalTime = 0;

/// @brief Array of stopped trains, used to detect whether to add carriages and ramps to the geometry.
std::vector<SUMOTrafficObject::NumericalID> myAllStoppedTrainIDs;
Expand Down

0 comments on commit 16a9a14

Please sign in to comment.