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 classInclude all edges of this storage in the iterator.static classprotected static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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.voidedge(int nodeA, int nodeB) Create edge between nodes a and bvoidflush()voidFlush and free resources that are not needed for post-processing (way geometries and KVStorage for edges).voidfreeze()Returns the implicit bounds of this graph calculated from the lat,lon input of setNodelonggetEdgeIteratorState(int edgeId, int adjNode) Returns a wrapper over the specified edgeId.getEdgeIteratorStateForKey(int edgeKey) Returns the edge state for the given edge keyintgetEdges()intCreates an object to access node properties.intgetNodes()intgetOtherNode(int edge, int node) intbooleanisAdjacentToNode(int edge, int node) booleanisClosed()booleanisFrozen()booleanbooleanwrapWeighting(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:
getBaseGraphin 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:GraphCreates an object to access node properties.- Specified by:
getNodeAccessin interfaceGraph
-
getBounds
Description copied from interface:GraphReturns 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getCapacity
public long getCapacity() -
loadExisting
public boolean loadExisting() -
edge
Create edge between nodes a and b -
getEdgeIteratorState
Description copied from interface:GraphReturns a wrapper over the specified edgeId.- Specified by:
getEdgeIteratorStatein interfaceGraphadjNode- 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:GraphReturns the edge state for the given edge key- Specified by:
getEdgeIteratorStateForKeyin interfaceGraph- See Also:
-
createEdgeExplorer
Description copied from interface:GraphReturns 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:
createEdgeExplorerin interfaceGraph
-
createEdgeExplorer
Description copied from interface:GraphCreates an EdgeExplorer that accepts all edges- Specified by:
createEdgeExplorerin interfaceGraph- See Also:
-
getAllEdges
- Specified by:
getAllEdgesin interfaceGraph- Returns:
- all edges in this graph, where baseNode will be the smaller node.
-
getTurnCostStorage
- Specified by:
getTurnCostStoragein interfaceGraph- Returns:
- the
TurnCostStorageor null if not supported
-
wrapWeighting
Description copied from interface:GraphWraps the given weighting into a weighting that can be used by this graph- Specified by:
wrapWeightingin interfaceGraph
-
getOtherNode
public int getOtherNode(int edge, int node) - Specified by:
getOtherNodein 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:
isAdjacentToNodein 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()
-