MATSIM
FallbackRoutingModuleDefaultImpl.java
Go to the documentation of this file.
1 package org.matsim.core.router;
2 
3 import com.google.inject.Inject;
4 import org.matsim.api.core.v01.Coord;
5 import org.matsim.api.core.v01.Id;
13 import org.matsim.core.config.Config;
17 
18 import java.util.Collections;
19 import java.util.List;
20 
21 class FallbackRoutingModuleDefaultImpl implements FallbackRoutingModule {
22 
23  @Deprecated // #deleteBeforeRelease : only used to retrofit plans created since the merge of fallback routing module (sep'-dec'19)
24  public static final String _fallback = "_fallback";
25 
26  @Inject private RoutingConfigGroup pcrCfg;
27  @Inject private Config config ;
28  @Inject private Population population ;
29  @Inject private Network network ;
30 
31  @Override public List<? extends PlanElement> calcRoute( RoutingRequest request ){
32  final Facility fromFacility = request.getFromFacility();
33  final Facility toFacility = request.getToFacility();
34  final double departureTime = request.getDepartureTime();
35  final Person person = request.getPerson();
36 
37  Leg leg = population.getFactory().createLeg( TransportMode.walk ) ;
38  Coord fromCoord = FacilitiesUtils.decideOnCoord( fromFacility, network, config );
39  Coord toCoord = FacilitiesUtils.decideOnCoord( toFacility, network, config ) ;
40  Id<Link> dpLinkId = FacilitiesUtils.decideOnLink( fromFacility, network ).getId() ;
41  Id<Link> arLinkId = FacilitiesUtils.decideOnLink( toFacility, network ).getId() ;
42  /*
43  * Even TransportMode.walk needs an "UltimateFallbackRoutingModule", but for all other modes (pt, drt, ...) it
44  * would be better if we would try the walkRouter first and fall back to "UltimateFallbackRoutingModule" or a
45  * handwritten teleported walk like below only if the walkRouter returns null. - gl/kn-dec'19
46  */
47  NetworkRoutingInclAccessEgressModule.routeBushwhackingLeg( person, leg, fromCoord, toCoord, departureTime, dpLinkId, arLinkId, population.getFactory(),
48  pcrCfg.getModeRoutingParams().get(TransportMode.walk) ) ;
49  return Collections.singletonList( leg ) ;
50  }
51 }