MATSIM
core
population
algorithms
TripsToLegsAlgorithm.java
Go to the documentation of this file.
1
/* *********************************************************************** *
2
* project: org.matsim.*
3
* TripsToLegAlgorithm.java
4
* *
5
* *********************************************************************** *
6
* *
7
* copyright : (C) 2012 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
package
org.matsim.core.population.algorithms;
21
22
import
java.util.List;
23
24
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
Leg
;
25
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
Plan
;
26
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
PlanElement
;
27
import
org
.
matsim
.
core
.
population
.
PopulationUtils
;
28
import
org
.
matsim
.
core
.
router
.
MainModeIdentifier
;
29
import
org
.
matsim
.
core
.
router
.
TripRouter
;
30
import
org
.
matsim
.
core
.
router
.
TripStructureUtils
;
31
import
org
.
matsim
.
core
.
router
.
TripStructureUtils
.
Trip
;
32
40
public
final
class
TripsToLegsAlgorithm
implements
PlanAlgorithm
{
41
private
final
MainModeIdentifier
mainModeIdentifier
;
42
43
public
TripsToLegsAlgorithm
(
final
TripRouter
router) {
44
this
(
TripStructureUtils
.
getRoutingModeIdentifier
() );
45
}
46
47
48
public
TripsToLegsAlgorithm
(
49
final
MainModeIdentifier
mainModeIdentifier) {
50
this.mainModeIdentifier =
mainModeIdentifier
;
51
}
52
53
@Override
54
public
void
run
(
final
Plan
plan) {
55
final
List<PlanElement> planElements = plan.
getPlanElements
();
56
final
List<Trip> trips =
TripStructureUtils
.
getTrips
( plan );
57
58
for
(
Trip
trip : trips ) {
59
final
List<PlanElement> fullTrip =
60
planElements.subList(
61
planElements.indexOf( trip.getOriginActivity() ) + 1,
62
planElements.indexOf( trip.getDestinationActivity() ));
63
final
String mode = mainModeIdentifier.
identifyMainMode
( fullTrip );
64
fullTrip.clear();
65
Leg
leg =
PopulationUtils
.
createLeg
(mode);
66
TripStructureUtils
.
setRoutingMode
(leg, mode);
67
fullTrip.add( leg );
68
if
( fullTrip.size() != 1 )
throw
new
RuntimeException
( fullTrip.toString() );
69
}
70
}
71
}
72
org.matsim.core.population.algorithms.TripsToLegsAlgorithm.run
void run(final Plan plan)
Definition:
TripsToLegsAlgorithm.java:54
org.matsim.core.population.algorithms.TripsToLegsAlgorithm.TripsToLegsAlgorithm
TripsToLegsAlgorithm(final TripRouter router)
Definition:
TripsToLegsAlgorithm.java:43
org.matsim.api.core.v01.population
Definition:
Activity.java:21
org.matsim.core.router.TripStructureUtils
Definition:
TripStructureUtils.java:54
org
org.matsim.core.router.MainModeIdentifier.identifyMainMode
String identifyMainMode(List<? extends PlanElement > tripElements)
RuntimeException
org.matsim.core.router.TripStructureUtils.getRoutingModeIdentifier
static MainModeIdentifier getRoutingModeIdentifier()
Definition:
TripStructureUtils.java:607
org.matsim.core.population
Definition:
ActivityImpl.java:21
org.matsim.api.core.v01.population.PlanElement
Definition:
PlanElement.java:26
org.matsim.api
org.matsim.core.router.TripRouter
Definition:
TripRouter.java:60
org.matsim.core.population.algorithms.PlanAlgorithm
Definition:
PlanAlgorithm.java:25
org.matsim.core
org.matsim.core.router.TripStructureUtils.setRoutingMode
static void setRoutingMode(Leg leg, String mode)
Definition:
TripStructureUtils.java:602
org.matsim.core.router
Definition:
AnalysisMainModeIdentifier.java:20
org.matsim.core.population.algorithms.TripsToLegsAlgorithm.TripsToLegsAlgorithm
TripsToLegsAlgorithm(final MainModeIdentifier mainModeIdentifier)
Definition:
TripsToLegsAlgorithm.java:48
org.matsim.api.core
org.matsim.core.population.PopulationUtils.createLeg
static Leg createLeg(String transportMode)
Definition:
PopulationUtils.java:835
org.matsim.core.router.TripStructureUtils.getTrips
static List< Trip > getTrips(final Plan plan)
Definition:
TripStructureUtils.java:116
org.matsim.api.core.v01.population.Plan.getPlanElements
List< PlanElement > getPlanElements()
org.matsim.core.population.algorithms.TripsToLegsAlgorithm
Definition:
TripsToLegsAlgorithm.java:40
org.matsim.api.core.v01.population.Leg
Definition:
Leg.java:25
org.matsim.core.population.PopulationUtils
Definition:
PopulationUtils.java:88
org.matsim.core.router.MainModeIdentifier
Definition:
MainModeIdentifier.java:29
org.matsim.core.population.algorithms.TripsToLegsAlgorithm.mainModeIdentifier
final MainModeIdentifier mainModeIdentifier
Definition:
TripsToLegsAlgorithm.java:41
org.matsim
org.matsim.api.core.v01.population.Plan
Definition:
Plan.java:39
org.matsim.core.router.TripStructureUtils.Trip
Definition:
TripStructureUtils.java:382
org.matsim.api.core.v01
Definition:
BasicLocation.java:20
Generated by
1.8.13