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 TypeMethodDescriptiondoublegetDecimal(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess) doubledoubleThe maximum double value this EncodedValue accepts for setDecimal without throwing an exception.doubleThe minimum double value this EncodedValue accepts for setDecimal without throwing an exception.doublegetNextStorableValue(double value) doublevoidsetDecimal(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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.graphhopper.routing.ev.EncodedValue
getName, init
-
Constructor Details
-
DecimalEncodedValueImpl
- See Also:
-
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:DecimalEncodedValueThis method stores the specified double value (rounding with a previously defined factor) into the IntsRef.- Specified by:
setDecimalin interfaceDecimalEncodedValue- See Also:
-
getDecimal
- Specified by:
getDecimalin interfaceDecimalEncodedValue
-
getNextStorableValue
public double getNextStorableValue(double value) - Specified by:
getNextStorableValuein 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:
getSmallestNonZeroValuein interfaceDecimalEncodedValue
-
getMaxStorableDecimal
public double getMaxStorableDecimal()Description copied from interface:DecimalEncodedValueThe maximum double value this EncodedValue accepts for setDecimal without throwing an exception.- Specified by:
getMaxStorableDecimalin interfaceDecimalEncodedValue
-
getMinStorableDecimal
public double getMinStorableDecimal()Description copied from interface:DecimalEncodedValueThe minimum double value this EncodedValue accepts for setDecimal without throwing an exception.- Specified by:
getMinStorableDecimalin interfaceDecimalEncodedValue
-
getMaxOrMaxStorableDecimal
public double getMaxOrMaxStorableDecimal()- Specified by:
getMaxOrMaxStorableDecimalin interfaceDecimalEncodedValue- See Also:
-