Class IntEncodedValueImpl

java.lang.Object
com.graphhopper.routing.ev.IntEncodedValueImpl
All Implemented Interfaces:
EncodedValue, IntEncodedValue
Direct Known Subclasses:
DecimalEncodedValueImpl, EnumEncodedValue, SimpleBooleanEncodedValue, StringEncodedValue

public class IntEncodedValueImpl extends Object implements IntEncodedValue
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

    Constructors
    Constructor
    Description
    IntEncodedValueImpl(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 Type
    Method
    Description
    final 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
    This method returns the hierarchical name like vehicle.type of this EncodedValue
    final int
    This method sets the dataIndex and shift of this EncodedValue object and potentially changes the submitted init object afterwards via calling next
    final 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
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • IntEncodedValueImpl

      public IntEncodedValueImpl(String name, int bits, boolean storeTwoDirections)
      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 EncodedValue
      bits - 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

      public final int init(EncodedValue.InitializerConfig 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 interface EncodedValue
      Returns:
      used bits
      See Also:
      • EncodedValue.InitializerConfig.next(int)
    • setInt

      public final void setInt(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess, int value)
      Description copied from interface: IntEncodedValue
      This method stores the specified integer value in the specified IntsRef.
      Specified by:
      setInt in interface IntEncodedValue
    • getInt

      public final int getInt(boolean reverse, int edgeId, EdgeIntAccess edgeIntAccess)
      Description copied from interface: IntEncodedValue
      This method restores the integer value from the specified 'flags' taken from the storage.
      Specified by:
      getInt in interface IntEncodedValue
    • 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 interface IntEncodedValue
    • 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 interface IntEncodedValue
    • 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 interface IntEncodedValue
    • isStoreTwoDirections

      public final boolean isStoreTwoDirections()
      Specified by:
      isStoreTwoDirections in interface EncodedValue
      Specified by:
      isStoreTwoDirections in interface IntEncodedValue
      Returns:
      true if this EncodedValue can store a different value for its reverse direction
    • getName

      public final String getName()
      Description copied from interface: EncodedValue
      This method returns the hierarchical name like vehicle.type of this EncodedValue
      Specified by:
      getName in interface EncodedValue
    • toString

      public final String toString()
      Overrides:
      toString in class Object