22 package org.matsim.core.router;
24 import org.apache.logging.log4j.LogManager;
25 import org.apache.logging.log4j.Logger;
30 import java.util.ArrayList;
31 import java.util.List;
51 modeHierarchy.add(
"undefined" ) ;
67 modeHierarchy.add(
"freight" ) ;
76 int mainModeIndex = -1 ;
77 String unknownMode = null;
79 if (pe instanceof
Leg leg) {
80 int index = modeHierarchy.indexOf( leg.getMode() ) ;
90 if (unknownMode != null && !unknownMode.equals(leg.getMode())) {
91 log.error(
"Multiple unknown modes in one trip: " + leg.getMode() +
" and " + unknownMode +
". The AnalysisMainModeIdentifier" +
92 " cannot determine which of those is the main mode because they are both unknown to it. Please bind your own " +
93 "AnalysisMainModeIdentifier that interprets all modes used in your scenario correctly.");
94 throw new IllegalStateException(
"unknown modes in AnalysisMainModeIdentifier: " + leg.getMode() +
" and " + unknownMode ) ;
96 unknownMode = leg.getMode();
99 if ( index > mainModeIndex ) {
100 mainModeIndex = index ;
105 if (unknownMode != null) {
108 log.error(
"Unknown mode " + unknownMode +
" and " + modeHierarchy.get( mainModeIndex ) +
" found in the same trip. The " +
109 "AnalysisMainModeIdentifier cannot determine which of those is the main mode because they are both unknown to it. " +
110 "Please bind your own AnalysisMainModeIdentifier that interprets all modes used in your scenario correctly.");
111 throw new IllegalStateException(
"unknown mode in AnalysisMainModeIdentifier: " + unknownMode);
117 return modeHierarchy.get( mainModeIndex ) ;
static final String other
final List< String > modeHierarchy
static final String truck
DefaultAnalysisMainModeIdentifier()
static final String transit_walk
String identifyMainMode(List<? extends PlanElement > planElements)
static final String non_network_walk
static final String airplane
static final String train
static final String motorcycle