public class QueryGraph extends Object implements Graph
Calling any lookup 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 createEdgeExplorer()
only returns two
virtual edges per virtual node (the ones with correct base node).
Constructor and Description |
---|
QueryGraph(Graph graph) |
Modifier and Type | Method and Description |
---|---|
void |
clearUnfavoredStatus()
Removes the 'unfavored' status of all virtual edges.
|
Graph |
copyTo(Graph g)
Copy this Graph into the specified Graph g.
|
EdgeExplorer |
createEdgeExplorer() |
EdgeExplorer |
createEdgeExplorer(EdgeFilter edgeFilter)
Returns an EdgeExplorer which makes it possible to traverse all filtered edges of a specific
node.
|
EdgeIteratorState |
edge(int a,
int b)
Creates an edge between the nodes a and b.
|
EdgeIteratorState |
edge(int a,
int b,
double distance,
boolean bothDirections)
Use edge(a,b).setDistance().setFlags instead
|
EdgeIteratorState |
edge(int a,
int b,
double distance,
int flags) |
boolean |
enforceHeading(int nodeId,
double favoredHeading,
boolean incoming)
Set those edges at the virtual node (nodeId) to 'unfavored' that require at least a turn of
100° from favoredHeading.
|
AllEdgesIterator |
getAllEdges() |
Graph |
getBaseGraph() |
BBox |
getBounds()
Returns the implicit bounds of this graph calculated from the lat,lon input of setNode
|
EdgeIteratorState |
getEdgeIteratorState(int origEdgeId,
int adjNode)
Returns a wrapper over the specified edgeId.
|
int |
getEdges() |
GraphExtension |
getExtension() |
NodeAccess |
getNodeAccess()
Creates a node explorer to access node properties.
|
int |
getNodes() |
EdgeIteratorState |
getOriginalEdgeFromVirtNode(int nodeId) |
int |
getOtherNode(int edge,
int node) |
Set<EdgeIteratorState> |
getUnfavoredVirtualEdges()
Returns all virtual edges that have been unfavored via
enforceHeading(int, double, boolean) or unfavorVirtualEdgePair(int, int) . |
boolean |
isAdjacentToNode(int edge,
int node) |
boolean |
isVirtualEdge(int edgeId) |
boolean |
isVirtualNode(int nodeId) |
static QueryGraph |
lookup(Graph graph,
List<QueryResult> queryResults) |
void |
lookup(List<QueryResult> resList)
For all specified query results calculate snapped point and if necessary set closest node
to a virtual one and reverse closest edge.
|
QueryGraph |
lookup(QueryResult fromRes,
QueryResult toRes)
Convenient method to initialize this QueryGraph with the two specified query results.
|
QueryGraph |
setUseEdgeExplorerCache(boolean useEECache)
This method is an experimental feature to reduce memory and CPU resources if there are many
locations ("hundreds") for one QueryGraph.
|
void |
unfavorVirtualEdgePair(int virtualNodeId,
int virtualEdgeId)
Sets the virtual edge with virtualEdgeId and its reverse edge to 'unfavored', which
effectively penalizes both virtual edges towards an adjacent node of virtualNodeId.
|
public QueryGraph(Graph graph)
public static QueryGraph lookup(Graph graph, List<QueryResult> queryResults)
public QueryGraph lookup(QueryResult fromRes, QueryResult toRes)
lookup(List)
public void lookup(List<QueryResult> resList)
QueryGraph
public Graph getBaseGraph()
getBaseGraph
in interface Graph
public EdgeIteratorState getOriginalEdgeFromVirtNode(int nodeId)
public boolean isVirtualEdge(int edgeId)
public boolean isVirtualNode(int nodeId)
public QueryGraph setUseEdgeExplorerCache(boolean useEECache)
EdgeFilter
passed into createEdgeExplorer(EdgeFilter)
. For equal (in the java sense) EdgeFilter
s always
the same EdgeExplorer
will be returned when caching is enabled. Care has to be taken for example for
custom or threaded algorithms, when using custom EdgeFilter
s, or when the same edge explorer is used
with different vehicles/encoders.public boolean enforceHeading(int nodeId, double favoredHeading, boolean incoming)
nodeId
- VirtualNode at which edges get unfavoredfavoredHeading
- north based azimuth of favored heading between 0 and 360incoming
- if true, incoming edges are unfavored, else outgoing edgespublic void unfavorVirtualEdgePair(int virtualNodeId, int virtualEdgeId)
virtualNodeId
- virtual node at which edges get unfavoredvirtualEdgeId
- this edge and the reverse virtual edge become unfavoredpublic Set<EdgeIteratorState> getUnfavoredVirtualEdges()
enforceHeading(int, double, boolean)
or unfavorVirtualEdgePair(int, int)
.public void clearUnfavoredStatus()
public int getNodes()
public int getEdges()
public NodeAccess getNodeAccess()
Graph
getNodeAccess
in interface Graph
public BBox getBounds()
Graph
public EdgeIteratorState getEdgeIteratorState(int origEdgeId, int adjNode)
Graph
getEdgeIteratorState
in interface Graph
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 storedpublic EdgeExplorer createEdgeExplorer(EdgeFilter edgeFilter)
Graph
createEdgeExplorer
in interface Graph
EdgeExplorer
,
Graph.createEdgeExplorer()
public EdgeExplorer createEdgeExplorer()
createEdgeExplorer
in interface Graph
Graph.createEdgeExplorer(com.graphhopper.routing.util.EdgeFilter)
public AllEdgesIterator getAllEdges()
getAllEdges
in interface Graph
public EdgeIteratorState edge(int a, int b)
Graph
public EdgeIteratorState edge(int a, int b, double distance, int flags)
public EdgeIteratorState edge(int a, int b, double distance, boolean bothDirections)
Graph
public Graph copyTo(Graph g)
Graph
public GraphExtension getExtension()
getExtension
in interface Graph
public int getOtherNode(int edge, int node)
getOtherNode
in interface Graph
public boolean isAdjacentToNode(int edge, int node)
isAdjacentToNode
in interface Graph
Copyright © 2012–2019. All rights reserved.