Skip to content

Commit

Permalink
documentation to the PruneFloatingIslands process has been added
Browse files Browse the repository at this point in the history
  • Loading branch information
benmoovit committed Mar 4, 2013
1 parent 1942390 commit de3821f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions opentripplanner-graph-builder/samples/graph-config.xml
Expand Up @@ -34,9 +34,9 @@
</bean>

<bean id="floatingIslands" class="org.opentripplanner.graph_builder.impl.PruneFloatingIslands">
<property name="maxIslandSize" value="1000 "/>
<property name="islandWithoutStopsMaxSize" value="1000 "/>
<property name="islandLogFile" value="{graphPath}/island.csv"/>
<property name="islandWithStopMaxSize" value="20"/>
<property name="islandWithStopsMaxSize" value="20"/>
<property name="transitToStreetNetwork" ref ="transitStreetLink"/>
</bean>

Expand Down
Expand Up @@ -13,32 +13,48 @@ the License, or (at your option) any later version.

package org.opentripplanner.graph_builder.impl;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import lombok.Getter;
import lombok.Setter;
import org.apache.log4j.*;
import org.apache.log4j.Logger;
import org.opentripplanner.common.StreetUtils;
import org.opentripplanner.graph_builder.services.GraphBuilder;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.services.StreetVertexIndexService;
import org.slf4j.*;

/**
* this module is part of the {@link GraphBuilder} process. it design to remove small isolated islands form the graph.
* Island created when there is no connectivity in the map, island acts like trap since there
* is no connectivity there is no way in or out the island.
* the module distinguish between two island types one with transit stops and without stops.
*
*
*
*/
public class PruneFloatingIslands implements GraphBuilder {

private static org.slf4j.Logger _log = LoggerFactory.getLogger(PruneFloatingIslands.class);

/**
* this field indicate the maximum size for island without stops
* island under this size will be pruned.
*/
@Setter
private int maxIslandSize = 40;
private int islandWithoutStopsMaxSize = 40;

/**
* this field indicate the maximum size for island with stops
* island under this size will be pruned.
*/
@Setter
private int islandWithStopMaxSize = 5;
private int islandWithStopsMaxSize = 5;

/**
* The name for output file for this process, the file will store information about the islands were found and if they were pruned.
* If the value is an empty string there will be no output file.
*/
@Setter
private String islandLogFile = "";

Expand All @@ -50,14 +66,18 @@ public List<String> provides() {
}

public List<String> getPrerequisites() {
// return Arrays.asList("streets","linking");
/**this module can run after the street module only but if
* the street linker did not run then it couldn't identifies island with stops.
* so if the need is to distinguish between island with stops or without stops
* as explained before this module should run after the streets and the linker modules.
*/
return Arrays.asList("streets");
}

@Override
public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
_log.warn("Pruning isolated islands ...");
StreetUtils.pruneFloatingIslands(graph, maxIslandSize, islandWithStopMaxSize,
StreetUtils.pruneFloatingIslands(graph, islandWithoutStopsMaxSize, islandWithStopsMaxSize,
LoggerAppenderProvider.createCsvFile4LoggerCat(islandLogFile, "islands"));
if(transitToStreetNetwork == null){
_log.warn("Could not reconnect stop, TransitToStreetNetworkGraphBuilder was not provided");
Expand Down

0 comments on commit de3821f

Please sign in to comment.