From f6233227f015090f0fb8f76961b365c9aa236c30 Mon Sep 17 00:00:00 2001 From: simei94 <67737999+simei94@users.noreply.github.com> Date: Wed, 15 May 2024 09:47:55 +0200 Subject: [PATCH] add trip filter for trip start OR end in shp area (#3269) --- .../java/org/matsim/simwrapper/SimWrapper.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapper.java b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapper.java index 028d6d6949f..19a8717ba7e 100644 --- a/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapper.java +++ b/contribs/simwrapper/src/main/java/org/matsim/simwrapper/SimWrapper.java @@ -120,6 +120,15 @@ boolean hasDashboard(Class d, String context) { * Generate the dashboards specification and writes .yaml files to {@code dir}. */ public void generate(Path dir) throws IOException { + generate(dir, false); + } + + /** + * Generate the dashboards specification and writes .yaml files to {@code dir}. + * @param dir target directory + * @param append if true, existing dashboards will not be overwritten + */ + public void generate(Path dir, boolean append) throws IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory() .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) @@ -157,6 +166,11 @@ public void generate(Path dir) throws IOException { yaml.subtabs = layout.getTabs(); Path out = dir.resolve("dashboard-" + i + ".yaml"); + + while (append && Files.exists(out)) { + out = dir.resolve("dashboard-" + ++i + ".yaml"); + } + writer.writeValue(out.toFile(), yaml); i++;