MATSIM
RunPNetworkGenerator.java
Go to the documentation of this file.
1 package tutorial.programming.example08DemandGeneration;
2 
13 
14 
18 public class RunPNetworkGenerator {
19 
20  public static void main(String[] args) {
21 
22  /*
23  * The input file name.
24  */
25  String osm = "./input/my-map.osm";
26 
27 
28  /*
29  * The coordinate system to use. OpenStreetMap uses WGS84, but for MATSim, we need a projection where distances
30  * are (roughly) euclidean distances in meters.
31  *
32  * UTM 33N is one such possibility (for parts of Europe, at least).
33  *
34  */
37 
38  /*
39  * First, create a new Config and a new Scenario. One always has to do this when working with the MATSim
40  * data containers.
41  *
42  */
43  Config config = ConfigUtils.createConfig();
44  Scenario scenario = ScenarioUtils.createScenario(config);
45 
46  /*
47  * Pick the Network from the Scenario for convenience.
48  */
49  Network network = scenario.getNetwork();
50 
51  OsmNetworkReader onr = new OsmNetworkReader(network,ct);
52  onr.parse(osm);
53 
54  /*
55  * Clean the Network. Cleaning means removing disconnected components, so that afterwards there is a route from every link
56  * to every other link. This may not be the case in the initial network converted from OpenStreetMap.
57  */
58  new NetworkCleaner().run(network);
59 
60  /*
61  * Write the Network to a MATSim network file.
62  */
63  new NetworkWriter(network).write("./input/network.xml");
64 
65  }
66 
67 }
void write(final String filename)
static CoordinateTransformation getCoordinateTransformation(final String fromSystem, final String toSystem)
static Config createConfig(final String filename)
void parse(final String osmFilename)
static Scenario createScenario(final Config config)