MATSIM
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
org.matsim.run.XY2Links Class Reference

Public Member Functions

void run (final String[] args)
 

Static Public Member Functions

static void main (final String[] args)
 

Private Member Functions

void parseArguments (final String[] args)
 
void printUsage ()
 

Private Attributes

Config config
 
String configfile = null
 
String plansfile = null
 

Detailed Description

Assigns each activity in each plan of each person in the population a link where the activity takes place based on the coordinates given for the activity. This tool is used for mapping a new demand/population to a network for the first time.

Author
mrieser

Definition at line 43 of file XY2Links.java.

Member Function Documentation

◆ parseArguments()

void org.matsim.run.XY2Links.parseArguments ( final String []  args)
private

Parses all arguments and sets the corresponding members.

Parameters
args

Definition at line 54 of file XY2Links.java.

References org.matsim.core.utils.misc.ArgumentParser.iterator(), and org.matsim.run.XY2Links.printUsage().

Referenced by org.matsim.run.XY2Links.run().

54  {
55  if (args.length == 0) {
56  System.out.println("Too few arguments.");
57  printUsage();
58  System.exit(1);
59  }
60  Iterator<String> argIter = new ArgumentParser(args).iterator();
61  String arg = argIter.next();
62  if (arg.equals("-h") || arg.equals("--help")) {
63  printUsage();
64  System.exit(0);
65  } else {
66  this.configfile = arg;
67  this.plansfile = argIter.next();
68  if (argIter.hasNext()) {
69  System.out.println("Too many arguments.");
70  printUsage();
71  System.exit(1);
72  }
73  }
74  }
Here is the call graph for this function:

◆ printUsage()

void org.matsim.run.XY2Links.printUsage ( )
private

Definition at line 76 of file XY2Links.java.

Referenced by org.matsim.run.XY2Links.parseArguments().

76  {
77  System.out.println();
78  System.out.println("XY2Links");
79  System.out.println("Reads a plans-file and assignes each activity in each plan of each person");
80  System.out.println("a link based on the coordinates given in the activity. The modified plans/");
81  System.out.println("persons are then written out to file again.");
82  System.out.println();
83  System.out.println("usage: XY2Links [OPTIONS] configfile plansfile");
84  System.out.println(" The following parameters must be given in the config-file:");
85  System.out.println(" - network.inputNetworkFile");
86  System.out.println(" - plans.inputPlansFile");
87  System.out.println();
88  System.out.println("Options:");
89  System.out.println("-h, --help: Displays this message.");
90  System.out.println();
91  System.out.println("----------------");
92  System.out.println("2008, matsim.org");
93  System.out.println();
94  }

◆ run()

void org.matsim.run.XY2Links.run ( final String []  args)

Starts the assignment of links to activities.

Parameters
argscommand-line arguments

Definition at line 100 of file XY2Links.java.

References org.matsim.core.population.io.StreamingPopulationReader.addAlgorithm(), org.matsim.core.population.io.StreamingPopulationWriter.closeStreaming(), org.matsim.core.scenario.ScenarioUtils.createMutableScenario(), org.matsim.core.scenario.MutableScenario.getConfig(), org.matsim.core.config.groups.NetworkConfigGroup.getInputFile(), org.matsim.core.scenario.MutableScenario.getNetwork(), org.matsim.core.config.groups.GlobalConfigGroup.getRandomSeed(), org.matsim.core.config.Config.global(), org.matsim.core.config.ConfigUtils.loadConfig(), org.matsim.core.config.Config.network(), org.matsim.run.XY2Links.parseArguments(), org.matsim.core.population.PopulationUtils.printPlansCount(), org.matsim.core.population.io.StreamingPopulationReader.readFile(), org.matsim.core.gbl.MatsimRandom.reset(), and org.matsim.core.population.io.StreamingPopulationWriter.startStreaming().

Referenced by org.matsim.run.XY2Links.main().

100  {
101  parseArguments(args);
102  this.config = ConfigUtils.loadConfig(this.configfile);
103  MatsimRandom.reset(this.config.global().getRandomSeed());
104  MutableScenario scenario = ScenarioUtils.createMutableScenario(this.config);
105  new MatsimNetworkReader(scenario.getNetwork()).readFile(this.config.network().getInputFile());
106  this.config = scenario.getConfig();
107 
108  StreamingPopulationReader reader = new StreamingPopulationReader( scenario ) ;
109  final StreamingPopulationWriter plansWriter = new StreamingPopulationWriter();
110  plansWriter.startStreaming(this.plansfile);
111  reader.addAlgorithm(new org.matsim.core.population.algorithms.XY2Links(scenario));
112  reader.addAlgorithm(plansWriter);
113  reader.readFile(this.config.plans().getInputFile());
114  PopulationUtils.printPlansCount(reader) ;
115  plansWriter.closeStreaming();
116 
117  System.out.println("done.");
118  }
final NetworkConfigGroup network()
Definition: Config.java:411
final GlobalConfigGroup global()
Definition: Config.java:395
Here is the call graph for this function:

◆ main()

static void org.matsim.run.XY2Links.main ( final String []  args)
static

Main method to start the assignment of links to activities.

Parameters
argsArray of arguments, usually passed on the command line.

Definition at line 125 of file XY2Links.java.

References org.matsim.run.XY2Links.run().

125  {
126  new XY2Links().run(args);
127  }
Here is the call graph for this function:

Member Data Documentation

◆ config

Config org.matsim.run.XY2Links.config
private

Definition at line 45 of file XY2Links.java.

◆ configfile

String org.matsim.run.XY2Links.configfile = null
private

Definition at line 46 of file XY2Links.java.

◆ plansfile

String org.matsim.run.XY2Links.plansfile = null
private

Definition at line 47 of file XY2Links.java.


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