MATSIM
core
router
MainModeIdentifierImpl.java
Go to the documentation of this file.
1
/* *********************************************************************** *
2
* project: org.matsim.*
3
* *
4
* *********************************************************************** *
5
* *
6
* copyright : (C) 2013 by the members listed in the COPYING, *
7
* LICENSE and WARRANTY file. *
8
* email : info at matsim dot org *
9
* *
10
* *********************************************************************** *
11
* *
12
* This program is free software; you can redistribute it and/or modify *
13
* it under the terms of the GNU General Public License as published by *
14
* the Free Software Foundation; either version 2 of the License, or *
15
* (at your option) any later version. *
16
* See also COPYING, LICENSE and WARRANTY file *
17
* *
18
* *********************************************************************** */
19
20
package
org.matsim.core.router;
21
22
import
java.util.List;
23
24
import
org
.
matsim
.
api
.
core
.
v01
.
TransportMode
;
25
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
Leg
;
26
import
org
.
matsim
.
api
.
core
.
v01
.
population
.
PlanElement
;
27
31
public
final
class
MainModeIdentifierImpl
implements
MainModeIdentifier
{
32
@Override
33
public
String
identifyMainMode
(
final
List<? extends PlanElement> tripElements) {
34
String mode = ((
Leg
) tripElements.get( 0 )).getMode();
35
// return mode.equals( TransportMode.transit_walk ) ? TransportMode.pt : mode;
36
if
( mode.equals(
TransportMode
.
transit_walk
) ) {
37
return
TransportMode
.
pt
;
38
39
// (yy not conforming to std transport planning since that would look for mode with the highest "weight"
40
// in the whole trip, but it is what I found and at least one test depends on it. kai, feb'16)
41
42
// Marcel's SBB raptor returns access/egress_walk to and from pt, and transit_walk only
43
// for direct walk (and presumably in between pt legs, if necessary). kai/gregor, sep'18
44
}
45
if
( mode.endsWith(
"_fallback"
) ) {
46
return
mode.substring(0, mode.length() - 9) ;
47
}
48
49
for
(
PlanElement
pe : tripElements ) {
50
if
( pe instanceof
Leg
) {
51
Leg leg = (Leg) pe ;
52
String mode2 = leg.
getMode
() ;
53
if
( !mode2.contains(
TransportMode
.
non_network_walk
) &&
54
!mode2.contains(
TransportMode
.
transit_walk
) ) {
55
return
mode2 ;
56
}
57
}
58
}
59
60
throw
new
RuntimeException
(
"could not identify main mode "
+ tripElements) ;
61
62
}
63
}
org.matsim.api.core.v01.population
Definition:
Activity.java:21
org.matsim.api.core.v01.population.Leg.getMode
String getMode()
org
RuntimeException
org.matsim.core.router.MainModeIdentifierImpl.identifyMainMode
String identifyMainMode(final List<? extends PlanElement > tripElements)
Definition:
MainModeIdentifierImpl.java:33
org.matsim.api.core.v01.population.PlanElement
Definition:
PlanElement.java:26
org.matsim.api
org.matsim.api.core.v01.TransportMode
Definition:
TransportMode.java:28
org.matsim.core.router.MainModeIdentifierImpl
Definition:
MainModeIdentifierImpl.java:31
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.non_network_walk
static final String non_network_walk
Definition:
TransportMode.java:54
org.matsim.core.router.MainModeIdentifier
Definition:
MainModeIdentifier.java:29
org.matsim
org.matsim.api.core.v01
Definition:
BasicLocation.java:20
Generated by
1.8.13