Class VirtualEdgeIteratorState
java.lang.Object
com.graphhopper.routing.querygraph.VirtualEdgeIteratorState
- All Implemented Interfaces:
EdgeIteratorState
Creates an edge state decoupled from a graph where nodes, pointList, etc are kept in memory.
Note, this class is not suited for public use and can change with minor releases unexpectedly or even gets removed.
-
Field Summary
Fields inherited from interface com.graphhopper.util.EdgeIteratorState
REVERSE_STATE, UNFAVORED_EDGE
-
Constructor Summary
ConstructorsConstructorDescriptionVirtualEdgeIteratorState
(int originalEdgeKey, int edgeKey, int baseNode, int adjNode, double distance, IntsRef edgeFlags, List<KVStorage.KeyValue> keyValues, PointList pointList, boolean reverse) -
Method Summary
Modifier and TypeMethodDescriptioncopyPropertiesFrom
(EdgeIteratorState fromEdge) Copies the properties of the specified edge into this edge.detach
(boolean reverse) Clones this EdgeIteratorState.fetchWayGeometry
(FetchMode mode) For road network data like OSM a way is often not just a straight line.boolean
get
(BooleanEncodedValue property) double
get
(DecimalEncodedValue property) <T extends Enum<?>>
Tget
(EnumEncodedValue<T> property) int
get
(IntEncodedValue property) get
(StringEncodedValue property) int
int
Returns the node used to instantiate the EdgeIterator.double
int
getEdge()
int
Returns the edge key of the current edge.getFlags()
Returns edge properties stored in direction of the raw database layout.This method returns KeyValue pairs for both directions in contrast toEdgeIteratorState.getValue(String)
.getName()
Identical to calling getKeyValues().get("name") if name is stored for both directions.int
This method returns the original (not virtual!) edge key.boolean
getReverse
(BooleanEncodedValue property) double
getReverse
(DecimalEncodedValue property) <T extends Enum<?>>
TgetReverse
(EnumEncodedValue<T> property) int
getReverse
(IntEncodedValue property) getReverse
(StringEncodedValue property) int
Like #getEdgeKey, but returns the reverse key.This method returns the *first* value for the specified key and only if stored for the direction of this EdgeIteratorState.set
(BooleanEncodedValue property, boolean value) set
(BooleanEncodedValue property, boolean fwd, boolean bwd) set
(DecimalEncodedValue property, double value) set
(DecimalEncodedValue property, double fwd, double bwd) <T extends Enum<?>>
EdgeIteratorStateset
(EnumEncodedValue<T> property, T value) <T extends Enum<?>>
EdgeIteratorStateset
(EnumEncodedValue<T> property, T fwd, T bwd) set
(IntEncodedValue property, int value) set
(IntEncodedValue property, int fwd, int bwd) set
(StringEncodedValue property, String value) set
(StringEncodedValue property, String fwd, String bwd) setDistance
(double dist) Stores the specified edgeFlags down to the DataAccesssetKeyValues
(List<KVStorage.KeyValue> list) This stores the specified key-value pairs in the storage of this EdgeIteratorState.setReverse
(BooleanEncodedValue property, boolean value) setReverse
(DecimalEncodedValue property, double value) <T extends Enum<?>>
EdgeIteratorStatesetReverse
(EnumEncodedValue<T> property, T value) setReverse
(IntEncodedValue property, int value) setReverse
(StringEncodedValue property, String value) void
setReverseEdge
(EdgeIteratorState reverseEdge) void
setUnfavored
(boolean unfavored) This method sets edge to unfavored status for routing from the start or to the stop location.setWayGeometry
(PointList list) toString()
-
Constructor Details
-
VirtualEdgeIteratorState
public VirtualEdgeIteratorState(int originalEdgeKey, int edgeKey, int baseNode, int adjNode, double distance, IntsRef edgeFlags, List<KVStorage.KeyValue> keyValues, PointList pointList, boolean reverse)
-
-
Method Details
-
getOriginalEdgeKey
public int getOriginalEdgeKey()This method returns the original (not virtual!) edge key. I.e. also the direction is already correctly encoded.- See Also:
-
getEdge
public int getEdge()- Specified by:
getEdge
in interfaceEdgeIteratorState
- Returns:
- the edge id of the current edge. Do not make any assumptions about the concrete values, except that for an implementation it is recommended that they'll be contiguous.
-
getEdgeKey
public int getEdgeKey()Description copied from interface:EdgeIteratorState
Returns the edge key of the current edge. The edge id can be derived from the edge key by callingGHUtility.getEdgeFromEdgeKey(int)
, but the edge key also contains information about the direction of the edge. The edge key is even when the edge is oriented in storage direction and odd otherwise. You can use the edge key to retrieve an edge state in the associated direction usingGraph.getEdgeIteratorStateForKey(int)
.- Specified by:
getEdgeKey
in interfaceEdgeIteratorState
-
getReverseEdgeKey
public int getReverseEdgeKey()Description copied from interface:EdgeIteratorState
Like #getEdgeKey, but returns the reverse key.- Specified by:
getReverseEdgeKey
in interfaceEdgeIteratorState
-
getBaseNode
public int getBaseNode()Description copied from interface:EdgeIteratorState
Returns the node used to instantiate the EdgeIterator. Often only used for convenience reasons. Do not confuse this with a source node of a directed edge.- Specified by:
getBaseNode
in interfaceEdgeIteratorState
- Returns:
- the requested node itself
- See Also:
-
getAdjNode
public int getAdjNode()- Specified by:
getAdjNode
in interfaceEdgeIteratorState
- Returns:
- the adjacent node of baseNode for the current edge.
- See Also:
-
fetchWayGeometry
Description copied from interface:EdgeIteratorState
For road network data like OSM a way is often not just a straight line. The nodes between the junction nodes are called pillar nodes. The junction nodes are called tower nodes and used for routing. The pillar nodes are necessary to have an exact geometry. See the docs for more information (docs/core/low-level-api.md#what-are-pillar-and-tower-nodes). Updates to the returned list are not reflected in the graph, for that you've to use setWayGeometry.- Specified by:
fetchWayGeometry
in interfaceEdgeIteratorState
- Parameters:
mode
-FetchMode
- Returns:
- the pillar and/or tower nodes depending on the mode.
-
setWayGeometry
- Specified by:
setWayGeometry
in interfaceEdgeIteratorState
- Parameters:
list
- is a sorted collection of coordinates between the base node and the current adjacent node. Specify the list without the adjacent and base node. This method can be called multiple times, but if the distance changes, the setDistance method is not called automatically.
-
getDistance
public double getDistance()- Specified by:
getDistance
in interfaceEdgeIteratorState
- Returns:
- the distance of the current edge in meter
-
setDistance
- Specified by:
setDistance
in interfaceEdgeIteratorState
-
getFlags
Description copied from interface:EdgeIteratorState
Returns edge properties stored in direction of the raw database layout. So do not use it directly, instead use the appropriate set/get methods with its EncodedValue object.- Specified by:
getFlags
in interfaceEdgeIteratorState
-
setFlags
Description copied from interface:EdgeIteratorState
Stores the specified edgeFlags down to the DataAccess- Specified by:
setFlags
in interfaceEdgeIteratorState
-
get
- Specified by:
get
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
getReverse
- Specified by:
getReverse
in interfaceEdgeIteratorState
-
setReverse
- Specified by:
setReverse
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
get
- Specified by:
get
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
getReverse
- Specified by:
getReverse
in interfaceEdgeIteratorState
-
setReverse
- Specified by:
setReverse
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
get
- Specified by:
get
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
getReverse
- Specified by:
getReverse
in interfaceEdgeIteratorState
-
setReverse
- Specified by:
setReverse
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
get
- Specified by:
get
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
getReverse
- Specified by:
getReverse
in interfaceEdgeIteratorState
-
setReverse
- Specified by:
setReverse
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
get
- Specified by:
get
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
getReverse
- Specified by:
getReverse
in interfaceEdgeIteratorState
-
setReverse
- Specified by:
setReverse
in interfaceEdgeIteratorState
-
set
- Specified by:
set
in interfaceEdgeIteratorState
-
getName
Description copied from interface:EdgeIteratorState
Identical to calling getKeyValues().get("name") if name is stored for both directions. Note that for backward compatibility this method returns an empty String instead of null if there was no KeyPair with key==name stored.- Specified by:
getName
in interfaceEdgeIteratorState
- Returns:
- the stored value for the key "name" in the KeyValue list of this EdgeIteratorState.
-
setKeyValues
Description copied from interface:EdgeIteratorState
This stores the specified key-value pairs in the storage of this EdgeIteratorState. This is more flexible compared to the mechanism of flags and EncodedValue and allows storing sparse key value pairs more efficient. But it might be slow and more inefficient on retrieval. Call this setKeyValues method only once per EdgeIteratorState as it allocates new space everytime this method is called.- Specified by:
setKeyValues
in interfaceEdgeIteratorState
-
getKeyValues
Description copied from interface:EdgeIteratorState
This method returns KeyValue pairs for both directions in contrast toEdgeIteratorState.getValue(String)
.- Specified by:
getKeyValues
in interfaceEdgeIteratorState
- See Also:
-
getValue
Description copied from interface:EdgeIteratorState
This method returns the *first* value for the specified key and only if stored for the direction of this EdgeIteratorState. If you need more than one value see alsoEdgeIteratorState.getKeyValues()
. Avoid storing KeyPairs with duplicate keys as only the first will be reachable with this method. Currently, there is no support to use this method in a custom_model, and you should use EncodedValues instead.- Specified by:
getValue
in interfaceEdgeIteratorState
-
setUnfavored
public void setUnfavored(boolean unfavored) This method sets edge to unfavored status for routing from the start or to the stop location. -
toString
-
detach
Description copied from interface:EdgeIteratorState
Clones this EdgeIteratorState.- Specified by:
detach
in interfaceEdgeIteratorState
- Parameters:
reverse
- if true a detached edgeState with reversed properties is created where base and adjacent nodes, flags and wayGeometry are in reversed order. See #162 for more details about why we need the reverse parameter.
-
copyPropertiesFrom
Description copied from interface:EdgeIteratorState
Copies the properties of the specified edge into this edge. Does not change nodes!- Specified by:
copyPropertiesFrom
in interfaceEdgeIteratorState
- Returns:
- the specified edge e
-
setReverseEdge
-