Search in sources :

Example 1 with PathDetailsBuilder

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

the class Path method calcDetails.

/**
 * Calculates the PathDetails for this Path. This method will return fast, if there are no calculators.
 *
 * @param pathBuilderFactory Generates the relevant PathBuilders
 * @return List of PathDetails for this Path
 */
public Map<String, List<PathDetail>> calcDetails(List<String> requestedPathDetails, PathDetailsBuilderFactory pathBuilderFactory, int previousIndex) {
    if (!isFound() || requestedPathDetails.isEmpty())
        return Collections.EMPTY_MAP;
    List<PathDetailsBuilder> pathBuilders = pathBuilderFactory.createPathDetailsBuilders(requestedPathDetails, encoder, weighting);
    if (pathBuilders.isEmpty())
        return Collections.EMPTY_MAP;
    forEveryEdge(new PathDetailsFromEdges(pathBuilders, previousIndex));
    Map<String, List<PathDetail>> pathDetails = new HashMap<>(pathBuilders.size());
    for (PathDetailsBuilder builder : pathBuilders) {
        Map.Entry<String, List<PathDetail>> entry = builder.build();
        List<PathDetail> existing = pathDetails.put(entry.getKey(), entry.getValue());
        if (existing != null)
            throw new IllegalStateException("Some PathDetailsBuilders use duplicate key: " + entry.getKey());
    }
    return pathDetails;
}
Also used : PathDetail(com.graphhopper.util.details.PathDetail) PathDetailsFromEdges(com.graphhopper.util.details.PathDetailsFromEdges) GHIntArrayList(com.graphhopper.coll.GHIntArrayList) IntArrayList(com.carrotsearch.hppc.IntArrayList) PathDetailsBuilder(com.graphhopper.util.details.PathDetailsBuilder)

Aggregations

IntArrayList (com.carrotsearch.hppc.IntArrayList)1 GHIntArrayList (com.graphhopper.coll.GHIntArrayList)1 PathDetail (com.graphhopper.util.details.PathDetail)1 PathDetailsBuilder (com.graphhopper.util.details.PathDetailsBuilder)1 PathDetailsFromEdges (com.graphhopper.util.details.PathDetailsFromEdges)1