Search in sources :

Example 11 with PathDetail

use of com.graphhopper.util.details.PathDetail in project graphhopper by graphhopper.

the class PathTest method testCalcAverageSpeedDetails.

@Test
public void testCalcAverageSpeedDetails() {
    Path p = new Dijkstra(pathDetailGraph, new ShortestWeighting(encoder), TraversalMode.NODE_BASED).calcPath(1, 5);
    assertTrue(p.isFound());
    Map<String, List<PathDetail>> details = p.calcDetails(Arrays.asList(new String[] { AVERAGE_SPEED }), new PathDetailsBuilderFactory(), 0);
    assertTrue(details.size() == 1);
    List<PathDetail> averageSpeedDetails = details.get(AVERAGE_SPEED);
    assertEquals(4, averageSpeedDetails.size());
    assertEquals(45.0, averageSpeedDetails.get(0).getValue());
    assertEquals(90.0, averageSpeedDetails.get(1).getValue());
    assertEquals(10.0, averageSpeedDetails.get(2).getValue());
    assertEquals(45.0, averageSpeedDetails.get(3).getValue());
    assertEquals(0, averageSpeedDetails.get(0).getFirst());
    assertEquals(1, averageSpeedDetails.get(1).getFirst());
    assertEquals(2, averageSpeedDetails.get(2).getFirst());
    assertEquals(3, averageSpeedDetails.get(3).getFirst());
    assertEquals(4, averageSpeedDetails.get(3).getLast());
}
Also used : PathDetailsBuilderFactory(com.graphhopper.util.details.PathDetailsBuilderFactory) PathDetail(com.graphhopper.util.details.PathDetail) AbstractGraphStorageTester.assertPList(com.graphhopper.storage.AbstractGraphStorageTester.assertPList) ShortestWeighting(com.graphhopper.routing.weighting.ShortestWeighting) Test(org.junit.Test)

Aggregations

PathDetail (com.graphhopper.util.details.PathDetail)11 Test (org.junit.Test)6 ShortestWeighting (com.graphhopper.routing.weighting.ShortestWeighting)4 AbstractGraphStorageTester.assertPList (com.graphhopper.storage.AbstractGraphStorageTester.assertPList)4 PathDetailsBuilderFactory (com.graphhopper.util.details.PathDetailsBuilderFactory)4 GHPoint (com.graphhopper.util.shapes.GHPoint)3 List (java.util.List)3 GHRequest (com.graphhopper.GHRequest)2 GHResponse (com.graphhopper.GHResponse)2 PathWrapper (com.graphhopper.PathWrapper)2 ArrayList (java.util.ArrayList)2 IntArrayList (com.carrotsearch.hppc.IntArrayList)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 GraphHopperAPI (com.graphhopper.GraphHopperAPI)1 GHIntArrayList (com.graphhopper.coll.GHIntArrayList)1 PathDetailsBuilder (com.graphhopper.util.details.PathDetailsBuilder)1 PathDetailsFromEdges (com.graphhopper.util.details.PathDetailsFromEdges)1 Map (java.util.Map)1