MATSIM
Public Member Functions | List of all members
org.matsim.pt.router.TransitActsRemover Class Reference
Inheritance diagram for org.matsim.pt.router.TransitActsRemover:
Inheritance graph
[legend]

Public Member Functions

void run (final Plan plan)
 
void run (final Plan plan, boolean treatAccessEgressAsTransit)
 

Detailed Description

Removes all transit activities (like "pt -interaction") as well as the legs following those activities. In addition, all legs with mode "transit_walk" are set to mode "pt" to be routed again with the transit.

See also
PtConstants::TRANSIT_ACTIVITY_TYPE
Author
mrieser
Deprecated:
– use org.matsim.core.population.algorithms.TripsToLegsAlgorithm instead to circumvene problems with different types of access / egress legs and stage activities.

Definition at line 48 of file TransitActsRemover.java.

Member Function Documentation

◆ run() [1/2]

void org.matsim.pt.router.TransitActsRemover.run ( final Plan  plan)

Implements org.matsim.core.population.algorithms.PlanAlgorithm.

Definition at line 50 of file TransitActsRemover.java.

50  {
51  run(plan,false);
52  }

◆ run() [2/2]

void org.matsim.pt.router.TransitActsRemover.run ( final Plan  plan,
boolean  treatAccessEgressAsTransit 
)

Definition at line 54 of file TransitActsRemover.java.

References org.matsim.api.core.v01.population.Leg.getMode(), org.matsim.api.core.v01.population.Plan.getPlanElements(), org.matsim.api.core.v01.population.Activity.getType(), org.matsim.api.core.v01.TransportMode.non_network_walk, org.matsim.api.core.v01.TransportMode.pt, org.matsim.core.population.PopulationUtils.removeActivity(), org.matsim.api.core.v01.population.Leg.setMode(), org.matsim.api.core.v01.population.Leg.setRoute(), org.matsim.pt.PtConstants.TRANSIT_ACTIVITY_TYPE, and org.matsim.api.core.v01.TransportMode.transit_walk.

54  {
55  List<String> accessModes = new ArrayList<>();
56  accessModes.add(TransportMode.transit_walk);
57  if (treatAccessEgressAsTransit){
58  accessModes.add(TransportMode.non_network_walk );
59  accessModes.add(TransportMode.non_network_walk );
60  }
61  List<PlanElement> planElements = plan.getPlanElements();
62  for (int i = 0, n = planElements.size(); i < n; i++) {
63  PlanElement pe = planElements.get(i);
64  if (pe instanceof Activity) {
65  Activity act = (Activity) pe;
66  if (PtConstants.TRANSIT_ACTIVITY_TYPE.equals(act.getType())) {
67  final int index = i;
68  PopulationUtils.removeActivity(((Plan) plan), index);
69  n -= 2;
70  i--; // i will be incremented again in next loop-iteration, so we'll check the next act
71  }
72  } else if (pe instanceof Leg) {
73  Leg leg = (Leg) pe;
74  if (accessModes.contains(leg.getMode())) {
75  leg.setMode(TransportMode.pt);
76  leg.setRoute(null);
77  }
78  }
79  }
80  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: