Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix for XYToLink class #3106

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading