Skip to content

Commit

Permalink
add run param option for input facilities (#3106)
Browse files Browse the repository at this point in the history
Co-authored-by: rakow <[email protected]>
  • Loading branch information
simei94 and rakow authored Feb 13, 2024
1 parent 8c4a877 commit b087d76
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package org.matsim.application.prepare.population;

import org.matsim.api.core.v01.Scenario;
import org.matsim.api.core.v01.TransportMode;
import org.matsim.api.core.v01.network.Network;
import org.matsim.api.core.v01.population.Population;
import org.matsim.application.MATSimAppCommand;
import org.matsim.core.config.ConfigUtils;
import org.matsim.core.network.NetworkUtils;
import org.matsim.core.network.algorithms.TransportModeNetworkFilter;
import org.matsim.core.population.PopulationUtils;
import org.matsim.core.population.algorithms.ParallelPersonAlgorithmUtils;
import org.matsim.core.population.algorithms.XY2Links;
import org.matsim.core.scenario.ScenarioUtils;
import org.matsim.facilities.ActivityFacilities;
import org.matsim.facilities.FacilitiesUtils;
import org.matsim.facilities.MatsimFacilitiesReader;
import picocli.CommandLine;

import java.nio.file.Path;
Expand All @@ -29,6 +34,9 @@ public class XYToLinks implements MATSimAppCommand {
@CommandLine.Option(names = "--car-only", description = "Convert to car-only network", defaultValue = "false")
private boolean carOnly;

@CommandLine.Option(names = "--facilities", description = "Input facilities. Necessary if activities already were assigned facility ids.")
private Path inputFacilities;

@Override
public Integer call() throws Exception {

Expand All @@ -42,7 +50,16 @@ public Integer call() throws Exception {
network = carOnlyNetwork;
}

XY2Links algo = new XY2Links(network, FacilitiesUtils.createActivityFacilities());
ActivityFacilities facilities = FacilitiesUtils.createActivityFacilities();

if (inputFacilities != null) {
Scenario scenario = ScenarioUtils.loadScenario(ConfigUtils.createConfig());
MatsimFacilitiesReader reader = new MatsimFacilitiesReader(scenario);
reader.parse(inputFacilities.toUri().toURL());
facilities = scenario.getActivityFacilities();
}

XY2Links algo = new XY2Links(network, facilities);

Population population = PopulationUtils.readPopulation(input.toString());

Expand Down

0 comments on commit b087d76

Please sign in to comment.