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 intgetInt(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess) This method restores the integer value from the specified 'flags' taken from the storage.intReturns the maximum value set using this encoded value or the physical storage limit if no value has been set at all yet.intThe maximum int value this EncodedValue accepts for setInt without throwing an exception.intThe minimum int value this EncodedValue accepts for setInt without throwing an exception.final StringgetName()This method returns the hierarchical name like vehicle.type of this EncodedValuefinal intThis method sets the dataIndex and shift of this EncodedValue object and potentially changes the submitted init object afterwards via calling nextfinal booleanfinal voidsetInt(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess, int value) This method stores the specified integer value in the specified IntsRef.final StringtoString()
-
Constructor Details
-
IntEncodedValueImpl
- See Also:
-
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:EncodedValueThis method sets the dataIndex and shift of this EncodedValue object and potentially changes the submitted init object afterwards via calling next- Specified by:
initin interfaceEncodedValue- Returns:
- used bits
- See Also:
-
setInt
Description copied from interface:IntEncodedValueThis method stores the specified integer value in the specified IntsRef.- Specified by:
setIntin interfaceIntEncodedValue
-
getInt
Description copied from interface:IntEncodedValueThis method restores the integer value from the specified 'flags' taken from the storage.- Specified by:
getIntin interfaceIntEncodedValue
-
getMaxStorableInt
public int getMaxStorableInt()Description copied from interface:IntEncodedValueThe maximum int value this EncodedValue accepts for setInt without throwing an exception.- Specified by:
getMaxStorableIntin interfaceIntEncodedValue
-
getMinStorableInt
public int getMinStorableInt()Description copied from interface:IntEncodedValueThe minimum int value this EncodedValue accepts for setInt without throwing an exception.- Specified by:
getMinStorableIntin interfaceIntEncodedValue
-
getMaxOrMaxStorableInt
public int getMaxOrMaxStorableInt()Description copied from interface:IntEncodedValueReturns 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:
getMaxOrMaxStorableIntin interfaceIntEncodedValue
-
isStoreTwoDirections
public final boolean isStoreTwoDirections()- Specified by:
isStoreTwoDirectionsin interfaceEncodedValue- Specified by:
isStoreTwoDirectionsin interfaceIntEncodedValue- Returns:
- true if this EncodedValue can store a different value for its reverse direction
-
getName
Description copied from interface:EncodedValueThis method returns the hierarchical name like vehicle.type of this EncodedValue- Specified by:
getNamein interfaceEncodedValue
-
toString
-