From 5bb12125ca4016e0f842d893e1d51c98239d0702 Mon Sep 17 00:00:00 2001 From: GregorRyb Date: Tue, 27 Aug 2024 18:19:56 +0200 Subject: [PATCH] add to run class --- .../java/org/matsim/run/LeipzigScenario.java | 8 +++++++- .../org/matsim/run/prepare/NetworkOptions.java | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/matsim/run/LeipzigScenario.java b/src/main/java/org/matsim/run/LeipzigScenario.java index 00899a4..d6b3a6d 100644 --- a/src/main/java/org/matsim/run/LeipzigScenario.java +++ b/src/main/java/org/matsim/run/LeipzigScenario.java @@ -184,6 +184,8 @@ protected Config prepareConfig(Config config) { // walk probably is teleported. // but we do not know where the facilities are. (Facilities are not written to file.) + + if (networkOpt.hasDrtArea()) { //drt DrtCaseSetup.prepareConfig(config, /* drtCase, */ new ShpOptions(networkOpt.getDrtArea(), null, null), ptDrtIntermodality); @@ -277,7 +279,6 @@ protected void prepareScenario(Scenario scenario) { if (networkOpt.hasCarFreeArea()){ PreparePopulation.deleteCarAndRideRoutesThatHaveForbiddenLinks(scenario.getPopulation(), networkOpt.getNonPtLinksInCarFreeArea(scenario.getNetwork())); } - } @Override @@ -333,6 +334,11 @@ public void install() { if (bike == BicycleHandling.onNetworkWithBicycleContrib) { controler.addOverridingModule(new BicycleModule()); } + + if (networkOpt.hasEBikeCity()) { + controler.getScenario().getVehicles().getVehicleTypes().get(TransportMode.bike).setMaximumVelocity(8.32); + + } } /** diff --git a/src/main/java/org/matsim/run/prepare/NetworkOptions.java b/src/main/java/org/matsim/run/prepare/NetworkOptions.java index 231ada9..90e7297 100644 --- a/src/main/java/org/matsim/run/prepare/NetworkOptions.java +++ b/src/main/java/org/matsim/run/prepare/NetworkOptions.java @@ -37,7 +37,13 @@ public class NetworkOptions { private Double slowSpeedRelativeChange; @CommandLine.Option(names = "--slow-speed-relative-change", description = "provide a value that is bigger than 0.0 and smaller than 1.0") private Path eBikeCity; - @CommandLine.Option(names = "--eBikeCity", description = "provide a value that is bigger than 0.0 and smaller than 1.0") + @CommandLine.Option(names = "--eBikeCity", description = "simplified e-bike city") + + + + public boolean hasEBikeCity() { + return isDefined(eBikeCity); + } /** @@ -112,14 +118,16 @@ public void prepare(Network network) { } } - if (isDefined(eBikeCity)) { - - + if (hasEBikeCity()) { + if (!Files.exists(eBikeCity)) { + throw new IllegalArgumentException("Path to e-bike city not found: " + eBikeCity); + } else { + PrepareNetwork.prepareEBikeCity(network, ShpGeometryUtils.loadPreparedGeometries(IOUtils.resolveFileOrResource(new ShpOptions(eBikeCity, null, null).getShapeFile().toString()))); + } } } - /** * Return path to drt area. */