30#include <jupedsim/jupedsim.h>
69 myRNG(
"JuPedSim_legacy"), myNetwork(net), myShapeContainer(net->getShapeContainer()), myJPSDeltaT(
string2time(oc.getString(
"pedestrian.jupedsim.step-length"))),
70 myExitTolerance(oc.getFloat(
"pedestrian.jupedsim.exit-tolerance")), myGEOSPedestrianNetworkLargestComponent(nullptr),
71 myHaveAdditionalWalkableAreas(false) {
73 const std::string model = oc.
getString(
"pedestrian.jupedsim.model");
74 if (model ==
"CollisionFreeSpeed" || model ==
"CollisionFreeSpeedModel") {
76 }
else if (model ==
"CollisionFreeSpeedV2" || model ==
"CollisionFreeSpeedModelV2") {
78 }
else if (model ==
"GeneralizedCentrifugalForce" || model ==
"GeneralizedCentrifugalForceModel") {
80 }
else if (model ==
"SocialForce" || model ==
"SocialForceModel") {
93 (*myPythonScript) <<
"while simulation.agent_count() > 0 and simulation.iteration_count() < 160 * 100: simulation.iterate()\n";
113 JPS_Point orientation;
114 if (fabs(angle -
M_PI / 2) < NUMERICAL_EPS) {
115 orientation = JPS_Point{0., 1.};
116 }
else if (fabs(angle +
M_PI / 2) < NUMERICAL_EPS) {
117 orientation = JPS_Point{0., -1.};
119 orientation = JPS_Point{1., tan(angle)};
122 JPS_AgentId agentId = 0;
123 JPS_ErrorMessage message =
nullptr;
127 JPS_CollisionFreeSpeedModelAgentParameters agentParameters{};
128 agentParameters.position = {p.
x(), p.
y()};
130 agentParameters.stageId = state->
getStageId();
132 agentParameters.radius =
getRadius(type);
133 agentId = JPS_Simulation_AddCollisionFreeSpeedModelAgent(
myJPSSimulation, agentParameters, &message);
137 JPS_CollisionFreeSpeedModelV2AgentParameters agentParameters{};
138 agentParameters.position = {p.
x(), p.
y()};
140 agentParameters.stageId = state->
getStageId();
142 agentParameters.radius =
getRadius(type);
143 agentId = JPS_Simulation_AddCollisionFreeSpeedModelV2Agent(
myJPSSimulation, agentParameters, &message);
147 JPS_GeneralizedCentrifugalForceModelAgentParameters agentParameters{};
148 agentParameters.position = {p.
x(), p.
y()};
149 agentParameters.orientation = orientation;
151 agentParameters.stageId = state->
getStageId();
153 agentId = JPS_Simulation_AddGeneralizedCentrifugalForceModelAgent(
myJPSSimulation, agentParameters, &message);
157 JPS_SocialForceModelAgentParameters agentParameters{};
158 agentParameters.position = {p.
x(), p.
y()};
159 agentParameters.orientation = orientation;
161 agentParameters.stageId = state->
getStageId();
163 agentParameters.radius =
getRadius(type);
164 agentId = JPS_Simulation_AddSocialForceModelAgent(
myJPSSimulation, agentParameters, &message);
168 if (message !=
nullptr) {
170 JPS_ErrorMessage_Free(message);
179 JPS_ErrorMessage message =
nullptr;
180 if (predecessor != 0) {
181 const JPS_Transition transition = JPS_Transition_CreateFixedTransition(stage, &message);
182 if (message !=
nullptr) {
183 WRITE_WARNINGF(
TL(
"Error while creating fixed transition for person '%': %"), agentID, JPS_ErrorMessage_GetMessage(message));
184 JPS_ErrorMessage_Free(message);
187 JPS_JourneyDescription_SetTransitionForStage(journey, predecessor, transition, &message);
188 if (message !=
nullptr) {
189 WRITE_WARNINGF(
TL(
"Error while setting transition for person '%': %"), agentID, JPS_ErrorMessage_GetMessage(message));
190 JPS_ErrorMessage_Free(message);
193 JPS_Transition_Free(transition);
195 JPS_JourneyDescription_AddStage(journey, stage);
203 JPS_ErrorMessage message =
nullptr;
204 const Position& coords = std::get<1>(waypoint);
205 const JPS_StageId waypointId = JPS_Simulation_AddStageWaypoint(
myJPSSimulation, {coords.
x(), coords.
y()},
206 std::get<2>(waypoint), &message);
207 if (message !=
nullptr) {
208 WRITE_WARNINGF(
TL(
"Error while adding waypoint for person '%': %"), agentID, JPS_ErrorMessage_GetMessage(message));
209 JPS_ErrorMessage_Free(message);
212 const JPS_StageId waiting = std::get<0>(waypoint);
215 (*myPythonScript) <<
"journey.add(" << waiting <<
")\n";
216 if (predecessor != 0) {
217 (*myPythonScript) <<
"journey.set_transition_for_stage(" << predecessor <<
", jps.Transition.create_fixed_transition(" << waiting <<
"))\n";
220 if (!
addStage(journey, predecessor, agentID, waiting)) {
225 (*myPythonScript) <<
"ws = simulation.add_waypoint_stage((" << coords.
x() <<
"," << coords.
y() <<
"), " << std::get<2>(waypoint) <<
")\n"
227 if (predecessor != 0) {
228 (*myPythonScript) <<
"journey.set_transition_for_stage(" << predecessor <<
", jps.Transition.create_fixed_transition(ws))\n";
231 if (!
addStage(journey, predecessor, agentID, waypointId)) {
243 const MSLane*
const departureLane = getSidewalk<MSEdge, MSLane>(stage->
getRoute().front());
244 if (departureLane ==
nullptr) {
245 const char* error =
TL(
"Person '%' could not find sidewalk on edge '%', time=%.");
258 if (tazShape ==
nullptr) {
271 const double halfDepartureLaneWidth = departureLane->
getWidth() / 2.0;
274 departureRelativePositionY = 0.0;
277 departureRelativePositionY =
RandHelper::rand(-halfDepartureLaneWidth, halfDepartureLaneWidth, &
myRNG);
282 std::vector<WaypointDesc> waypoints;
283 const MSEdge* prev =
nullptr;
285 const MSLane*
const lane = getSidewalk<MSEdge, MSLane>(e);
286 JPS_StageId waitingStage = 0;
287 if (prev !=
nullptr) {
299 const MSEdge* wa =
nullptr;
300 for (
const MSEdge*
const ce : crossingRoute) {
301 if (ce->isCrossing()) {
302 const MSLane*
const crossing = getSidewalk<MSEdge, MSLane>(ce);
305 if (waitingStage != 0 && wa !=
nullptr) {
307 waypoints.push_back({waitingStage, wa->
getLanes()[0]->getShape().getCentroid(), wa->
getWidth() / 2.});
309 const MSLane*
const prevLane = getSidewalk<MSEdge, MSLane>(prev);
312 if (crossing->
getShape().front().distanceSquaredTo(startPos) < crossing->
getShape().back().distanceSquaredTo(startPos)) {
313 if (crossingWait->second.first == 0) {
316 waitingStage = crossingWait->second.first;
318 if (crossingWait->second.second == 0) {
319 crossingWait->second.second =
addWaitingSet(crossing,
false);
321 waitingStage = crossingWait->second.second;
324 throw ProcessError(
TLF(
"No waiting set for crossing at %.", ce->getID()));
327 if (ce->isWalkingArea()) {
333 waypoints.push_back({waitingStage, lane->
getShape().positionAtOffset(e->getLength() / 2.), lane->
getWidth() / 2.});
336 const JPS_StageId finalWait = std::get<0>(waypoints.back());
337 waypoints.pop_back();
338 if (!waypoints.empty()) {
339 waypoints.erase(waypoints.begin());
345 JPS_JourneyDescription journeyDesc = JPS_JourneyDescription_Create();
347 (*myPythonScript) <<
"\njourney = jps.JourneyDescription()\n";
349 JPS_StageId startingStage = 0;
350 JPS_StageId predecessor = 0;
351 for (
const auto& p : waypoints) {
353 JPS_JourneyDescription_Free(journeyDesc);
356 if (startingStage == 0) {
357 startingStage = std::get<0>(waypoints.front()) == 0 ? predecessor : std::get<0>(waypoints.front());
360 JPS_ErrorMessage message =
nullptr;
361 JPS_JourneyId journeyId = JPS_Simulation_AddJourney(
myJPSSimulation, journeyDesc, &message);
362 JPS_JourneyDescription_Free(journeyDesc);
363 if (message !=
nullptr) {
364 WRITE_WARNINGF(
TL(
"Error while adding a journey for person '%': %"), person->
getID(), JPS_ErrorMessage_GetMessage(message));
365 JPS_ErrorMessage_Free(message);
371 if (pstate->getPerson() == person) {
376 if (state ==
nullptr) {
377 state =
new PState(
static_cast<MSPerson*
>(person), stage, journeyId, startingStage, waypoints);
379 state->
setPosition(departurePosition.
x(), departurePosition.
y());
384 state->
reinit(stage, journeyId, startingStage, waypoints);
390 (*myPythonScript) <<
"journey_id = simulation.add_journey(journey)\n"
391 "simulation.add_agent(jps.CollisionFreeSpeedModelAgentParameters(journey_id=journey_id,stage_id="
392 << startingStage <<
",position=(" << departurePosition.
x() <<
"," << departurePosition.
y()
397 if (message !=
nullptr) {
398 WRITE_WARNINGF(
TL(
"Error while switching to a new journey for person '%': %"), person->
getID(), JPS_ErrorMessage_GetMessage(message));
399 JPS_ErrorMessage_Free(message);
410 if (pstate->
getLane() !=
nullptr) {
412 peds.erase(std::find(peds.begin(), peds.end(), pstate));
415 if (pstate->
getStage() !=
nullptr) {
425 JPS_ErrorMessage message =
nullptr;
426 for (
int i = 0; i < nbrIterations; ++i) {
430 WRITE_ERRORF(
TL(
"Error during iteration %: %"), i, JPS_ErrorMessage_GetMessage(message));
438 PState*
const state = *stateIt;
452 if (stage ==
nullptr) {
463 const JPS_Point position = JPS_Agent_GetPosition(agent);
467 const JPS_Point orientation = JPS_Agent_GetOrientation(agent);
468 state->
setAngle(atan2(orientation.y, orientation.x));
471 Position newPosition(position.x, position.y);
474 const double oldLanePos = state->
getEdgePos(time);
476 double bestDistance = std::numeric_limits<double>::max();
477 MSLane* candidateLane =
nullptr;
478 double candidateLaneLongitudinalPosition = 0.0;
481 forwardRoute, 0, person->
getVClass(),
true, bestDistance, &candidateLane, candidateLaneLongitudinalPosition, routeOffset);
484 if (candidateLane != state->
getLane()) {
485 if (state->
getLane() !=
nullptr) {
487 peds.erase(std::find(peds.begin(), peds.end(), state));
497 const bool arrived = stage->
moveToNextEdge(person, time, 1,
nullptr);
505 JPS_CollisionFreeSpeedModelState modelState = JPS_Agent_GetCollisionFreeSpeedModelState(agent,
nullptr);
506 if (newMaxSpeed != JPS_CollisionFreeSpeedModelState_GetV0(modelState)) {
507 JPS_CollisionFreeSpeedModelState_SetV0(modelState, newMaxSpeed);
512 JPS_CollisionFreeSpeedModelV2State modelState = JPS_Agent_GetCollisionFreeSpeedModelV2State(agent,
nullptr);
513 if (newMaxSpeed != JPS_CollisionFreeSpeedModelV2State_GetV0(modelState)) {
514 JPS_CollisionFreeSpeedModelV2State_SetV0(modelState, newMaxSpeed);
519 JPS_GeneralizedCentrifugalForceModelState modelState = JPS_Agent_GetGeneralizedCentrifugalForceModelState(agent,
nullptr);
520 if (newMaxSpeed != JPS_GeneralizedCentrifugalForceModelState_GetV0(modelState)) {
521 JPS_GeneralizedCentrifugalForceModelState_SetV0(modelState, newMaxSpeed);
526 JPS_SocialForceModelState modelState = JPS_Agent_GetSocialForceModelState(agent,
nullptr);
527 if (newMaxSpeed != JPS_SocialForceModelState_GetDesiredSpeed(modelState)) {
528 JPS_SocialForceModelState_SetDesiredSpeed(modelState, newMaxSpeed);
534 const double speed = person->
getSpeed();
535 for (
int offset = 0; offset < 2; offset++) {
537 if (waypoint !=
nullptr && std::get<0>(*waypoint) != 0) {
538 const JPS_StageId waitingStage = std::get<0>(*waypoint);
549 const double passingClearanceTime = person->
getFloatParam(
"pedestrian.timegap-crossing");
551 person->
getImpatience(), speed, 0, 0,
nullptr,
false, person);
552 const auto proxy = JPS_Simulation_GetWaitingSetProxy(
myJPSSimulation, waitingStage, &message);
553 JPS_WaitingSetProxy_SetWaitingSetState(proxy, open ? JPS_WaitingSet_Inactive : JPS_WaitingSet_Active);
559 const double slack = person->
getMaxSpeed() *
TS / 2. + POSITION_EPS;
565 const JPS_AgentId agentID = state->
getAgentId();
578 for (
const auto& area :
myAreas) {
579 const std::vector<JPS_Point>& areaBoundary = area->areaBoundary;
580 JPS_AgentIdIterator agentsInArea = JPS_Simulation_AgentsInPolygon(
myJPSSimulation, areaBoundary.data(), areaBoundary.size());
581 if (area->areaType ==
"vanishing_area") {
582 const SUMOTime period = area->params.count(
"period") > 0 ?
string2time(area->params.at(
"period")) : 1000;
583 const int nbrPeriodsCoveringTimestep = (int)ceil(
TS /
STEPS2TIME(period));
584 if (time - area->lastRemovalTime >= nbrPeriodsCoveringTimestep * period) {
585 for (
int k = 0; k < nbrPeriodsCoveringTimestep; k++) {
586 const JPS_AgentId agentID = JPS_AgentIdIterator_Next(agentsInArea);
588 auto lambda = [agentID](
const PState *
const p) {
589 return p->getAgentId() == agentID;
593 const PState*
const state = *iterator;
598 WRITE_MESSAGEF(
TL(
"Person '%' in vanishing area '%' was removed from the simulation."), person->
getID(), area->id);
602 area->lastRemovalTime = time;
609 for (JPS_AgentId agentID = JPS_AgentIdIterator_Next(agentsInArea); agentID != 0; agentID = JPS_AgentIdIterator_Next(agentsInArea)) {
610 if (area->params.count(
"speed") > 0) {
611 const JPS_Agent agent = JPS_Simulation_GetAgent(
myJPSSimulation, agentID,
nullptr);
615 JPS_CollisionFreeSpeedModelState modelState = JPS_Agent_GetCollisionFreeSpeedModelState(agent,
nullptr);
616 if (newMaxSpeed != JPS_CollisionFreeSpeedModelState_GetV0(modelState)) {
617 JPS_CollisionFreeSpeedModelState_SetV0(modelState, newMaxSpeed);
622 JPS_CollisionFreeSpeedModelV2State modelState = JPS_Agent_GetCollisionFreeSpeedModelV2State(agent,
nullptr);
623 if (newMaxSpeed != JPS_CollisionFreeSpeedModelV2State_GetV0(modelState)) {
624 JPS_CollisionFreeSpeedModelV2State_SetV0(modelState, newMaxSpeed);
629 JPS_GeneralizedCentrifugalForceModelState modelState = JPS_Agent_GetGeneralizedCentrifugalForceModelState(agent,
nullptr);
630 if (newMaxSpeed != JPS_GeneralizedCentrifugalForceModelState_GetV0(modelState)) {
631 JPS_GeneralizedCentrifugalForceModelState_SetV0(modelState, newMaxSpeed);
636 JPS_SocialForceModelState modelState = JPS_Agent_GetSocialForceModelState(agent,
nullptr);
637 if (newMaxSpeed != JPS_SocialForceModelState_GetDesiredSpeed(modelState)) {
638 JPS_SocialForceModelState_SetDesiredSpeed(modelState, newMaxSpeed);
646 JPS_AgentIdIterator_Free(agentsInArea);
651 std::vector<SUMOTrafficObject::NumericalID> allStoppedTrainIDs;
652 std::vector<const MSVehicle*> allStoppedTrains;
653 for (
const auto& stop : stoppingPlaces) {
654 std::vector<const SUMOVehicle*> stoppedTrains = stop.second->getStoppedVehicles();
656 allStoppedTrainIDs.push_back(train->getNumericalID());
657 allStoppedTrains.push_back(
dynamic_cast<const MSVehicle*
>(train));
662 if (!allStoppedTrainIDs.empty()) {
663 std::vector<GEOSGeometry*> carriagePolygons;
664 std::vector<GEOSGeometry*> rampPolygons;
665 for (
const MSVehicle* train : allStoppedTrains) {
666 if (train->getLeavingPersonNumber() > 0) {
670 const std::vector<MSTrainHelper::Carriage*>& carriages = trainHelper.
getCarriages();
672 Position dir = carriage->front - carriage->back;
681 carriageShape.push_back(carriage->front + perp * p);
682 carriageShape.push_back(carriage->back + perp * p);
683 carriageShape.push_back(carriage->back - perp * p);
684 carriageShape.push_back(carriage->front - perp * p);
689 for (
const Position& door : carriage->doorPositions) {
691 rampShape.push_back(door - perp * p + dir * d);
692 rampShape.push_back(door - perp * p - dir * d);
693 rampShape.push_back(door + perp * p - dir * d);
694 rampShape.push_back(door + perp * p + dir * d);
700 if (!carriagePolygons.empty()) {
701 GEOSGeometry* carriagesCollection = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, carriagePolygons.data(), (
unsigned int)carriagePolygons.size());
702 GEOSGeometry* rampsCollection = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, rampPolygons.data(), (
unsigned int)rampPolygons.size());
703 GEOSGeometry* carriagesAndRampsUnion = GEOSUnion(carriagesCollection, rampsCollection);
704 if (carriagesAndRampsUnion ==
nullptr) {
708#ifdef DEBUG_GEOMETRY_GENERATION
711 int nbrComponents = 0;
712 double maxArea = 0.0;
713 double totalArea = 0.0;
714 const GEOSGeometry* pedestrianNetworkWithTrainsAndRampsLargestComponent =
getLargestComponent(pedestrianNetworkWithTrainsAndRamps, nbrComponents, maxArea, totalArea);
715 if (nbrComponents > 1) {
716 WRITE_WARNINGF(
TL(
"While generating geometry % connected components were detected, %% of total pedestrian area is covered by the largest."),
717 nbrComponents, maxArea / totalArea * 100.0,
"%");
719#ifdef DEBUG_GEOMETRY_GENERATION
725 WRITE_WARNINGF(
TL(
"While switching to train geometry: %"), JPS_ErrorMessage_GetMessage(message));
729 GEOSGeom_destroy(pedestrianNetworkWithTrainsAndRamps);
731 GEOSGeom_destroy(rampsCollection);
732 GEOSGeom_destroy(carriagesCollection);
738 WRITE_WARNINGF(
TL(
"While switching to default geometry: %"), JPS_ErrorMessage_GetMessage(message));
747 JPS_ErrorMessage_Free(message);
768 GEOSGeometry* lineString = GEOSGeom_createLineString(coordinateSequence);
770 GEOSGeom_destroy(lineString);
771 return dilatedLineString;
778 if (shape.size() == 1) {
779 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' will be skipped as it is just a point."), shapeID, junctionID);
783 if (shape.back() != shape.front()) {
784 shape.push_back(shape.front());
788 cleanShape.push_back(shape[0]);
790 for (
int i = 1; i < (int)shape.size(); i++) {
791 if (shape[i] != shape[i - 1]) {
792 cleanShape.push_back(shape[i]);
794 duplicates.push_back(shape[i]);
797 if (cleanShape.size() < shape.size()) {
798 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' had some equal consecutive points removed: %"), shapeID, junctionID,
toString(duplicates, 9));
801 GEOSGeometry* linearRing = GEOSGeom_createLinearRing(coordinateSequence);
802 GEOSGeometry* polygon = GEOSGeom_createPolygon(linearRing,
nullptr, 0);
804 if (!GEOSisValid(polygon)) {
805 if (cleanShape.size() == 3) {
806 if (isInternalShape) {
807 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' has been dilated as it is just a segment."), shapeID, junctionID);
809 WRITE_WARNINGF(
TL(
"Polygon '%' has been dilated as it is just a segment."), shapeID);
811 GEOSGeometry* lineString = GEOSGeom_createLineString(GEOSCoordSeq_clone(coordinateSequence));
812 GEOSGeom_destroy(polygon);
814 GEOSGeom_destroy(lineString);
816 if (isInternalShape) {
817 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' has been replaced by its convex hull as it is not simple."), shapeID, junctionID);
818 GEOSGeometry* hull = GEOSConvexHull(polygon);
819 GEOSGeom_destroy(polygon);
822 WRITE_WARNINGF(
TL(
"Polygon '%' at junction '%' will be skipped as it is not simple."), shapeID, junctionID);
831 if (isInternalShape) {
841 std::vector<GEOSGeometry*> walkableAreas;
843 const MSLane*
const lane = getSidewalk<MSEdge, MSLane>(edge);
844 if (lane !=
nullptr) {
845 GEOSGeometry* dilatedLane =
nullptr;
846 if (edge->isWalkingArea()) {
848 }
else if (edge->isCrossing()) {
850 if (outlineShape !=
nullptr) {
853 if (dilatedLane !=
nullptr) {
854 walkableAreas.push_back(dilatedLane);
864 if (dilatedLane !=
nullptr) {
865 walkableAreas.push_back(dilatedLane);
870 const MSJunction*
const junction = junctionWithID.second;
871 int pedEdgeCount = 0;
872 bool hasWalkingArea =
false;
876 for (
const MSEdge*
const edge : edges) {
877 if (edge->isWalkingArea()) {
878 hasWalkingArea =
true;
881 if (getSidewalk<MSEdge, MSLane>(edge) !=
nullptr) {
885 if (hasWalkingArea) {
889 if (!hasWalkingArea && pedEdgeCount > 1) {
892 if (walkingAreaGeom !=
nullptr) {
893 walkableAreas.push_back(walkingAreaGeom);
899 std::vector<GEOSGeometry*> additionalObstacles;
901 if (polygonWithID.second->getShapeType() ==
"jupedsim.walkable_area" || polygonWithID.second->getShapeType() ==
"taz") {
902 GEOSGeometry* walkableArea =
createGeometryFromShape(polygonWithID.second->getShape(), std::string(
""), polygonWithID.first);
903 if (walkableArea !=
nullptr) {
904 walkableAreas.push_back(walkableArea);
907 }
else if (polygonWithID.second->getShapeType() ==
"jupedsim.obstacle") {
908 GEOSGeometry* additionalObstacle =
createGeometryFromShape(polygonWithID.second->getShape(), std::string(
""), polygonWithID.first);
909 if (additionalObstacle !=
nullptr) {
910 additionalObstacles.push_back(additionalObstacle);
916 GEOSGeometry* disjointWalkableAreas = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, walkableAreas.data(), (
unsigned int)walkableAreas.size());
917#ifdef DEBUG_GEOMETRY_GENERATION
920 GEOSGeometry* initialWalkableAreas = GEOSUnaryUnion(disjointWalkableAreas);
921#ifdef DEBUG_GEOMETRY_GENERATION
922 dumpGeometry(initialWalkableAreas,
"initialWalkableAreas.wkt");
924 GEOSGeom_destroy(disjointWalkableAreas);
927 GEOSGeometry* disjointAdditionalObstacles = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, additionalObstacles.data(), (
unsigned int)additionalObstacles.size());
928#ifdef DEBUG_GEOMETRY_GENERATION
931 GEOSGeometry* additionalObstaclesUnion = GEOSUnaryUnion(disjointAdditionalObstacles);
932#ifdef DEBUG_GEOMETRY_GENERATION
933 dumpGeometry(additionalObstaclesUnion,
"additionalObstaclesUnion.wkt");
935 GEOSGeometry* finalWalkableAreas = GEOSDifference(initialWalkableAreas, additionalObstaclesUnion);
936#ifdef DEBUG_GEOMETRY_GENERATION
937 dumpGeometry(finalWalkableAreas,
"finalWalkableAreas.wkt");
939 GEOSGeom_destroy(initialWalkableAreas);
940 GEOSGeom_destroy(additionalObstaclesUnion);
941 GEOSGeom_destroy(disjointAdditionalObstacles);
943 if (!GEOSisSimple(finalWalkableAreas)) {
944 throw ProcessError(
TL(
"Union of walkable areas minus union of obstacles is not a simple polygon."));
947 return finalWalkableAreas;
953 GEOSCoordSequence* coordinateSequence = GEOSCoordSeq_create((
unsigned int)shape.size(), 2);
954 for (
int i = 0; i < (int)shape.size(); i++) {
955 GEOSCoordSeq_setX(coordinateSequence, i, shape[i].x());
956 GEOSCoordSeq_setY(coordinateSequence, i, shape[i].y());
958 return coordinateSequence;
965 const GEOSCoordSequence* coordinateSequence = GEOSGeom_getCoordSeq(geometry);
966 unsigned int coordinateSequenceSize;
967 GEOSCoordSeq_getSize(coordinateSequence, &coordinateSequenceSize);
970 for (
unsigned int i = 0; i < coordinateSequenceSize; i++) {
971 GEOSCoordSeq_getX(coordinateSequence, i, &x);
972 GEOSCoordSeq_getY(coordinateSequence, i, &y);
973 coordinateVector.push_back(
Position(x, y));
975 return coordinateVector;
979std::vector<JPS_Point>
981 std::vector<JPS_Point> pointVector;
982 const GEOSCoordSequence* coordinateSequence = GEOSGeom_getCoordSeq(geometry);
983 unsigned int coordinateSequenceSize;
984 GEOSCoordSeq_getSize(coordinateSequence, &coordinateSequenceSize);
988 for (
unsigned int i = 0; i < coordinateSequenceSize - 1; i++) {
989 GEOSCoordSeq_getX(coordinateSequence, i, &x);
990 GEOSCoordSeq_getY(coordinateSequence, i, &y);
991 pointVector.push_back({x, y});
1000 GEOSGeometry* linearRingAsPolygon = GEOSGeom_createPolygon(GEOSGeom_clone(linearRing),
nullptr, 0);
1001 GEOSArea(linearRingAsPolygon, &area);
1002 GEOSGeom_destroy(linearRingAsPolygon);
1015 const GEOSGeometry* exterior = GEOSGetExteriorRing(polygon);
1019 std::vector<PositionVector> holes;
1020 int nbrInteriorRings = GEOSGetNumInteriorRings(polygon);
1021 if (nbrInteriorRings != -1) {
1022 for (
int k = 0; k < nbrInteriorRings; k++) {
1023 const GEOSGeometry* linearRing = GEOSGetInteriorRingN(polygon, k);
1037 nbrComponents = GEOSGetNumGeometries(polygon);
1038 const GEOSGeometry* largestComponent =
nullptr;
1041 for (
int i = 0; i < nbrComponents; i++) {
1042 const GEOSGeometry* componentPolygon = GEOSGetGeometryN(polygon, i);
1044 GEOSArea(componentPolygon, &area);
1046 if (area > maxArea) {
1048 largestComponent = componentPolygon;
1051 return largestComponent;
1057 JPS_GeometryBuilder geometryBuilder = JPS_GeometryBuilder_Create();
1060 const GEOSGeometry* exterior = GEOSGetExteriorRing(polygon);
1062 JPS_GeometryBuilder_AddAccessibleArea(geometryBuilder, exteriorCoordinates.data(), exteriorCoordinates.size());
1065 int nbrInteriorRings = GEOSGetNumInteriorRings(polygon);
1066 if (nbrInteriorRings != -1) {
1067 for (
int k = 0; k < nbrInteriorRings; k++) {
1068 const GEOSGeometry* linearRing = GEOSGetInteriorRingN(polygon, k);
1072 JPS_GeometryBuilder_ExcludeFromAccessibleArea(geometryBuilder, holeCoordinates.data(), holeCoordinates.size());
1077 JPS_ErrorMessage message =
nullptr;
1078 JPS_Geometry geometry = JPS_GeometryBuilder_Build(geometryBuilder, &message);
1079 if (geometry ==
nullptr) {
1080 const std::string error =
TLF(
"Error while generating geometry: %", JPS_ErrorMessage_GetMessage(message));
1081 JPS_ErrorMessage_Free(message);
1084 JPS_GeometryBuilder_Free(geometryBuilder);
1091 GEOSGeometry* polygonGeoCoordinates =
nullptr;
1092 if (useGeoCoordinates) {
1093 const GEOSGeometry* exterior = GEOSGetExteriorRing(polygon);
1095 for (
Position& position : exteriorPoints) {
1098 const int nbrInteriorRings = GEOSGetNumInteriorRings(polygon);
1099 std::vector<GEOSGeometry*> holeRings;
1100 if (nbrInteriorRings != -1) {
1101 for (
int k = 0; k < nbrInteriorRings; k++) {
1102 const GEOSGeometry* linearRing = GEOSGetInteriorRingN(polygon, k);
1104 for (
Position& position : holePoints) {
1108 GEOSGeometry* holeRing = GEOSGeom_createLinearRing(holeRingCoords);
1109 holeRings.push_back(holeRing);
1113 GEOSGeometry* exteriorRing = GEOSGeom_createLinearRing(exteriorRingCoords);
1114 polygonGeoCoordinates = GEOSGeom_createPolygon(exteriorRing, holeRings.data(), nbrInteriorRings);
1116 std::ofstream dumpFile;
1117 dumpFile.open(filename);
1118 GEOSWKTWriter* writer = GEOSWKTWriter_create();
1120 char* wkt = GEOSWKTWriter_write(writer, polygonGeoCoordinates ==
nullptr ? polygon : polygonGeoCoordinates);
1121 dumpFile << wkt << std::endl;
1124 GEOSWKTWriter_destroy(writer);
1125 GEOSGeom_destroy(polygonGeoCoordinates);
1137 JPS_ErrorMessage message =
nullptr;
1138 JPS_StageId waitingStage = 0;
1142 const double offset = 2 * radius + POSITION_EPS;
1143 const double lonOffset = entry ? NUMERICAL_EPS : shape.
length() - NUMERICAL_EPS;
1146 for (
double latOff = offset; latOff < crossing->
getWidth() / 2. - offset; latOff += offset) {
1154 pv.push_back(crossing->
getIncomingLanes().front().lane->getShape().getCentroid());
1156 if (!entry && crossing->
getLinkCont().size() == 1 && crossing->
getLinkCont().front()->getLane()->isWalkingArea()) {
1157 pv.push_back(crossing->
getLinkCont().front()->getLane()->getShape().getCentroid());
1159 std::vector<JPS_Point> points;
1161 GEOSCoordSequence* seq = GEOSCoordSeq_create(1, 2);
1162 GEOSCoordSeq_setX(seq, 0, p.x());
1163 GEOSCoordSeq_setY(seq, 0, p.y());
1164 GEOSGeometry* point = GEOSGeom_createPoint(seq);
1166 points.push_back({p.x(), p.y()});
1168 WRITE_WARNINGF(
"Waiting point %,% is not in the geometry for % on '%'.", p.x(), p.y(), entry ?
"entry" :
"exit", crossing->
getID())
1170 GEOSGeom_destroy(point);
1172 waitingStage = JPS_Simulation_AddStageWaitingSet(
myJPSSimulation, points.data(), points.size(), &message);
1173 if (message !=
nullptr) {
1174 const std::string error =
TLF(
"Error while adding waiting set for % on '%': %",
1175 entry ?
"entry" :
"exit", crossing->
getID(), JPS_ErrorMessage_GetMessage(message));
1176 JPS_ErrorMessage_Free(message);
1179 const auto proxy = JPS_Simulation_GetWaitingSetProxy(
myJPSSimulation, waitingStage, &message);
1180 JPS_WaitingSetProxy_SetWaitingSetState(proxy, JPS_WaitingSet_Inactive);
1183 (*myPythonScript) <<
"ws = simulation.add_waiting_set_stage([";
1184 for (
const JPS_Point& p : points) {
1185 (*myPythonScript) <<
"(" << p.x <<
"," << p.y <<
"),";
1187 (*myPythonScript) <<
"])\nsimulation.get_stage(ws).state = jps.stages.WaitingSetState.INACTIVE\n";
1189 return waitingStage;
1195 initGEOS(
nullptr,
nullptr);
1198 int nbrComponents = 0;
1199 double maxArea = 0.0;
1200 double totalArea = 0.0;
1202 if (nbrComponents > 1) {
1203 WRITE_WARNINGF(
TL(
"While generating geometry % connected components were detected, %% of total pedestrian area is covered by the largest."),
1204 nbrComponents, maxArea / totalArea * 100.0,
"%");
1206#ifdef DEBUG_GEOMETRY_GENERATION
1209 const std::string filename = oc.
getString(
"pedestrian.jupedsim.wkt");
1210 if (!filename.empty()) {
1218 JPS_ErrorMessage message =
nullptr;
1220 double strengthGeometryRepulsion = oc.
getFloat(
"pedestrian.jupedsim.strength-geometry-repulsion");
1221 double rangeGeometryRepulsion = oc.
getFloat(
"pedestrian.jupedsim.range-geometry-repulsion");
1223 if (oc.
isDefault(
"pedestrian.jupedsim.strength-geometry-repulsion") && oc.
isDefault(
"pedestrian.jupedsim.range-geometry-repulsion")) {
1224 WRITE_MESSAGE(
TL(
"Adapting geometry repulsion default values for jupedsim timestep of 0.02."));
1225 strengthGeometryRepulsion = 35.;
1226 rangeGeometryRepulsion = 0.019;
1232 JPS_CollisionFreeSpeedModelBuilder modelBuilder = JPS_CollisionFreeSpeedModelBuilder_Create(
1233 oc.
getFloat(
"pedestrian.jupedsim.strength-neighbor-repulsion"),
1234 oc.
getFloat(
"pedestrian.jupedsim.range-neighbor-repulsion"),
1235 strengthGeometryRepulsion,
1236 rangeGeometryRepulsion);
1238 JPS_CollisionFreeSpeedModelBuilder_Free(modelBuilder);
1242 JPS_CollisionFreeSpeedModelV2Builder modelBuilder = JPS_CollisionFreeSpeedModelV2Builder_Create();
1244 JPS_CollisionFreeSpeedModelV2Builder_Free(modelBuilder);
1248 if (oc.
isDefault(
"pedestrian.jupedsim.strength-geometry-repulsion")) {
1249 strengthGeometryRepulsion = 0.2;
1251 JPS_GeneralizedCentrifugalForceModelBuilder modelBuilder = JPS_GeneralizedCentrifugalForceModelBuilder_Create(
1252 oc.
isDefault(
"pedestrian.jupedsim.strength-neighbor-repulsion") ? 0.3 : oc.
getFloat(
"pedestrian.jupedsim.strength-neighbor-repulsion"),
1253 strengthGeometryRepulsion,
1261 JPS_GeneralizedCentrifugalForceModelBuilder_Free(modelBuilder);
1265 JPS_SocialForceModelBuilder modelBuilder = JPS_SocialForceModelBuilder_Create(120000.0, 240000.0);
1267 JPS_SocialForceModelBuilder_Free(modelBuilder);
1273 const std::string error =
TLF(
"Error creating the pedestrian model: %", JPS_ErrorMessage_GetMessage(message));
1274 JPS_ErrorMessage_Free(message);
1279 const std::string error =
TLF(
"Error creating the simulation: %", JPS_ErrorMessage_GetMessage(message));
1280 JPS_ErrorMessage_Free(message);
1290 (*myPythonScript) <<
"import jupedsim as jps\nimport shapely\n\n"
1291 "with open('" << filename <<
"') as f: geom = shapely.from_wkt(f.read())\n"
1292 "simulation = jps.Simulation(dt=" <<
STEPS2TIME(
myJPSDeltaT) <<
", model=jps.CollisionFreeSpeedModel(), geometry=geom,\n"
1293 "trajectory_writer=jps.SqliteTrajectoryWriter(output_file='out.sql'))\n";
1304 for (
auto areaIt =
myAreas.begin(); areaIt !=
myAreas.end(); ++areaIt) {
1305 if (poly->
getID() == (*areaIt)->id) {
1306 lastRemovalTime = (*areaIt)->lastRemovalTime;
1313 std::vector<JPS_Point> areaBoundary;
1315 areaBoundary.push_back({p.x(), p.y()});
1318 if (areaBoundary.back().x == areaBoundary.front().x && areaBoundary.back().y == areaBoundary.front().y) {
1319 areaBoundary.pop_back();
1332 JPS_JourneyId journeyId, JPS_StageId stageId,
1333 const std::vector<WaypointDesc>& waypoints) :
1335 myJourneyId(journeyId), myStageId(stageId), myWaypoints(waypoints), myAgentId(0) {
1342 const std::vector<WaypointDesc>& waypoints) {
1343 if (myStage !=
nullptr) {
1344 myStage->setPState(
nullptr);
1347 myJourneyId = journeyId;
1348 myStageId = stageId;
1349 myWaypoints = waypoints;
1363 myRemoteXYPos.set(x, y, z);
1374 return offset < (int)myWaypoints.size() ? &myWaypoints[offset] :
nullptr;
std::vector< const MSEdge * > ConstMSEdgeVector
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGEF(...)
#define WRITE_ERRORF(...)
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const std::string DEFAULT_PEDTYPE_ID
@ RANDOM_LOCATION
The position may be chosen freely in a polygon defined by a taz.
@ SUMO_TAG_BUS_STOP
A bus stop.
const double SUMO_const_laneWidth
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A class that stores a 2D geometrical boundary.
double ymin() const
Returns minimum y-coordinate.
double xmin() const
Returns minimum x-coordinate.
double ymax() const
Returns maximum y-coordinate.
double xmax() const
Returns maximum x-coordinate.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
const MSEdgeVector & getEdges() const
Returns loaded edges.
A road/street connecting two junctions.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
bool isNormal() const
return whether this edge is an internal edge
const MSJunction * getToJunction() const
const MSJunction * getFromJunction() const
bool isTazConnector() const
double getWidth() const
Returns the edges's width (sum over all lanes)
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
The base class for an intersection.
const ConstMSEdgeVector & getOutgoing() const
const PositionVector & getShape() const
Returns this junction's shape.
const ConstMSEdgeVector & getIncoming() const
Representation of a lane in the micro simulation.
const MSLink * getLinkTo(const MSLane *const) const
returns the link to the given lane or nullptr, if it is not connected
double getSpeedLimit() const
Returns the lane's maximum allowed speed.
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
MSLane * getLogicalPredecessorLane() const
get the most likely predecessor lane (sorted using by_connections_to_sorter). The result is cached in...
virtual const PositionVector & getShape(bool) const
MSEdge & getEdge() const
Returns the lane's edge.
const PositionVector * getOutlineShape() const
double getWidth() const
Returns the lane's width.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
bool opened(SUMOTime arrivalTime, double arrivalSpeed, double leaveSpeed, double vehicleLength, double impatience, double decel, SUMOTime waitingTime, double posLat=0, BlockingFoes *collectFoes=nullptr, bool ignoreRed=false, const SUMOTrafficObject *ego=nullptr, double dist=-1) const
Returns the information whether the link may be passed.
const MSTrafficLightLogic * getTLLogic() const
Returns the TLS index.
The simulated network and simulation perfomer.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
MSJunctionControl & getJunctionControl()
Returns the junctions control.
MSPedestrianRouter & getPedestrianRouter(int rngIndex, const Prohibitions &prohibited={}) const
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
ShapeContainer & getShapeContainer()
Returns the shapes container.
MSEdgeControl & getEdgeControl()
Returns the edge control.
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
ActiveLanes myActiveLanes
store of all lanes which have pedestrians on them
int myNumActivePedestrians
the total number of active pedestrians
Container for pedestrian state and individual position update function.
MSStageMoving * getStage() const
return the current stage
int myDir
the walking direction on the current lane (1 forward, -1 backward)
virtual double getAngle(const MSStageMoving &, SUMOTime) const
return the current orientation in degrees
double getEdgePos(SUMOTime) const
abstract methods inherited from MSTransportableStateAdapter
MSPerson * getPerson() const
return the represented person
bool isWaitingToEnter() const
whether the person still waits to entere the network
const MSLane * getLane() const
the current lane of the transportable
double getSpeed() const
return the current speed of the transportable, we need to be able to do this for vehicles as well,...
Holds pedestrian state and performs updates.
JPS_AgentId getAgentId() const
JPS_JourneyId getJourneyId() const
void setAngle(double angle)
void reinit(MSStageMoving *stage, JPS_JourneyId journeyId, JPS_StageId stageId, const std::vector< WaypointDesc > &waypoints)
const MSPModel_JuPedSim_legacy::WaypointDesc * getNextWaypoint(const int offset=0) const
const MSEdge * getNextEdge(const MSStageMoving &stage) const override
return the list of internal edges if the transportable is on an intersection
void setStage(MSStageMoving *const stage)
void setAgentId(JPS_AgentId id)
void setPosition(const double x, const double y, const double z=0.)
JPS_StageId getStageId() const
first stage of the journey
bool advanceNextWaypoint()
void setLanePosition(double lanePosition)
Position getPosition(const MSStageMoving &, SUMOTime) const override
return the network coordinate of the transportable
PState(MSPerson *person, MSStageMoving *stage, JPS_JourneyId journeyId, JPS_StageId stageId, const std::vector< WaypointDesc > &waypoints)
void setLane(MSLane *lane)
void polygonChanged(const SUMOPolygon *const poly, const bool added, const bool removed) override
SUMOTime execute(SUMOTime time)
JPS_Geometry myJPSGeometryWithTrainsAndRamps
The JPS polygon representing the largest connected component plus carriages and ramps.
JPS_Geometry myJPSGeometry
The JPS polygon representing the largest connected component of the pedestrian network.
static const RGBColor PEDESTRIAN_NETWORK_CARRIAGES_AND_RAMPS_COLOR
static const double GEOS_MITRE_LIMIT
void initialize(const OptionsCont &oc)
void clearState() override
Resets pedestrians when quick-loading state.
static JPS_Geometry buildJPSGeometryFromGEOSGeometry(const GEOSGeometry *polygon)
static GEOSCoordSequence * convertToGEOSPoints(PositionVector shape)
static PositionVector convertToSUMOPoints(const GEOSGeometry *geometry)
static double getRadius(const MSVehicleType &vehType)
static const double GEOS_BUFFERED_SEGMENT_WIDTH
GEOSGeometry * buildPedestrianNetwork(MSNet *network)
static const int GEOS_QUADRANT_SEGMENTS
void registerArrived(const JPS_AgentId agentID)
static void dumpGeometry(const GEOSGeometry *polygon, const std::string &filename, bool useGeoCoordinates=false)
void preparePolygonForDrawing(const GEOSGeometry *polygon, const std::string &polygonId, const RGBColor &color)
std::map< const MSLane *, std::pair< JPS_StageId, JPS_StageId >, ComparatorNumericalIdLess > myCrossingWaits
const SUMOTime myJPSDeltaT
Timestep used in the JuPedSim simulator.
bool addWaypoint(JPS_JourneyDescription journey, JPS_StageId &predecessor, const std::string &agentID, const WaypointDesc &waypoint)
GEOSGeometry * myGEOSPedestrianNetwork
The GEOS polygon containing all computed connected components of the pedestrian network.
JPS_StageId addWaitingSet(const MSLane *const crossing, const bool entry)
MSNet *const myNetwork
The network on which the simulation runs.
void removePolygonFromDrawing(const std::string &polygonId)
~MSPModel_JuPedSim_legacy()
JPS_OperationalModel myJPSOperationalModel
static const GEOSGeometry * getLargestComponent(const GEOSGeometry *polygon, int &nbrComponents, double &maxArea, double &totalArea)
JPS_Simulation myJPSSimulation
static const std::vector< MSPModel_JuPedSim_legacy::PState * > noPedestrians
void tryPedestrianInsertion(PState *state, const Position &p)
static GEOSGeometry * createGeometryFromCenterLine(PositionVector centerLine, double width, int capStyle)
MSTransportableStateAdapter * add(MSTransportable *person, MSStageMoving *stage, SUMOTime now) override
register the given person as a pedestrian
MSPModel_JuPedSim_legacy(const OptionsCont &oc, MSNet *net)
static std::vector< JPS_Point > convertToJPSPoints(const GEOSGeometry *geometry)
ShapeContainer & myShapeContainer
The shape container used to add polygons to the rendering pipeline.
OutputDevice * myPythonScript
@ GeneralizedCentrifugalForce
std::vector< std::unique_ptr< AreaData > > myAreas
Array of special areas.
void remove(MSTransportableStateAdapter *state) override
remove the specified person from the pedestrian simulation
bool addStage(JPS_JourneyDescription journey, JPS_StageId &predecessor, const std::string &agentID, const JPS_StageId stage)
static double getLinearRingArea(const GEOSGeometry *linearRing)
std::vector< SUMOTrafficObject::NumericalID > myAllStoppedTrainIDs
Array of stopped trains, used to detect whether to add carriages and ramps to the geometry.
static const std::string PEDESTRIAN_NETWORK_CARRIAGES_AND_RAMPS_ID
static GEOSGeometry * createGeometryFromShape(PositionVector shape, std::string junctionID=std::string(""), std::string shapeID=std::string(""), bool isInternalShape=false)
std::vector< PState * > myPedestrianStates
SumoRNG myRNG
The random number generator for fluctuations on insertion.
static const std::string PEDESTRIAN_NETWORK_ID
const double myExitTolerance
Threshold to decide if a pedestrian has ended its journey or not.
std::map< JPS_StageId, const MSLane * > myCrossings
const GEOSGeometry * myGEOSPedestrianNetworkLargestComponent
The GEOS polygon representing the largest (by area) connected component of the pedestrian network.
static const RGBColor PEDESTRIAN_NETWORK_COLOR
std::tuple< JPS_StageId, Position, double > WaypointDesc
static const double GEOS_MIN_AREA
bool myHaveAdditionalWalkableAreas
static const int BACKWARD
static const double RANDOM_POS_LAT
magic value to encode randomized lateral offset for persons when starting a walk
static const int UNDEFINED_DIRECTION
static const double UNSPECIFIED_POS_LAT
the default lateral offset for persons when starting a walk
double getImpatience() const
const MSEdge * getDestination() const
returns the destination edge
virtual double getArrivalPos() const
virtual const MSEdge * getEdge() const
Returns the current edge.
virtual const MSEdge * getNextRouteEdge() const =0
ConstMSEdgeVector getEdges() const
the edges of the current stage
const std::vector< const MSEdge * > & getRoute() const
void setPState(MSTransportableStateAdapter *pstate)
double getDepartPosLat() const
const MSEdge * getEdge() const
Returns the current edge.
double getDepartPos() const
const std::vector< constMSEdge * >::iterator getRouteStep() const
virtual bool moveToNextEdge(MSTransportable *transportable, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr, const bool isReplay=false)=0
move forward and return whether the transportable arrived
virtual double getMaxSpeed(const MSTransportable *const transportable=nullptr) const =0
the maximum speed of the transportable
bool moveToNextEdge(MSTransportable *person, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr, const bool isReplay=false)
move forward and return whether the person arrived
void activateMoveReminders(MSTransportable *person, double oldPos, double newPos, double newSpeed)
void activateEntryReminders(MSTransportable *person, const bool isDepart=false)
add the move reminders for the current lane on entry
A class that helps computing positions of a train's carriages and additional structures.
void computeDoorPositions()
compute door positions on demand and fills the carriage structures
const std::vector< Carriage * > & getCarriages() const
double getHalfWidth() const
virtual double getSpeed() const override
the current speed of the transportable
MSStage * getNextStage(int offset) const
Return the next (or previous) stage denoted by the offset.
int getNumRemainingStages() const
Return the number of remaining stages (including the current)
MSStage * getCurrentStage() const
Return the current stage.
SUMOVehicleClass getVClass() const override
Returns the object's access class.
double getMaxSpeed() const override
Returns the maximum speed (the minimum of desired and physical maximum speed)
const SUMOVTypeParameter & getVTypeParameter() const override
Returns the object's "vehicle" type parameter.
int getCurrentStageIndex() const
Return the index of the current stage.
MSStageType getCurrentStageType() const
the current stage type of the transportable
const SUMOVehicleParameter & getParameter() const override
Returns the vehicle's parameter (including departure definition)
const MSVehicleType & getVehicleType() const override
Returns the object's "vehicle" type.
const MSEdge * getEdge() const override
Returns the current edge.
abstract base class for managing callbacks to retrieve various state information from the model
Representation of a vehicle in the micro simulation.
The car-following model and parameter.
double getWidth() const
Get the width which vehicles of this class shall have when being drawn.
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
T get(const std::string &id) const
Retrieves an item.
A storage for options typed value containers)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="", const int maximumDepth=2)
Creates the device using the output definition stored in the named option.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
double getDouble(const std::string &key, const double defaultValue) const
Returns the value for a given key converted to a double.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
double compute(const E *from, const E *to, double departPos, double arrivalPos, double speed, SUMOTime msTime, const N *onlyNode, const SUMOVTypeParameter &pars, std::vector< const E * > &into, bool allEdges=false) const
Builds the route between the given edges using the minimum effort at the given time The definition of...
A point in 2D or 3D with translation and scaling methods.
void setx(double x)
set position x
static const Position INVALID
used to indicate that a position is valid
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
void norm2D()
Normalizes the given vector.
double x() const
Returns the x-position.
double length2D() const
Computes the length of the given vector neglecting the z coordinate.
void sety(double y)
set position y
double y() const
Returns the y-position.
double length() const
Returns the length.
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
void move2side(double amount, double maxExtension=100)
move position vector to side using certain amount
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
void extrapolate2D(const double val, const bool onlyFirst=false)
extrapolate position vector in two dimensions (Z is ignored)
bool around(const Position &p, double offset=0) const
Returns the information whether the position vector describes a polygon lying around the given point.
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
const PositionVector & getShape() const
Returns the shape of the polygon.
virtual void setHoles(const std::vector< PositionVector > &holes)
Sets the holes of the polygon.
double getFloatParam(const std::string ¶mName, const bool required=false, const double deflt=INVALID_DOUBLE, bool checkDist=true) const
Retrieve a floating point parameter for the traffic object.
Structure representing possible vehicle parameter.
double maxPlatformDistance
the maximum distance between platform and train
double carriageDoorWidth
the width of the carriage doors
Representation of a vehicle.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
void addShapeListener(ShapeListener *listener)
virtual bool removePolygon(const std::string &id, bool useLock=true)
Removes a polygon from the container.
const Polygons & getPolygons() const
Returns all polygons.
virtual bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, const PositionVector &shape, bool geo, bool fill, double lineWidth, bool ignorePruning=false, const std::string &name=Shape::DEFAULT_NAME)
Builds a polygon using the given values and adds it to the container.
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
std::vector< std::string > getVector()
return vector of strings
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static void initRandGlobal(SumoRNG *which=nullptr)
Reads the given random number options and initialises the random number generator in accordance.
static bool moveToXYMap_matchingRoutePosition(const Position &pos, const std::string &origID, const ConstMSEdgeVector ¤tRoute, int routeIndex, SUMOVehicleClass vClass, bool setLateralPos, double &bestDistance, MSLane **lane, double &lanePos, int &routeOffset)
#define UNUSED_PARAMETER(x)
Structure that keeps data related to vanishing areas (and other types of areas).