forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opentripplanner#5591 from HSLdevcom/DT-6123
Consider escalator edges in island pruning
- Loading branch information
Showing
6 changed files
with
110 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...est/java/org/opentripplanner/graph_builder/module/islandpruning/EscalatorPruningTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.opentripplanner.graph_builder.module.islandpruning; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.opentripplanner.graph_builder.module.islandpruning.IslandPruningUtils.buildOsmGraph; | ||
|
||
import java.util.stream.Collectors; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.test.support.ResourceLoader; | ||
|
||
public class EscalatorPruningTest { | ||
|
||
@Test | ||
public void streetEdgesBetweenEscalatorEdgesRetained() { | ||
var graph = buildOsmGraph( | ||
ResourceLoader.of(EscalatorPruningTest.class).file("matinkyla-escalator.pbf"), | ||
10, | ||
2, | ||
50, | ||
250 | ||
); | ||
assertTrue( | ||
graph | ||
.getStreetEdges() | ||
.stream() | ||
.map(streetEdge -> streetEdge.getName().toString()) | ||
.collect(Collectors.toSet()) | ||
.contains("490072445") | ||
); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/test/java/org/opentripplanner/graph_builder/module/islandpruning/IslandPruningUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.opentripplanner.graph_builder.module.islandpruning; | ||
|
||
import java.io.File; | ||
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore; | ||
import org.opentripplanner.graph_builder.module.osm.OsmModule; | ||
import org.opentripplanner.openstreetmap.OsmProvider; | ||
import org.opentripplanner.routing.graph.Graph; | ||
import org.opentripplanner.transit.model.framework.Deduplicator; | ||
import org.opentripplanner.transit.service.StopModel; | ||
import org.opentripplanner.transit.service.TransitModel; | ||
|
||
class IslandPruningUtils { | ||
|
||
static Graph buildOsmGraph( | ||
File osmFile, | ||
int thresholdIslandWithoutStops, | ||
int thresholdIslandWithStops, | ||
double adaptivePruningFactor, | ||
int adaptivePruningDistance | ||
) { | ||
try { | ||
var deduplicator = new Deduplicator(); | ||
var graph = new Graph(deduplicator); | ||
var transitModel = new TransitModel(new StopModel(), deduplicator); | ||
// Add street data from OSM | ||
OsmProvider osmProvider = new OsmProvider(osmFile, true); | ||
OsmModule osmModule = OsmModule.of(osmProvider, graph).withEdgeNamer(new TestNamer()).build(); | ||
|
||
osmModule.buildGraph(); | ||
|
||
transitModel.index(); | ||
graph.index(transitModel.getStopModel()); | ||
|
||
// Prune floating islands and set noThru where necessary | ||
PruneIslands pruneIslands = new PruneIslands( | ||
graph, | ||
transitModel, | ||
DataImportIssueStore.NOOP, | ||
null | ||
); | ||
pruneIslands.setPruningThresholdIslandWithoutStops(thresholdIslandWithoutStops); | ||
pruneIslands.setPruningThresholdIslandWithStops(thresholdIslandWithStops); | ||
pruneIslands.setAdaptivePruningFactor(adaptivePruningFactor); | ||
pruneIslands.setAdaptivePruningDistance(adaptivePruningDistance); | ||
pruneIslands.buildGraph(); | ||
|
||
return graph; | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+501 Bytes
.../resources/org/opentripplanner/graph_builder/module/islandpruning/matinkyla-escalator.pbf
Binary file not shown.