Package com.graphhopper.routing.ev
Class IntEncodedValueImpl
java.lang.Object
com.graphhopper.routing.ev.IntEncodedValueImpl
- All Implemented Interfaces:
EncodedValue
,IntEncodedValue
- Direct Known Subclasses:
DecimalEncodedValueImpl
,EnumEncodedValue
,SimpleBooleanEncodedValue
,StringEncodedValue
Implementation of the IntEncodedValue via a certain number of bits (that determines the maximum value) and
a minimum value (default is 0).
With storeTwoDirections = true it can store separate values for forward and reverse edge direction e.g. for one speed
value per direction of an edge.
With negateReverseDirection = true it supports negating the value for the reverse direction without storing a separate
value e.g. to store an elevation slope which is negative for the reverse direction but has otherwise the same value
and is used to save storage space.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.graphhopper.routing.ev.EncodedValue
EncodedValue.InitializerConfig
-
Constructor Summary
ConstructorsConstructorDescriptionIntEncodedValueImpl
(String name, int bits, boolean storeTwoDirections) IntEncodedValueImpl
(String name, int bits, int minStorableValue, boolean negateReverseDirection, boolean storeTwoDirections) This creates an EncodedValue to store an integer value with up to the specified bits. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
getInt
(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess) This method restores the integer value from the specified 'flags' taken from the storage.int
Returns the maximum value set using this encoded value or the physical storage limit if no value has been set at all yet.int
The maximum int value this EncodedValue accepts for setInt without throwing an exception.int
The minimum int value this EncodedValue accepts for setInt without throwing an exception.final String
getName()
This method returns the hierarchical name like vehicle.type of this EncodedValuefinal int
This method sets the dataIndex and shift of this EncodedValue object and potentially changes the submitted init object afterwards via calling nextfinal boolean
final void
setInt
(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess, int value) This method stores the specified integer value in the specified IntsRef.final String
toString()
-
Constructor Details
-
IntEncodedValueImpl
-
IntEncodedValueImpl
public IntEncodedValueImpl(String name, int bits, int minStorableValue, boolean negateReverseDirection, boolean storeTwoDirections) This creates an EncodedValue to store an integer value with up to the specified bits.- Parameters:
name
- the key to identify this EncodedValuebits
- the bits that should be reserved for storing the value. This determines the maximum value.minStorableValue
- the minimum value. Use e.g. 0 if no negative values are needed.negateReverseDirection
- true if the reverse direction should be always negative of the forward direction. This is used to reduce space and store the value only once. If this option is used you cannot use storeTwoDirections or a minValue different to 0.storeTwoDirections
- true if forward and backward direction of the edge should get two independent values.
-
-
Method Details
-
init
Description copied from interface:EncodedValue
This method sets the dataIndex and shift of this EncodedValue object and potentially changes the submitted init object afterwards via calling next- Specified by:
init
in interfaceEncodedValue
- Returns:
- used bits
- See Also:
-
EncodedValue.InitializerConfig.next(int)
-
setInt
Description copied from interface:IntEncodedValue
This method stores the specified integer value in the specified IntsRef.- Specified by:
setInt
in interfaceIntEncodedValue
-
getInt
Description copied from interface:IntEncodedValue
This method restores the integer value from the specified 'flags' taken from the storage.- Specified by:
getInt
in interfaceIntEncodedValue
-
getMaxStorableInt
public int getMaxStorableInt()Description copied from interface:IntEncodedValue
The maximum int value this EncodedValue accepts for setInt without throwing an exception.- Specified by:
getMaxStorableInt
in interfaceIntEncodedValue
-
getMinStorableInt
public int getMinStorableInt()Description copied from interface:IntEncodedValue
The minimum int value this EncodedValue accepts for setInt without throwing an exception.- Specified by:
getMinStorableInt
in interfaceIntEncodedValue
-
getMaxOrMaxStorableInt
public int getMaxOrMaxStorableInt()Description copied from interface:IntEncodedValue
Returns the maximum value set using this encoded value or the physical storage limit if no value has been set at all yet. Note that even when some values were set this is not equal to the global maximum across all values in the graph if values are set multiple times for the same edge and they are decreasing. However, the returned value will always be equal to or larger than the global maximum.- Specified by:
getMaxOrMaxStorableInt
in interfaceIntEncodedValue
-
isStoreTwoDirections
public final boolean isStoreTwoDirections()- Specified by:
isStoreTwoDirections
in interfaceEncodedValue
- Specified by:
isStoreTwoDirections
in interfaceIntEncodedValue
- Returns:
- true if this EncodedValue can store a different value for its reverse direction
-
getName
Description copied from interface:EncodedValue
This method returns the hierarchical name like vehicle.type of this EncodedValue- Specified by:
getName
in interfaceEncodedValue
-
toString
-