Search in sources :

Example 16 with BooleanEncodedValue

use of com.graphhopper.routing.ev.BooleanEncodedValue in project graphhopper by graphhopper.

the class GraphHopperMultimodalIT method testSubnetworkRemoval.

@Test
public void testSubnetworkRemoval() {
    Profile foot = graphHopperGtfs.getProfile("foot");
    BooleanEncodedValue footSub = graphHopperGtfs.getEncodingManager().getBooleanEncodedValue(Subnetwork.key(foot.getName()));
    // Go through all edges on removed foot subnetworks, and check that we can get to our destination station from there
    List<GHResponse> responses = new ArrayList<>();
    AllEdgesIterator edges = graphHopperGtfs.getGraphHopperStorage().getAllEdges();
    while (edges.next()) {
        if (edges.get(footSub)) {
            Request ghRequest = new Request(Arrays.asList(new GHPointLocation(new GHPoint(graphHopperGtfs.getGraphHopperStorage().getNodeAccess().getLat(edges.getBaseNode()), graphHopperGtfs.getGraphHopperStorage().getNodeAccess().getLon(edges.getBaseNode()))), new GHStationLocation("EMSI")), LocalDateTime.of(2007, 1, 1, 6, 40, 0).atZone(zoneId).toInstant());
            // Yes, I can walk very fast, 50 km/h. Problem?
            ghRequest.setWalkSpeedKmH(50);
            // But I dislike walking a lot.
            ghRequest.setBetaStreetTime(20);
            GHResponse response = graphHopper.route(ghRequest);
            responses.add(response);
        }
    }
    // There is a removed subnetwork -- otherwise there's nothing to check
    assumeThat(responses).isNotEmpty();
    assertThat(responses).allMatch(r -> !r.getAll().isEmpty());
}
Also used : AllEdgesIterator(com.graphhopper.routing.util.AllEdgesIterator) BooleanEncodedValue(com.graphhopper.routing.ev.BooleanEncodedValue) ArrayList(java.util.ArrayList) GHPoint(com.graphhopper.util.shapes.GHPoint) Profile(com.graphhopper.config.Profile) Test(org.junit.jupiter.api.Test)

Aggregations

BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)16 Test (org.junit.jupiter.api.Test)8 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)6 ArrayList (java.util.ArrayList)4 AllEdgesIterator (com.graphhopper.routing.util.AllEdgesIterator)3 Weighting (com.graphhopper.routing.weighting.Weighting)3 Snap (com.graphhopper.storage.index.Snap)3 GHPoint (com.graphhopper.util.shapes.GHPoint)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 IntArrayList (com.carrotsearch.hppc.IntArrayList)2 Profile (com.graphhopper.config.Profile)2 ReaderWay (com.graphhopper.reader.ReaderWay)2 Path (com.graphhopper.routing.Path)2 RoutingAlgorithm (com.graphhopper.routing.RoutingAlgorithm)2 Subnetwork (com.graphhopper.routing.ev.Subnetwork)2 QueryGraph (com.graphhopper.routing.querygraph.QueryGraph)2 IntsRef (com.graphhopper.storage.IntsRef)2 IntHashSet (com.carrotsearch.hppc.IntHashSet)1 IntObjectMap (com.carrotsearch.hppc.IntObjectMap)1 IntObjectPredicate (com.carrotsearch.hppc.predicates.IntObjectPredicate)1