MATSIM
Classes | Static Public Member Functions | List of all members
tutorial.programming.readingNonstdRoutesIntoScenario.RunReadNonstandardRoutesExample Class Reference

Classes

class  MySpecialRoute
 

Static Public Member Functions

static void main (String[] args)
 

Detailed Description

This is is an example, taken from Thibaut, of how to set an additional route factory before the controler has started.

This will generate the route, with start and end link id. It will also set distance and travel time if they are in the file. This is sufficient information for teleportation. Additional information needs to come from elsewhere, or the corresponding MatsimReader needs to be modified.

Note, however, that for pure teleportation it is not necessary to set the route factory since the default RouteFactories will already generate an instance of GenericRoute when a mode is not registered.

Author
nagel
thibautd

Definition at line 52 of file RunReadNonstandardRoutesExample.java.

Member Function Documentation

static void tutorial.programming.readingNonstdRoutesIntoScenario.RunReadNonstandardRoutesExample.main ( String[]  args)
static

Definition at line 54 of file RunReadNonstandardRoutesExample.java.

References org.matsim.core.config.ConfigUtils.createConfig(), org.matsim.core.scenario.ScenarioUtils.createScenario(), org.matsim.api.core.v01.population.Population.getFactory(), org.matsim.api.core.v01.Scenario.getPopulation(), org.matsim.core.scenario.ScenarioUtils.loadScenario(), org.matsim.core.controler.Controler.run(), and org.matsim.core.population.routes.RouteFactories.setRouteFactory().

54  {
55  Config config = ConfigUtils.createConfig();
56  Scenario scenario = ScenarioUtils.createScenario(config);
57  RouteFactories modeRouteFactory = ((PopulationFactory) scenario.getPopulation().getFactory()).getRouteFactories();
58  modeRouteFactory.setRouteFactory(MySpecialRoute.class, new RouteFactory() {
59  @Override
60  public Route createRoute(Id<Link> startLinkId, Id<Link> endLinkId) {
61  return new MySpecialRoute(startLinkId, endLinkId);
62  }
63  @Override
64  public String getCreatedRouteType() {
65  return MySpecialRoute.ROUTE_TYPE;
66  }
67  });
68  ScenarioUtils.loadScenario(scenario);
69  Controler controler = new Controler(scenario);
70  controler.run();
71 
72  }

Here is the call graph for this function:


The documentation for this class was generated from the following file: