Class FastestWeighting
java.lang.Object
com.graphhopper.routing.weighting.AbstractWeighting
com.graphhopper.routing.weighting.FastestWeighting
- All Implemented Interfaces:
Weighting
Calculates the fastest route with the specified vehicle (VehicleEncoder). Calculates the weight
in seconds.
- Author:
- Peter Karich
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic String
static String
protected static final double
Converting to seconds is not necessary but makes adding other penalties easier (e.g.Fields inherited from class com.graphhopper.routing.weighting.AbstractWeighting
accessEnc, speedEnc
Fields inherited from interface com.graphhopper.routing.weighting.Weighting
INFINITE_U_TURN_COSTS
-
Constructor Summary
ConstructorsConstructorDescriptionFastestWeighting
(BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc) FastestWeighting
(BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc, EnumEncodedValue<RoadAccess> roadAccessEnc, PMap map, TurnCostProvider turnCostProvider) FastestWeighting
(BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc, TurnCostProvider turnCostProvider) -
Method Summary
Modifier and TypeMethodDescriptiondouble
calcEdgeWeight
(EdgeIteratorState edgeState, boolean reverse) This method calculates the weight of a givenEdgeIteratorState
.double
Used only for the heuristic estimation in A*getName()
Methods inherited from class com.graphhopper.routing.weighting.AbstractWeighting
calcEdgeMillis, calcTurnMillis, calcTurnWeight, hasTurnCosts, toString
-
Field Details
-
DESTINATION_FACTOR
-
PRIVATE_FACTOR
-
SPEED_CONV
protected static final double SPEED_CONVConverting to seconds is not necessary but makes adding other penalties easier (e.g. turn costs or traffic light costs etc)- See Also:
-
-
Constructor Details
-
FastestWeighting
-
FastestWeighting
public FastestWeighting(BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc, TurnCostProvider turnCostProvider) -
FastestWeighting
public FastestWeighting(BooleanEncodedValue accessEnc, DecimalEncodedValue speedEnc, EnumEncodedValue<RoadAccess> roadAccessEnc, PMap map, TurnCostProvider turnCostProvider)
-
-
Method Details
-
calcMinWeightPerDistance
public double calcMinWeightPerDistance()Description copied from interface:Weighting
Used only for the heuristic estimation in A*- Returns:
- minimal weight per meter. E.g. if you calculate the fastest way the return value is '1/max_velocity' or a shortest weighting would return 1.
-
calcEdgeWeight
Description copied from interface:Weighting
This method calculates the weight of a givenEdgeIteratorState
. E.g. a high value indicates that the edge should be avoided during shortest path search. Make sure that this method is very fast and optimized as this is called potentially millions of times for one route or a lot more for nearly any preprocessing phase.- Parameters:
edgeState
- the edge for which the weight should be calculatedreverse
- if the specified edge is specified in reverse direction e.g. from the reverse case of a bidirectional search.- Returns:
- the calculated weight with the specified velocity has to be in the range of 0 and +Infinity. Make sure your method does not return NaN which can e.g. occur for 0/0.
-
getName
-