Skip to content

Commit

Permalink
warning about tripinfo for jupedsim fix #13982
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Jan 2, 2024
1 parent 82656a7 commit 1378669
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/microsim/transportables/MSPModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ class MSPModel {
/// @brief whether movements on intersections are modelled
virtual bool usingInternalLanes() = 0;

/// @brief whether travel times and distances can reliably be calculated from the network alone
virtual bool usingShortcuts() {
return false;
}

/// @brief return the number of active objects
virtual int getActiveNumber() = 0;

Expand Down
8 changes: 3 additions & 5 deletions src/microsim/transportables/MSPModel_JuPedSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include <utils/geom/PositionVector.h>
#include <utils/options/OptionsCont.h>
#include <utils/shapes/ShapeContainer.h>
#include "MSPModel_Striping.h"
#include "MSPModel_JuPedSim.h"
#include "MSPerson.h"

Expand All @@ -58,7 +57,7 @@ const double MSPModel_JuPedSim::GEOS_BUFFERED_SEGMENT_WIDTH = 0.5 * SUMO_const_l
// ===========================================================================
MSPModel_JuPedSim::MSPModel_JuPedSim(const OptionsCont& oc, MSNet* net) :
myNetwork(net), myJPSDeltaT(string2time(oc.getString("pedestrian.jupedsim.step-length"))),
myExitTolerance(oc.getFloat("pedestrian.jupedsim.exit-tolerance")) {
myExitTolerance(oc.getFloat("pedestrian.jupedsim.exit-tolerance")), myHaveAdditionalWalkableAreas(false) {
initialize();
net->getBeginOfTimestepEvents()->addEvent(new Event(this), net->getCurrentTimeStep() + DELTA_T);
}
Expand Down Expand Up @@ -564,6 +563,7 @@ MSPModel_JuPedSim::buildPedestrianNetwork(MSNet* network) {
GEOSGeometry* walkableArea = createGeometryFromShape(polygonWithID.second->getShape(), polygonWithID.first);
if (walkableArea != nullptr) {
walkableAreas.push_back(walkableArea);
myHaveAdditionalWalkableAreas = true;
}
} else if (polygonWithID.second->getShapeType() == "jupedsim.obstacle") {
GEOSGeometry* additionalObstacle = createGeometryFromShape(polygonWithID.second->getShape(), polygonWithID.first);
Expand Down Expand Up @@ -602,8 +602,7 @@ MSPModel_JuPedSim::buildPedestrianNetwork(MSNet* network) {
GEOSGeom_destroy(disjointAdditionalObstacles);

if (!GEOSisSimple(finalWalkableAreas)) {
const std::string error = "Union of walkable areas minus union of obstacles is not a simple polygon.";
throw ProcessError(error);
throw ProcessError(TL("Union of walkable areas minus union of obstacles is not a simple polygon."));
}

return finalWalkableAreas;
Expand Down Expand Up @@ -731,7 +730,6 @@ MSPModel_JuPedSim::initialize() {
initGEOS(nullptr, nullptr);
myGEOSPedestrianNetwork = buildPedestrianNetwork(myNetwork);
int nbrConnectedComponents = GEOSGetNumGeometries(myGEOSPedestrianNetwork);
myIsPedestrianNetworkConnected = nbrConnectedComponents == 1 ? true : false;

// myJPSGeometryBuilder = JPS_GeometryBuilder_Create();
// for (size_t i = 0; i < GEOSGetNumGeometries(myGEOSPedestrianNetwork); i++) {
Expand Down
5 changes: 4 additions & 1 deletion src/microsim/transportables/MSPModel_JuPedSim.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class MSPModel_JuPedSim : public MSPModel {
SUMOTime execute(SUMOTime time);

bool usingInternalLanes() override;
bool usingShortcuts() override {
return myHaveAdditionalWalkableAreas;
}
void registerArrived();
int getActiveNumber() override;
void clearState() override;
Expand Down Expand Up @@ -150,7 +153,7 @@ class MSPModel_JuPedSim : public MSPModel {
std::vector<PState*> myPedestrianStates;

GEOSGeometry* myGEOSPedestrianNetwork;
bool myIsPedestrianNetworkConnected;
bool myHaveAdditionalWalkableAreas;

JPS_GeometryBuilder myJPSGeometryBuilder;
JPS_Geometry myJPSGeometry;
Expand Down
10 changes: 10 additions & 0 deletions src/microsim/transportables/MSPerson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
#include "MSPerson.h"
#include "MSPModel.h"

// ===========================================================================
// static member definition
// ===========================================================================
bool MSPerson::MSPersonStage_Walking::myWarnedInvalidTripinfo = false;


// ===========================================================================
// method definitions
// ===========================================================================
Expand Down Expand Up @@ -267,6 +273,10 @@ MSPerson::MSPersonStage_Walking::walkDistance(bool partial) const {

void
MSPerson::MSPersonStage_Walking::tripInfoOutput(OutputDevice& os, const MSTransportable* const person) const {
if (!myWarnedInvalidTripinfo && MSNet::getInstance()->getPersonControl().getMovementModel()->usingShortcuts()) {
WRITE_WARNING(TL("The pedestrian model uses infrastructure which is not in the network, timeLoss and routeLength may be invalid."));
myWarnedInvalidTripinfo = true;
}
const double distance = walkDistance(true);
const double maxSpeed = getMaxSpeed(person);
const SUMOTime duration = myArrived - myDeparted;
Expand Down
2 changes: 2 additions & 0 deletions src/microsim/transportables/MSPerson.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class MSPerson : public MSTransportable {
/// @brief distance walked on non-normal edges (i.e. walkingareas)
double myInternalDistance;

static bool myWarnedInvalidTripinfo;

private:
/// @brief Invalidated copy constructor.
MSPersonStage_Walking(const MSPersonStage_Walking&);
Expand Down
1 change: 1 addition & 0 deletions src/microsim/trigger/MSTriggeredRerouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ MSEdge MSTriggeredRerouter::mySpecialDest_keepDestination("MSTriggeredRerouter_k
MSEdge MSTriggeredRerouter::mySpecialDest_terminateRoute("MSTriggeredRerouter_terminateRoute", -1, SumoXMLEdgeFunc::UNKNOWN, "", "", -1, 0);
std::map<std::string, MSTriggeredRerouter*> MSTriggeredRerouter::myInstances;


// ===========================================================================
// method definitions
// ===========================================================================
Expand Down

0 comments on commit 1378669

Please sign in to comment.