From 72528b6bd3c3c90b2252bd89b02542927c7b2c76 Mon Sep 17 00:00:00 2001 From: simei94 Date: Thu, 1 Sep 2022 18:22:39 +0200 Subject: [PATCH] add functionality to use mode filtered network --- .../prepare/CreateDrtStopsFromNetwork.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/org/matsim/run/prepare/CreateDrtStopsFromNetwork.java b/src/main/java/org/matsim/run/prepare/CreateDrtStopsFromNetwork.java index 08f903ed..7d1d19f1 100644 --- a/src/main/java/org/matsim/run/prepare/CreateDrtStopsFromNetwork.java +++ b/src/main/java/org/matsim/run/prepare/CreateDrtStopsFromNetwork.java @@ -12,6 +12,7 @@ import org.matsim.core.config.Config; import org.matsim.core.config.ConfigUtils; import org.matsim.core.network.NetworkUtils; +import org.matsim.core.network.algorithms.TransportModeNetworkFilter; import org.matsim.core.scenario.ScenarioUtils; import org.matsim.core.utils.geometry.CoordUtils; import org.matsim.core.utils.geometry.geotools.MGC; @@ -20,7 +21,9 @@ import java.io.FileWriter; import java.io.IOException; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; @CommandLine.Command( name = "create-drt-stops", @@ -37,6 +40,9 @@ public class CreateDrtStopsFromNetwork implements MATSimAppCommand { private String mode; // mode = "drt", "av" or other specific drt operator mode + @CommandLine.Option(names = "--modeFilteredNetwork", defaultValue = "false", description = "Use mode filtered network for stops generation") + private boolean modeFilteredNetwork; + @CommandLine.Option(names = "--min-distance", description = "minimal distance between two stops in m", defaultValue = "100.") private double minDistance; @@ -67,6 +73,20 @@ public Integer call() throws Exception { return 2; } + if(modeFilteredNetwork) { + Network filteredNetwork = NetworkUtils.createNetwork(); + Set modes = new HashSet<>(); + modes.add(mode); + + TransportModeNetworkFilter filter = new TransportModeNetworkFilter(network); + filter.filter(filteredNetwork, modes); + + network = filteredNetwork; + + log.info("Using a network filtered by mode " + mode + ". " + + "If you do not want to use the filtered network do not use the option --modeFilteredNetwork."); + } + for(Node node : network.getNodes().values()) { //we dont want pt nodes included as pt has a separate network + no dead ends if(MGC.coord2Point(node.getCoord()).within(drtServiceArea) && (node.getInLinks().size() + node.getOutLinks().size() > 2)