MATSIM
MatsimClassRouter.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * RunEmissionToolOffline.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2009 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 package tutorial.programming.example21tutorialTUBclass.leastCostPath;
21 
22 import java.util.ArrayList;
23 
24 import org.matsim.api.core.v01.Id;
32 import org.matsim.vehicles.Vehicle;
33 
40 public class MatsimClassRouter implements LeastCostPathCalculator {
41 
42  private final Network network;
43 
44 
45  public MatsimClassRouter(Network network, TravelDisutility travelCosts,
46  TravelTime travelTimes) {
47  this.network = network;
48 
49  }
50 
51  @Override
52  public Path calcLeastCostPath(Node fromNode, Node toNode, double starttime,
53  Person person, Vehicle vehicle) {
54 
55 
56 
57  ArrayList<Node> nodes = new ArrayList<Node>();
58  ArrayList<Link> links = new ArrayList<Link>();
59 
60  nodes.add(network.getNodes().get(Id.createNodeId(13)));
61  //the first node is the toNode of the previous activity's link
62  nodes.add(network.getNodes().get(Id.createNodeId(14)));
63  nodes.add(network.getNodes().get(Id.createNodeId(25)));
64  nodes.add(network.getNodes().get(Id.createNodeId(36)));
65  nodes.add(network.getNodes().get(Id.createNodeId(47)));
66  //the last node is the fromNode of the next activity's link
67 
68 
69  //the first link is the first link after the first Node
70  links.add(network.getLinks().get(Id.createLinkId(112)));
71  links.add(network.getLinks().get(Id.createLinkId(213)));
72  links.add(network.getLinks().get(Id.createLinkId(224)));
73  links.add(network.getLinks().get(Id.createLinkId(235)));
74  //the last link is the last link before the last node
75 
76  //we don't provide any traveltimes or costs here
77  return new Path(nodes,links,0.0,0.0);
78  }
79 
80 }
Map< Id< Node >,?extends Node > getNodes()
MatsimClassRouter(Network network, TravelDisutility travelCosts, TravelTime travelTimes)
Path calcLeastCostPath(Node fromNode, Node toNode, double starttime, Person person, Vehicle vehicle)
Map< Id< Link >,?extends Link > getLinks()