MATSIM
analysis
TransportPlanningMainModeIdentifier.java
Go to the documentation of this file.
1
2
/* *********************************************************************** *
3
* project: org.matsim.*
4
* TransportPlanningMainModeIdentifier.java
5
* *
6
* *********************************************************************** *
7
* *
8
* copyright : (C) 2019 by the members listed in the COPYING, *
9
* LICENSE and WARRANTY file. *
10
* email : info at matsim dot org *
11
* *
12
* *********************************************************************** *
13
* *
14
* This program is free software; you can redistribute it and/or modify *
15
* it under the terms of the GNU General Public License as published by *
16
* the Free Software Foundation; either version 2 of the License, or *
17
* (at your option) any later version. *
18
* See also COPYING, LICENSE and WARRANTY file *
19
* *
20
* *********************************************************************** */
21
22
package
org.matsim.analysis;
23
24
import
java.util.ArrayList;
25
import
java.util.List;
26
27
import
org
.
matsim
.
api
.
core
.
v01
.
TransportMode
;
28
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
Leg
;
29
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
PlanElement
;
30
import
org
.
matsim
.
core
.
router
.
AnalysisMainModeIdentifier
;
31
import
org
.
matsim
.
core
.
router
.
MainModeIdentifier
;
32
40
public
final
class
TransportPlanningMainModeIdentifier
implements
AnalysisMainModeIdentifier
{
41
// I am against other people changing this lightheartedly since some of my analysis depends on it. So either please discuss,
42
// or use your own variant. kai, sep'16
43
44
// yyyyyy some variant of this (maybe not exactly this one here) should be able to deal with multi-leg trips. kai/amit, mar'17
45
46
private
final
List<String>
modeHierarchy
=
new
ArrayList<>() ;
47
48
public
TransportPlanningMainModeIdentifier
() {
49
modeHierarchy.add(
TransportMode
.
non_network_walk
) ;
50
modeHierarchy.add(
"undefined"
) ;
51
modeHierarchy.add(
TransportMode
.
other
) ;
52
modeHierarchy.add(
TransportMode
.
transit_walk
) ;
53
modeHierarchy.add(
TransportMode
.
walk
) ;
54
modeHierarchy.add(
TransportMode
.
bike
) ;
55
modeHierarchy.add(
TransportMode
.
drt
) ;
56
modeHierarchy.add(
TransportMode
.
pt
) ;
57
modeHierarchy.add(
TransportMode
.
ride
) ;
58
modeHierarchy.add(
TransportMode
.
car
) ;
59
60
// NOTE: This hierarchical stuff is not so great: is park-n-ride a car trip or a pt trip? Could weigh it by distance, or by time spent
61
// in respective mode. Or have combined modes as separate modes. In any case, can't do it at the leg level, since it does not
62
// make sense to have the system calibrate towards something where we have counted the car and the pt part of a multimodal
63
// trip as two separate trips. kai, sep'16
64
}
65
66
@Override
public
String
identifyMainMode
( List<? extends PlanElement> planElements ) {
67
int
mainModeIndex = -1 ;
68
for
(
PlanElement
pe : planElements ) {
69
if
( pe instanceof
Leg
) {
70
Leg leg = (Leg) pe ;
71
int
index = modeHierarchy.indexOf( leg.
getMode
() ) ;
72
if
( index < 0 ) {
73
throw
new
RuntimeException
(
"unknown mode="
+ leg.
getMode
() ) ;
74
}
75
if
( index > mainModeIndex ) {
76
mainModeIndex = index ;
77
}
78
}
79
}
80
if
( mainModeIndex <= modeHierarchy.indexOf(
TransportMode
.
transit_walk
) ) {
81
mainModeIndex = modeHierarchy.indexOf(
TransportMode
.
walk
) ;
82
}
83
return
modeHierarchy.get( mainModeIndex ) ;
84
}
85
}
org.matsim.api.core.v01.TransportMode.other
static final String other
Definition:
TransportMode.java:56
org.matsim.api.core.v01.population
Definition:
Activity.java:21
org.matsim.api.core.v01.population.Leg.getMode
String getMode()
org.matsim.api.core.v01.TransportMode.car
static final String car
Definition:
TransportMode.java:30
org
org.matsim.analysis.TransportPlanningMainModeIdentifier.modeHierarchy
final List< String > modeHierarchy
Definition:
TransportPlanningMainModeIdentifier.java:46
RuntimeException
org.matsim.core.router.AnalysisMainModeIdentifier
Definition:
AnalysisMainModeIdentifier.java:39
org.matsim.api.core.v01.population.PlanElement
Definition:
PlanElement.java:26
org.matsim.api
org.matsim.api.core.v01.TransportMode.ride
static final String ride
Definition:
TransportMode.java:31
org.matsim.core
org.matsim.core.router
Definition:
AnalysisMainModeIdentifier.java:20
org.matsim.api.core.v01.TransportMode
Definition:
TransportMode.java:28
org.matsim.api.core.v01.TransportMode.drt
static final String drt
Definition:
TransportMode.java:36
org.matsim.api.core.v01.TransportMode.transit_walk
static final String transit_walk
Definition:
TransportMode.java:39
org.matsim.api.core
org.matsim.api.core.v01.TransportMode.pt
static final String pt
Definition:
TransportMode.java:35
org.matsim.api.core.v01.population.Leg
Definition:
Leg.java:25
org.matsim.api.core.v01.TransportMode.bike
static final String bike
Definition:
TransportMode.java:32
org.matsim.analysis.TransportPlanningMainModeIdentifier
Definition:
TransportPlanningMainModeIdentifier.java:40
org.matsim.api.core.v01.TransportMode.non_network_walk
static final String non_network_walk
Definition:
TransportMode.java:54
org.matsim.core.router.MainModeIdentifier
Definition:
MainModeIdentifier.java:29
org.matsim.analysis.TransportPlanningMainModeIdentifier.TransportPlanningMainModeIdentifier
TransportPlanningMainModeIdentifier()
Definition:
TransportPlanningMainModeIdentifier.java:48
org.matsim
org.matsim.analysis.TransportPlanningMainModeIdentifier.identifyMainMode
String identifyMainMode(List<? extends PlanElement > planElements)
Definition:
TransportPlanningMainModeIdentifier.java:66
org.matsim.api.core.v01
Definition:
BasicLocation.java:20
org.matsim.api.core.v01.TransportMode.walk
static final String walk
Definition:
TransportMode.java:38
Generated by
1.8.13