MATSIM
TransitActsRemover.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * TransitInteractionRemover.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2009 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.pt.router;
22 
30 import org.matsim.pt.PtConstants;
31 
32 import java.util.ArrayList;
33 import java.util.List;
34 
47 @Deprecated
48 public class TransitActsRemover implements PlanAlgorithm {
49 
50  public void run(final Plan plan) {
51  run(plan,false);
52  }
53 
54  public void run(final Plan plan, boolean treatAccessEgressAsTransit) {
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())) {
76  leg.setRoute(null);
77  }
78  }
79  }
80  }
81 
82 }
static void removeActivity(Plan plan, int index)
static final String TRANSIT_ACTIVITY_TYPE
void run(final Plan plan, boolean treatAccessEgressAsTransit)
List< PlanElement > getPlanElements()