Class QueryGraph
java.lang.Object
com.graphhopper.routing.querygraph.QueryGraph
- All Implemented Interfaces:
Graph
A class which is used to query the underlying graph with real GPS points. It does so by
introducing virtual nodes and edges. It is lightweight in order to be created every time a new
query comes in, which makes the behaviour thread safe.
Calling any create
method creates virtual edges between the tower nodes of the existing
graph and new virtual tower nodes. Every virtual node has two adjacent nodes and is connected
to each adjacent nodes via 2 virtual edges with opposite base node / adjacent node encoding.
However, the edge explorer returned by Graph.createEdgeExplorer()
only returns two
virtual edges per virtual node (the ones with correct base node).
- Author:
- Peter Karich
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Removes the 'unfavored' status of all virtual edges.static QueryGraph
static QueryGraph
static QueryGraph
createEdgeExplorer
(EdgeFilter edgeFilter) Returns an EdgeExplorer which makes it possible to traverse all filtered edges of a specific node.edge
(int a, int b) Creates an edge between the nodes a and b.Returns the implicit bounds of this graph calculated from the lat,lon input of setNodegetEdgeIteratorState
(int origEdgeId, int adjNode) Returns a wrapper over the specified edgeId.getEdgeIteratorStateForKey
(int edgeKey) Returns the edge state for the given edge keyint
getEdges()
Creates an object to access node properties.int
getNodes()
int
getOtherNode
(int edge, int node) com.graphhopper.routing.querygraph.QueryOverlay
Returns all virtual edges that have been unfavored viaunfavorVirtualEdge(int)
orunfavorVirtualEdges(IntArrayList)
boolean
isAdjacentToNode
(int edge, int node) boolean
isVirtualEdge
(int edgeId) boolean
isVirtualNode
(int nodeId) void
unfavorVirtualEdge
(int virtualEdgeId) Assigns the 'unfavored' flag to a virtual edge (for both directions)void
unfavorVirtualEdges
(com.carrotsearch.hppc.IntArrayList edgeIds) wrapWeighting
(Weighting weighting) Wraps the given weighting into a weighting that can be used by this graphMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.graphhopper.storage.Graph
createEdgeExplorer
-
Method Details
-
create
-
create
-
create
-
getQueryOverlay
public com.graphhopper.routing.querygraph.QueryOverlay getQueryOverlay() -
getBaseGraph
- Specified by:
getBaseGraph
in interfaceGraph
- Returns:
- a graph which behaves like an unprepared graph and e.g. the normal unidirectional Dijkstra or any graph traversal algorithm can be executed.
-
isVirtualEdge
public boolean isVirtualEdge(int edgeId) -
isVirtualNode
public boolean isVirtualNode(int nodeId) -
unfavorVirtualEdges
public void unfavorVirtualEdges(com.carrotsearch.hppc.IntArrayList edgeIds) -
unfavorVirtualEdge
public void unfavorVirtualEdge(int virtualEdgeId) Assigns the 'unfavored' flag to a virtual edge (for both directions) -
getUnfavoredVirtualEdges
Returns all virtual edges that have been unfavored viaunfavorVirtualEdge(int)
orunfavorVirtualEdges(IntArrayList)
-
clearUnfavoredStatus
public void clearUnfavoredStatus()Removes the 'unfavored' status of all virtual edges. -
getNodes
public int getNodes() -
getEdges
public int getEdges() -
getNodeAccess
Description copied from interface:Graph
Creates an object to access node properties.- Specified by:
getNodeAccess
in interfaceGraph
-
getBounds
Description copied from interface:Graph
Returns the implicit bounds of this graph calculated from the lat,lon input of setNode -
getEdgeIteratorState
Description copied from interface:Graph
Returns a wrapper over the specified edgeId.- Specified by:
getEdgeIteratorState
in interfaceGraph
adjNode
- is the node that will be returned via getAdjNode(). If adjNode is Integer.MIN_VALUE then the edge will be returned in the direction of how it is stored- Returns:
- a new EdgeIteratorState object or potentially null if adjNode does not match
-
getEdgeIteratorStateForKey
Description copied from interface:Graph
Returns the edge state for the given edge key- Specified by:
getEdgeIteratorStateForKey
in interfaceGraph
- See Also:
-
createEdgeExplorer
Description copied from interface:Graph
Returns an EdgeExplorer which makes it possible to traverse all filtered edges of a specific node. Calling this method might be expensive, so e.g. create an explorer before a for loop!- Specified by:
createEdgeExplorer
in interfaceGraph
-
getAllEdges
- Specified by:
getAllEdges
in interfaceGraph
- Returns:
- all edges in this graph, where baseNode will be the smaller node.
-
edge
Description copied from interface:Graph
Creates an edge between the nodes a and b. To set distance or access use the returned edge and e.g. edgeState.setDistance -
getTurnCostStorage
- Specified by:
getTurnCostStorage
in interfaceGraph
- Returns:
- the
TurnCostStorage
or null if not supported
-
wrapWeighting
Description copied from interface:Graph
Wraps the given weighting into a weighting that can be used by this graph- Specified by:
wrapWeighting
in interfaceGraph
-
getOtherNode
public int getOtherNode(int edge, int node) - Specified by:
getOtherNode
in interfaceGraph
- Returns:
- the 'opposite' node of a given edge, so if there is an edge 3-2 and node =2 this returns 3
-
isAdjacentToNode
public boolean isAdjacentToNode(int edge, int node) - Specified by:
isAdjacentToNode
in interfaceGraph
- Returns:
- true if the edge with id edge is adjacent to node, false otherwise
-