Class QueryGraphWeighting
java.lang.Object
com.graphhopper.routing.weighting.QueryGraphWeighting
- All Implemented Interfaces:
Weighting
Whenever a
QueryGraph
is used for shortest path calculations including turn costs we need to wrap the
Weighting
we want to use with this class. Otherwise turn costs at virtual nodes and/or including virtual
edges will not be calculated correctly.-
Constructor Summary
ConstructorsConstructorDescriptionQueryGraphWeighting
(BaseGraph graph, Weighting weighting, com.carrotsearch.hppc.IntArrayList closestEdges) -
Method Summary
Modifier and TypeMethodDescriptionlong
calcEdgeMillis
(EdgeIteratorState edgeState, boolean reverse) This method calculates the time taken (in milliseconds) to travel along the specified edgeState.double
calcEdgeWeight
(EdgeIteratorState edgeState, boolean reverse) This method calculates the weight of a givenEdgeIteratorState
.double
Used only for the heuristic estimation in A*long
calcTurnMillis
(int inEdge, int viaNode, int outEdge) double
calcTurnWeight
(int inEdge, int viaNode, int outEdge) getName()
boolean
This method can be used to check whether or not this weighting returns turn costs (or if they are all zero).toString()
-
Constructor Details
-
QueryGraphWeighting
-
-
Method Details
-
calcMinWeightPerDistance
public double calcMinWeightPerDistance()Description copied from interface:Weighting
Used only for the heuristic estimation in A*- Specified by:
calcMinWeightPerDistance
in interfaceWeighting
- 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.- Specified by:
calcEdgeWeight
in interfaceWeighting
- 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.
-
calcTurnWeight
public double calcTurnWeight(int inEdge, int viaNode, int outEdge) - Specified by:
calcTurnWeight
in interfaceWeighting
-
calcEdgeMillis
Description copied from interface:Weighting
This method calculates the time taken (in milliseconds) to travel along the specified edgeState. It is typically used for post-processing and on only a few thousand edges.- Specified by:
calcEdgeMillis
in interfaceWeighting
-
calcTurnMillis
public long calcTurnMillis(int inEdge, int viaNode, int outEdge) - Specified by:
calcTurnMillis
in interfaceWeighting
-
hasTurnCosts
public boolean hasTurnCosts()Description copied from interface:Weighting
This method can be used to check whether or not this weighting returns turn costs (or if they are all zero). This is sometimes needed to do safety checks as not all graph algorithms can be run edge-based and might yield wrong results when turn costs are applied while running node-based.- Specified by:
hasTurnCosts
in interfaceWeighting
-
getName
-
toString
-