Enum Direction

  • All Implemented Interfaces:
    Serializable, Comparable<Direction>

    public enum Direction
    extends Enum<Direction>
    The possible flowdirections.

    The normal (exiting) flowdirection schema defines in which cell the drop flows if it has a particular value.

            -1     0     1 
          +-----+-----+-----+
     -1   |  4  |  3  |  2  |
          +-----+-----+-----+
      0   |  5  |  x  |  1  |
          +-----+-----+-----+
      1   |  6  |  7  |  8  |
          +-----+-----+-----+
     

    The entering flowdirection schema defines what value the neighbour cell has to have to flow into the current (center) cell.
            -1     0     1 
          +-----+-----+-----+
     -1   |  8  |  7  |  6  |
          +-----+-----+-----+
      0   |  1  |  x  |  5  |
          +-----+-----+-----+
      1   |  2  |  3  |  4  |
          +-----+-----+-----+
     

    Author:
    Andrea Antonello (www.hydrologis.com)
    • Field Detail

      • col

        public int col
      • row

        public int row
    • Method Detail

      • values

        public static Direction[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Direction c : Direction.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Direction valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • getFlow

        public int getFlow()
      • getEnteringFlow

        public int getEnteringFlow()
      • getOutletValue

        public static int getOutletValue()
      • getDir

        public static Direction getDir​(int col,
                                       int row)
        Get the dir for a particular col/row of the directions schema.
        Parameters:
        col - the col [-1, 1].
        row - the row [1, 1].
        Returns:
        the direction or null for illegal values.
      • getOrderedDirs

        public static Direction[] getOrderedDirs()
        Returns:
        the array of directions, starting from the most eastern, going counterclockwise.
      • forFlow

        public static Direction forFlow​(int flowValue)
        Get the Direction by its exiting flow.
        Parameters:
        flowValue - the value of the (exiting) flow.
        Returns:
        the direction.
      • getDistance

        public double getDistance​(double xRes,
                                  double yRes)