Package com.graphhopper.routing.ev
Class DecimalEncodedValueImpl
java.lang.Object
com.graphhopper.routing.ev.IntEncodedValueImpl
com.graphhopper.routing.ev.DecimalEncodedValueImpl
- All Implemented Interfaces:
DecimalEncodedValue
,EncodedValue
,IntEncodedValue
public final class DecimalEncodedValueImpl
extends IntEncodedValueImpl
implements DecimalEncodedValue
This class holds a signed decimal value and stores it as an integer value via a conversion factor and a certain
number of bits that determine the maximum value.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.graphhopper.routing.ev.EncodedValue
EncodedValue.InitializerConfig
-
Constructor Summary
ConstructorsConstructorDescriptionDecimalEncodedValueImpl
(String name, int bits, double factor, boolean storeTwoDirections) DecimalEncodedValueImpl
(String name, int bits, double minStorableValue, double factor, boolean negateReverseDirection, boolean storeTwoDirections, boolean useMaximumAsInfinity) -
Method Summary
Modifier and TypeMethodDescriptiondouble
getDecimal
(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess) double
double
The maximum double value this EncodedValue accepts for setDecimal without throwing an exception.double
The minimum double value this EncodedValue accepts for setDecimal without throwing an exception.double
getNextStorableValue
(double value) double
void
setDecimal
(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess, double value) This method stores the specified double value (rounding with a previously defined factor) into the IntsRef.Methods inherited from class com.graphhopper.routing.ev.IntEncodedValueImpl
getInt, getMaxOrMaxStorableInt, getMaxStorableInt, getMinStorableInt, getName, init, isStoreTwoDirections, setInt, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.graphhopper.routing.ev.EncodedValue
getName, init
-
Constructor Details
-
DecimalEncodedValueImpl
-
DecimalEncodedValueImpl
public DecimalEncodedValueImpl(String name, int bits, double minStorableValue, double factor, boolean negateReverseDirection, boolean storeTwoDirections, boolean useMaximumAsInfinity) - Parameters:
name
- the key to identify this EncodedValuebits
- the bits that should be reserved for storing the integer value. This determines the maximum value.minStorableValue
- the minimum storable value. Use e.g. 0 if no negative values are needed.factor
- the precision factor, i.e. store = (int) Math.round(value / factor)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.storeTwoDirections
- true if forward and backward direction of the edge should get two independent values.useMaximumAsInfinity
- true if the maximum value should be treated as Double.Infinity
-
-
Method Details
-
setDecimal
Description copied from interface:DecimalEncodedValue
This method stores the specified double value (rounding with a previously defined factor) into the IntsRef.- Specified by:
setDecimal
in interfaceDecimalEncodedValue
- See Also:
-
getDecimal
- Specified by:
getDecimal
in interfaceDecimalEncodedValue
-
getNextStorableValue
public double getNextStorableValue(double value) - Specified by:
getNextStorableValue
in interfaceDecimalEncodedValue
- Returns:
- the smallest decimal value that is larger or equal to the given value and that can be stored exactly,
i.e. for which
DecimalEncodedValue.getDecimal(boolean, int, com.graphhopper.routing.ev.EdgeIntAccess)
returns the same value that we put in usingDecimalEncodedValue.setDecimal(boolean, int, com.graphhopper.routing.ev.EdgeIntAccess, double)
. For example if the internal scaling factor is 3 calling getDecimal after setDecimal(reverse, ref, 5) will return 6 not 5! The value returned by this method is guaranteed to be storable without such a modification.
-
getSmallestNonZeroValue
public double getSmallestNonZeroValue()- Specified by:
getSmallestNonZeroValue
in interfaceDecimalEncodedValue
-
getMaxStorableDecimal
public double getMaxStorableDecimal()Description copied from interface:DecimalEncodedValue
The maximum double value this EncodedValue accepts for setDecimal without throwing an exception.- Specified by:
getMaxStorableDecimal
in interfaceDecimalEncodedValue
-
getMinStorableDecimal
public double getMinStorableDecimal()Description copied from interface:DecimalEncodedValue
The minimum double value this EncodedValue accepts for setDecimal without throwing an exception.- Specified by:
getMinStorableDecimal
in interfaceDecimalEncodedValue
-
getMaxOrMaxStorableDecimal
public double getMaxOrMaxStorableDecimal()- Specified by:
getMaxOrMaxStorableDecimal
in interfaceDecimalEncodedValue
- See Also:
-