Skip to content

Commit

Permalink
Merge pull request opentripplanner#2378 from barslett/Island
Browse files Browse the repository at this point in the history
PruneFloatingIslands with build parameters
  • Loading branch information
novalis authored Dec 18, 2016
2 parents 908caf6 + 03cb80e commit 9089fcf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<GtfsBundle> gtfsBundles = Lists.newArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,8 +72,8 @@ public List<String> getPrerequisites() {
public void buildGraph(Graph graph, HashMap<Class<?>, 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 {
Expand All @@ -87,5 +87,11 @@ public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
public void checkInputs() {
//no inputs
}
public void setPruningThresholdIslandWithoutStops(int pruningThresholdIslandWithoutStops) {
this.pruningThresholdIslandWithoutStops = pruningThresholdIslandWithoutStops;
}
public void setPruningThresholdIslandWithStops(int pruningThresholdIslandWithStops) {
this.pruningThresholdIslandWithStops = pruningThresholdIslandWithStops;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

}

0 comments on commit 9089fcf

Please sign in to comment.