-
Notifications
You must be signed in to change notification settings - Fork 1k
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 #5732 from entur/fix_roundabout_direct_routing
Fix street routing on roundabout
- Loading branch information
Showing
4 changed files
with
75 additions
and
12 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
74 changes: 74 additions & 0 deletions
74
src/test/java/org/opentripplanner/street/integration/WalkRoutingTest.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,74 @@ | ||
package org.opentripplanner.street.integration; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.opentripplanner.ConstantsForTests; | ||
import org.opentripplanner.TestOtpModel; | ||
import org.opentripplanner.astar.model.GraphPath; | ||
import org.opentripplanner.model.GenericLocation; | ||
import org.opentripplanner.routing.api.request.RouteRequest; | ||
import org.opentripplanner.routing.api.request.StreetMode; | ||
import org.opentripplanner.routing.graph.Graph; | ||
import org.opentripplanner.routing.impl.GraphPathFinder; | ||
import org.opentripplanner.street.model.edge.Edge; | ||
import org.opentripplanner.street.model.vertex.Vertex; | ||
import org.opentripplanner.street.search.TemporaryVerticesContainer; | ||
import org.opentripplanner.street.search.state.State; | ||
import org.opentripplanner.test.support.ResourceLoader; | ||
|
||
class WalkRoutingTest { | ||
|
||
static final Instant dateTime = Instant.now(); | ||
private final Graph roundabout; | ||
|
||
{ | ||
TestOtpModel model = ConstantsForTests.buildOsmGraph( | ||
ResourceLoader.of(WalkRoutingTest.class).file("roundabout.osm.pbf") | ||
); | ||
roundabout = model.graph(); | ||
|
||
model.transitModel().index(); | ||
roundabout.index(model.transitModel().getStopModel()); | ||
} | ||
|
||
/** | ||
* Both https://www.openstreetmap.org/way/146988098 and | ||
* https://www.openstreetmap.org/way/146988099 are routable for pedestrians, the routing engine | ||
* should return a path from any point of the first way to any point of the second. | ||
* <br> | ||
* See also <a href="https://github.com/opentripplanner/OpenTripPlanner/issues/5706">issue | ||
* #5706</a> | ||
*/ | ||
@Test | ||
void shouldRouteAroundRoundabout() { | ||
var start = new GenericLocation(59.94646, 10.77511); | ||
var end = new GenericLocation(59.94641, 10.77522); | ||
Assertions.assertDoesNotThrow(() -> route(roundabout, start, end)); | ||
} | ||
|
||
private static List<GraphPath<State, Edge, Vertex>> route( | ||
Graph graph, | ||
GenericLocation from, | ||
GenericLocation to | ||
) { | ||
RouteRequest request = new RouteRequest(); | ||
request.setDateTime(dateTime); | ||
request.setFrom(from); | ||
request.setTo(to); | ||
request.journey().direct().setMode(StreetMode.WALK); | ||
|
||
try ( | ||
var temporaryVertices = new TemporaryVerticesContainer( | ||
graph, | ||
request, | ||
request.journey().direct().mode(), | ||
request.journey().direct().mode() | ||
) | ||
) { | ||
var gpf = new GraphPathFinder(null); | ||
return gpf.graphPathFinderEntryPoint(request, temporaryVertices); | ||
} | ||
} | ||
} |
Binary file added
BIN
+3.89 KB
src/test/resources/org/opentripplanner/street/integration/roundabout.osm.pbf
Binary file not shown.