diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/population/XYToLinks.java b/contribs/application/src/main/java/org/matsim/application/prepare/population/XYToLinks.java index ec9ada3bad5..83aefa033e0 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/population/XYToLinks.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/population/XYToLinks.java @@ -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; @@ -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 { @@ -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());