diff --git a/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java b/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java index bec946cf500..ef0b384225c 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.setPruningThresholdIslandWithoutStops(builderParams.pruningThresholdIslandWithoutStops); + pruneFloatingIslands.setPruningThresholdIslandWithStops(builderParams.pruningThresholdIslandWithStops); + 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..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 = 40; + private int pruningThresholdIslandWithoutStops; /** * this field indicate the maximum size for island with stops * island under this size will be pruned. */ - private int islandWithStopsMaxSize = 5; + 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,5 +87,11 @@ public void buildGraph(Graph graph, HashMap, Object> extra) { public void checkInputs() { //no inputs } + public void setPruningThresholdIslandWithoutStops(int pruningThresholdIslandWithoutStops) { + this.pruningThresholdIslandWithoutStops = pruningThresholdIslandWithoutStops; + } + 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 f598869ba2f..94c491f800b 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 indicates the pruning threshold for islands without stops. + * Any such island under this size will be pruned. + */ + public final int pruningThresholdIslandWithoutStops; + + /** + * This field indicates the pruning threshold for islands with stops. + * Any such island under this size will be pruned. + */ + public final int pruningThresholdIslandWithStops; /** * 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); + pruningThresholdIslandWithoutStops = config.path("islandWithoutStopsMaxSize").asInt(40); + pruningThresholdIslandWithStops = config.path("islandWithStopsMaxSize").asInt(5); } }