Commit 45c0076c authored by Sebastian Hörl's avatar Sebastian Hörl
Browse files

Make operators optional

parent 0e6ad27e
......@@ -29,8 +29,8 @@ import ch.sbb.matsim.routing.pt.raptor.SwissRailRaptorModule;
public class RunASTRA2018002 {
static public void main(String[] args) throws ConfigurationException {
CommandLine cmd = new CommandLine.Builder(args) //
.requireOptions("config-path", "model", "operator-path") //
.allowOptions("use-route-choice", "use-only-significant") //
.requireOptions("config-path", "model") //
.allowOptions("use-route-choice", "use-only-significant", "operator-path") //
.build();
// Load config
......@@ -60,7 +60,7 @@ public class RunASTRA2018002 {
controler.addOverridingModule(new SwissRailRaptorModule());
controler.addOverridingModule(new AVModule());
controler.addOverridingModule(new OperatingAreaModule());
controler.addOverridingModule(new OperatorModule(new File(cmd.getOptionStrict("operator-path"))));
controler.addOverridingModule(new OperatorModule(cmd.getOption("operator-path").map(File::new)));
controler.addOverridingModule(new BaselineTransitModule());
// TODO: Consolidate QSim plugins
......
......@@ -3,6 +3,8 @@ package ch.ethz.matsim.projects.astra_2018_002.av.operator;
import java.io.File;
import java.net.MalformedURLException;
import java.util.Collection;
import java.util.Collections;
import java.util.Optional;
import org.matsim.api.core.v01.Id;
import org.matsim.core.controler.AbstractModule;
......@@ -20,9 +22,9 @@ import ch.ethz.matsim.av.framework.AVModule;
import ch.ethz.matsim.projects.astra_2018_002.av.operating_area.OperatingAreaModule;
public class OperatorModule extends AbstractModule {
private final File operatorPath;
private final Optional<File> operatorPath;
public OperatorModule(File operatorPath) {
public OperatorModule(Optional<File> operatorPath) {
this.operatorPath = operatorPath;
}
......@@ -33,7 +35,11 @@ public class OperatorModule extends AbstractModule {
@Provides
@Singleton
public Collection<Operator> provideOperators() throws MalformedURLException {
return new OperatorReader().read(operatorPath.toURI().toURL());
if (operatorPath.isPresent()) {
return new OperatorReader().read(operatorPath.get().toURI().toURL());
} else {
return Collections.emptySet();
}
}
@Provides
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment