From 0dc1063ea6717a2ddc37d039818581062d350554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Barslett?= Date: Fri, 4 Nov 2016 15:10:20 +0100 Subject: [PATCH 1/2] PruneFloatingIslands with build parameters --- .../graph_builder/GraphBuilder.java | 5 ++++- .../graph_builder/module/PruneFloatingIslands.java | 10 ++++++++-- .../standalone/GraphBuilderParameters.java | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java b/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java index bec946cf500..9a74f866b3d 100644 --- a/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java +++ b/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java @@ -245,7 +245,10 @@ public static GraphBuilder forDirectory(CommandLineParameters params, File dir) osmModule.staticBikeParkAndRide = builderParams.staticBikeParkAndRide; osmModule.staticParkAndRide = builderParams.staticParkAndRide; graphBuilder.addModule(osmModule); - graphBuilder.addModule(new PruneFloatingIslands()); + PruneFloatingIslands pruneFloatingIslands = new PruneFloatingIslands(); + pruneFloatingIslands.setislandWithoutStopsMaxSize(builderParams.islandWithoutStopsMaxSize); + pruneFloatingIslands.setIslandWithStopsMaxSize(builderParams.islandWithStopsMaxSize); + graphBuilder.addModule(pruneFloatingIslands); } if ( hasGTFS ) { List gtfsBundles = Lists.newArrayList(); diff --git a/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java b/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java index 3d0cb6c0a09..7bdf82e07a0 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java @@ -38,13 +38,13 @@ public class PruneFloatingIslands implements GraphBuilderModule { * this field indicate the maximum size for island without stops * island under this size will be pruned. */ - private int islandWithoutStopsMaxSize = 40; + private int islandWithoutStopsMaxSize; /** * this field indicate the maximum size for island with stops * island under this size will be pruned. */ - private int islandWithStopsMaxSize = 5; + private int islandWithStopsMaxSize; /** * The name for output file for this process. The file will store information about the islands @@ -87,5 +87,11 @@ public void buildGraph(Graph graph, HashMap, Object> extra) { public void checkInputs() { //no inputs } + public void setislandWithoutStopsMaxSize(int islandWithoutStopsMaxSize) { + this.islandWithoutStopsMaxSize = islandWithoutStopsMaxSize; + } + public void setIslandWithStopsMaxSize(int islandWithStopsMaxSize) { + this.islandWithStopsMaxSize = islandWithStopsMaxSize; + } } \ No newline at end of file diff --git a/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java b/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java index f598869ba2f..d3812ea49ae 100644 --- a/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java +++ b/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java @@ -116,6 +116,18 @@ public class GraphBuilderParameters { * Maximal distance between stops in meters that will connect consecutive trips that are made with same vehicle */ public int maxInterlineDistance = 200; + + /** + * this field indicate the maximum size for island without stops + * island under this size will be pruned. + */ + public final int islandWithoutStopsMaxSize; + + /** + * this field indicate the maximum size for island with stops + * island under this size will be pruned. + */ + public final int islandWithStopsMaxSize; /** * Set all parameters from the given Jackson JSON tree, applying defaults. @@ -144,6 +156,8 @@ public GraphBuilderParameters(JsonNode config) { staticBikeParkAndRide = config.path("staticBikeParkAndRide").asBoolean(false); maxHtmlAnnotationsPerFile = config.path("maxHtmlAnnotationsPerFile").asInt(1000); maxInterlineDistance = config.path("maxInterlineDistance").asInt(200); + islandWithoutStopsMaxSize = config.path("islandWithoutStopsMaxSize").asInt(40); + islandWithStopsMaxSize = config.path("islandWithStopsMaxSize").asInt(5); } } From 03cb80e0c969192fd5f1e6a9065c3aab344c34ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torbj=C3=B8rn=20Barslett?= Date: Fri, 16 Dec 2016 10:33:58 +0100 Subject: [PATCH 2/2] Found more intuitive parameter names, fixed typos --- .../graph_builder/GraphBuilder.java | 4 ++-- .../module/PruneFloatingIslands.java | 16 ++++++++-------- .../standalone/GraphBuilderParameters.java | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java b/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java index 9a74f866b3d..ef0b384225c 100644 --- a/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java +++ b/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java @@ -246,8 +246,8 @@ public static GraphBuilder forDirectory(CommandLineParameters params, File dir) osmModule.staticParkAndRide = builderParams.staticParkAndRide; graphBuilder.addModule(osmModule); PruneFloatingIslands pruneFloatingIslands = new PruneFloatingIslands(); - pruneFloatingIslands.setislandWithoutStopsMaxSize(builderParams.islandWithoutStopsMaxSize); - pruneFloatingIslands.setIslandWithStopsMaxSize(builderParams.islandWithStopsMaxSize); + pruneFloatingIslands.setPruningThresholdIslandWithoutStops(builderParams.pruningThresholdIslandWithoutStops); + pruneFloatingIslands.setPruningThresholdIslandWithStops(builderParams.pruningThresholdIslandWithStops); graphBuilder.addModule(pruneFloatingIslands); } if ( hasGTFS ) { diff --git a/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java b/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java index 7bdf82e07a0..0fa3042ffa6 100644 --- a/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java +++ b/src/main/java/org/opentripplanner/graph_builder/module/PruneFloatingIslands.java @@ -38,13 +38,13 @@ public class PruneFloatingIslands implements GraphBuilderModule { * this field indicate the maximum size for island without stops * island under this size will be pruned. */ - private int islandWithoutStopsMaxSize; + private int pruningThresholdIslandWithoutStops; /** * this field indicate the maximum size for island with stops * island under this size will be pruned. */ - private int islandWithStopsMaxSize; + private int pruningThresholdIslandWithStops; /** * The name for output file for this process. The file will store information about the islands @@ -72,8 +72,8 @@ public List getPrerequisites() { public void buildGraph(Graph graph, HashMap, Object> extra) { LOG.info("Pruning isolated islands in street network"); - StreetUtils.pruneFloatingIslands(graph, islandWithoutStopsMaxSize, - islandWithStopsMaxSize, islandLogFile); + StreetUtils.pruneFloatingIslands(graph, pruningThresholdIslandWithoutStops, + pruningThresholdIslandWithStops, islandLogFile); if (transitToStreetNetwork == null) { LOG.debug("TransitToStreetNetworkGraphBuilder was not provided to PruneFloatingIslands. Not attempting to reconnect stops."); } else { @@ -87,11 +87,11 @@ public void buildGraph(Graph graph, HashMap, Object> extra) { public void checkInputs() { //no inputs } - public void setislandWithoutStopsMaxSize(int islandWithoutStopsMaxSize) { - this.islandWithoutStopsMaxSize = islandWithoutStopsMaxSize; + public void setPruningThresholdIslandWithoutStops(int pruningThresholdIslandWithoutStops) { + this.pruningThresholdIslandWithoutStops = pruningThresholdIslandWithoutStops; } - public void setIslandWithStopsMaxSize(int islandWithStopsMaxSize) { - this.islandWithStopsMaxSize = islandWithStopsMaxSize; + public void setPruningThresholdIslandWithStops(int pruningThresholdIslandWithStops) { + this.pruningThresholdIslandWithStops = pruningThresholdIslandWithStops; } } \ No newline at end of file diff --git a/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java b/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java index d3812ea49ae..94c491f800b 100644 --- a/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java +++ b/src/main/java/org/opentripplanner/standalone/GraphBuilderParameters.java @@ -118,16 +118,16 @@ public class GraphBuilderParameters { public int maxInterlineDistance = 200; /** - * this field indicate the maximum size for island without stops - * island under this size will be pruned. + * This field indicates the pruning threshold for islands without stops. + * Any such island under this size will be pruned. */ - public final int islandWithoutStopsMaxSize; + public final int pruningThresholdIslandWithoutStops; /** - * this field indicate the maximum size for island with stops - * island under this size will be pruned. + * This field indicates the pruning threshold for islands with stops. + * Any such island under this size will be pruned. */ - public final int islandWithStopsMaxSize; + public final int pruningThresholdIslandWithStops; /** * Set all parameters from the given Jackson JSON tree, applying defaults. @@ -156,8 +156,8 @@ public GraphBuilderParameters(JsonNode config) { staticBikeParkAndRide = config.path("staticBikeParkAndRide").asBoolean(false); maxHtmlAnnotationsPerFile = config.path("maxHtmlAnnotationsPerFile").asInt(1000); maxInterlineDistance = config.path("maxInterlineDistance").asInt(200); - islandWithoutStopsMaxSize = config.path("islandWithoutStopsMaxSize").asInt(40); - islandWithStopsMaxSize = config.path("islandWithStopsMaxSize").asInt(5); + pruningThresholdIslandWithoutStops = config.path("islandWithoutStopsMaxSize").asInt(40); + pruningThresholdIslandWithStops = config.path("islandWithStopsMaxSize").asInt(5); } }