Package com.graphhopper.storage
Class BaseGraph
java.lang.Object
com.graphhopper.storage.BaseGraph
- All Implemented Interfaces:
Graph
,Closeable
,AutoCloseable
The base graph handles nodes and edges file format. It can be used with different Directory
implementations like RAMDirectory for fast access or via MMapDirectory for virtual-memory and not
thread safe usage.
Note: A RAM DataAccess Object is thread-safe in itself but if used in this Graph implementation it is not write thread safe.
Life cycle: (1) object creation, (2) configuration via setters & getters, (3) create or loadExisting, (4) usage, (5) flush, (6) close
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Include all edges of this storage in the iterator.static class
protected static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
create
(long initSize) Creates an EdgeExplorer that accepts all edgescreateEdgeExplorer
(EdgeFilter filter) Returns an EdgeExplorer which makes it possible to traverse all filtered edges of a specific node.void
edge
(int nodeA, int nodeB) Create edge between nodes a and bvoid
flush()
void
Flush and free resources that are not needed for post-processing (way geometries and KVStorage for edges).void
freeze()
Returns the implicit bounds of this graph calculated from the lat,lon input of setNodelong
getEdgeIteratorState
(int edgeId, int adjNode) Returns a wrapper over the specified edgeId.getEdgeIteratorStateForKey
(int edgeKey) Returns the edge state for the given edge keyint
getEdges()
int
Creates an object to access node properties.int
getNodes()
int
getOtherNode
(int edge, int node) int
boolean
isAdjacentToNode
(int edge, int node) boolean
isClosed()
boolean
isFrozen()
boolean
boolean
wrapWeighting
(Weighting weighting) Wraps the given weighting into a weighting that can be used by this graph
-
Constructor Details
-
BaseGraph
public BaseGraph(Directory dir, int intsForFlags, boolean withElevation, boolean withTurnCosts, int segmentSize)
-
-
Method Details
-
debugPrint
public void debugPrint() -
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.
-
isInitialized
public boolean isInitialized() -
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 -
freeze
public void freeze() -
isFrozen
public boolean isFrozen() -
create
-
getIntsForFlags
public int getIntsForFlags() -
toDetailsString
-
flushAndCloseGeometryAndNameStorage
public void flushAndCloseGeometryAndNameStorage()Flush and free resources that are not needed for post-processing (way geometries and KVStorage for edges). -
flush
public void flush() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getCapacity
public long getCapacity() -
loadExisting
public boolean loadExisting() -
edge
Create edge between nodes a and b -
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
-
createEdgeExplorer
Description copied from interface:Graph
Creates an EdgeExplorer that accepts all edges- Specified by:
createEdgeExplorer
in interfaceGraph
- See Also:
-
getAllEdges
- Specified by:
getAllEdges
in interfaceGraph
- Returns:
- all edges in this graph, where baseNode will be the smaller node.
-
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
-
createEdgeIntAccess
-
isClosed
public boolean isClosed() -
getDirectory
-
getSegmentSize
public int getSegmentSize()
-