From 632e5ece7fa2ea1f19d66a67fc8cb050a4009f53 Mon Sep 17 00:00:00 2001 From: simei94 <67737999+simei94@users.noreply.github.com> Date: Tue, 12 Mar 2024 02:50:56 -0600 Subject: [PATCH] preserve possibility to run converter without shp file (#3158) Co-authored-by: Michal Maciejewski --- .../prepare/network/CreateNetworkFromSumo.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateNetworkFromSumo.java b/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateNetworkFromSumo.java index b4a3521e48d..62f21e24314 100644 --- a/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateNetworkFromSumo.java +++ b/contribs/application/src/main/java/org/matsim/application/prepare/network/CreateNetworkFromSumo.java @@ -74,7 +74,15 @@ public static void main(String[] args) { @Override public Integer call() throws Exception { - SumoNetworkConverter converter = SumoNetworkConverter.newInstance(input, output, Path.of(shp.getShapeFile()), crs.getInputCRS(), crs.getTargetCRS(), freeSpeedFactor); +// since ShpOptions.getShapeFile() no longer is a path but a string, we have to check if it is defined before creating SumoNetworkConverter to +// preserve the possibility to run the converter without a shp file, otherwise, when calling Path.of(shp.getShapeFile) a NullPointerException is caused -sme0324 + Path path = null; + + if (shp.isDefined()) { + path = Path.of(shp.getShapeFile()); + } + + SumoNetworkConverter converter = SumoNetworkConverter.newInstance(input, output, path, crs.getInputCRS(), crs.getTargetCRS(), freeSpeedFactor); Network network = NetworkUtils.createNetwork(); Lanes lanes = LanesUtils.createLanesContainer();