MATSIM
TripRouterModule.java
Go to the documentation of this file.
1 /*
2  * *********************************************************************** *
3  * * project: org.matsim.*
4  * * TripRouterModule.java
5  * * *
6  * * *********************************************************************** *
7  * * *
8  * * copyright : (C) 2015 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 
23 package org.matsim.core.router;
24 
31 
32 
33 public class TripRouterModule extends AbstractModule {
34 
35  @Override
36  public void install() {
37  // yy The code below will install _one_ LeastCostPathCalculator, which will be Dijkstra or Landmarks or something. It will be the
38  // same Landmarks instance for all modes ... although one could do better by doing the preprocessing separately for the different modes.
39  // kai/mm, jan'17
40 
41  bind(TripRouter.class); // not thread-safe, not a singleton
42  bind(MainModeIdentifier.class).to(MainModeIdentifierImpl.class);
44 
45  bind(MultimodalLinkChooser.class).to(MultimodalLinkChooserDefaultImpl.class);
46 
49  bind(SingleModeNetworksCache.class).asEagerSingleton();
50  RoutingConfigGroup routeConfigGroup = getConfig().routing();
51  for (String mode : routeConfigGroup.getTeleportedModeFreespeedFactors().keySet()) {
52  if (getConfig().transit().isUseTransit() && getConfig().transit().getTransitModes().contains(mode)) {
53  // default config contains "pt" as teleported mode, but if we have simulated transit, this is supposed to override it
54  // better solve this on the config level eventually.
55  continue;
56  }
57  addRoutingModuleBinding(mode).toProvider(new FreespeedFactorRouting(getConfig().routing().getModeRoutingParams().get(mode)));
58  }
59  for (String mode : routeConfigGroup.getTeleportedModeSpeeds().keySet()) {
60  addRoutingModuleBinding(mode).toProvider(new BeelineTeleportationRouting(getConfig().routing().getModeRoutingParams().get(mode)));
61  }
62 
63  boolean linkToLinkRouting = getConfig().controller().isLinkToLinkRoutingEnabled();
64  if (linkToLinkRouting) {
65  bind(NetworkTurnInfoBuilderI.class).to(NetworkTurnInfoBuilder.class) ;
66  }
67  for (String mode : routeConfigGroup.getNetworkModes()) {
68  addRoutingModuleBinding(mode).toProvider(linkToLinkRouting ? //
69  new LinkToLinkRouting(mode) : new NetworkRoutingProvider(mode));
70  }
71  if (getConfig().transit().isUseTransit()) {
72  if (getConfig().transit().getRoutingAlgorithmType() != TransitRoutingAlgorithmType.SwissRailRaptor) {
73  // the SwissRailRaptorModule adds the routingModuleBinding itself
74  for (String mode : getConfig().transit().getTransitModes()) {
75  addRoutingModuleBinding(mode).toProvider(Transit.class);
76  }
77  }
78  }
79 
80  this.bind( FallbackRoutingModule.class ).to( FallbackRoutingModuleDefaultImpl.class ) ;
81  }
82 }
final LinkedBindingBuilder< RoutingModule > addRoutingModuleBinding(String mode)
TransitConfigGroup transit()
Definition: Config.java:451
RoutingConfigGroup routing()
Definition: Config.java:439
final ControllerConfigGroup controller()
Definition: Config.java:399