From 4fb3e6e6d6514afa2cd0b2ee7c83803d748d2c21 Mon Sep 17 00:00:00 2001 From: tschlenther Date: Fri, 2 Feb 2024 20:25:28 +0100 Subject: [PATCH] fix: drt stops creation for every mode --- .../java/org/matsim/run/prepare/DrtCaseSetup.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/matsim/run/prepare/DrtCaseSetup.java b/src/main/java/org/matsim/run/prepare/DrtCaseSetup.java index d188a42a..6ecc0b17 100644 --- a/src/main/java/org/matsim/run/prepare/DrtCaseSetup.java +++ b/src/main/java/org/matsim/run/prepare/DrtCaseSetup.java @@ -189,9 +189,6 @@ public static void prepareScenario(Scenario scenario, DrtCase drtCase, ShpOption throw new IllegalArgumentException("could not find 'mode' attribute in the given shape file at " + drtArea.getShapeFile().toString()); } Integer noVehicles = (Integer) feature.getAttribute("noVehicles"); - if (noVehicles.equals(null)){ - throw new IllegalArgumentException("could not find 'noVehicles' attribute in the given shape file at " + drtArea.getShapeFile().toString()); - } log.info("attempting to create " + noVehicles + " drt vehicles for mode " + drtMode); @@ -201,7 +198,12 @@ public static void prepareScenario(Scenario scenario, DrtCase drtCase, ShpOption //normally the following code would be set in prepareConfig, but.. //.. the stops creator relies on a network with drt modes. Drt modes are added in RunLeipzigScenario.prepareScenario().. //.. so stops are created after that step -sme0823 - multiModeDrtConfigGroup.getModalElements().forEach(drtConfigGroup -> { + + String finalDrtMode = drtMode; + DrtConfigGroup drtConfigGroup = multiModeDrtConfigGroup.getModalElements().stream(). + filter(cfg -> cfg.getMode().equals(finalDrtMode)) + .findFirst().orElseThrow(); +// multiModeDrtConfigGroup.getModalElements().forEach(drtConfigGroup -> { //path, tho which stops.xml is saved URL path = IOUtils.extendUrl(scenario.getConfig().getContext(), "leipzig-v" + version + "-" + drtConfigGroup.getMode() + "-stops.xml"); @@ -221,8 +223,8 @@ public static void prepareScenario(Scenario scenario, DrtCase drtCase, ShpOption //naming pattern comes from @DrtStopsWriter line 81. Should be ok to hard code it here. -sme0523 drtConfigGroup.transitStopFile = stopsFile.toString(); - configureNecessaryConfigGroups(scenario.getConfig(), drtConfigGroup.getMode()); - }); +// configureNecessaryConfigGroups(scenario.getConfig(), drtConfigGroup.getMode()); +// }); } }