Class GridNode


  • public class GridNode
    extends Node
    A node in the grid environment of a digital elevation model.
    Author:
    Andrea Antonello (www.hydrologis.com)
    • Field Detail

      • elevation

        public double elevation
      • xRes

        public double xRes
      • yRes

        public double yRes
    • Constructor Detail

      • GridNode

        public GridNode​(javax.media.jai.iterator.RandomIter elevationIter,
                        int cols,
                        int rows,
                        double xRes,
                        double yRes,
                        int col,
                        int row,
                        Double novalue)
        The constructor.
        Parameters:
        elevationIter - the elevation model raster iter.
        cols - the cols of the raster.
        rows - the rows of the raster.
        xRes - the x resolution of the raster.
        yRes - the y resolution of the raster.
        col - the col of the current node.
        row - the row of the current node.
    • Method Detail

      • setFloatValueInMap

        public void setFloatValueInMap​(javax.media.jai.iterator.WritableRandomIter map,
                                       float value)
        Description copied from class: Node
        Utility method to set the value of a certain map in the current node position.
        Overrides:
        setFloatValueInMap in class Node
        Parameters:
        map - the map to set the value in. if null, it is ignored.
        value - the value to set.
      • setDoubleValueInMap

        public void setDoubleValueInMap​(javax.media.jai.iterator.WritableRandomIter map,
                                        double value)
        Overrides:
        setDoubleValueInMap in class Node
      • isOutlet

        public boolean isOutlet()
        Returns:
        true if this node can't flow anywhere following the steepest path downstream.
      • isPit

        public boolean isPit()
        Returns:
        true if all cells around the node are higher than the current.
      • isPitFor

        public boolean isPitFor​(List<GridNode> existingConnectedNodes)
      • getSurroundingMin

        public double getSurroundingMin()
        Returns:
        the min value of the surrounding nodes.
      • getWindow

        public double[][] getWindow​(int size,
                                    boolean doCircular)
        Get a window of values surrounding the current node.

        Notes:

        • the size has to be odd, so that the current node can be in the center. If the size is even, size+1 will be used.
        • values outside the boundaries of the raster will be set to novalue. No exception is thrown.
        Parameters:
        size - the size of the window. The window will be a matrix window[size][size].
        doCircular - if true the window values are set to novalue were necessary to make it circular.
        Returns:
        the read window.
      • getWindow

        public List<GridNode> getWindow​(int size)
        Get a window of nodes surrounding the current node.

        Notes:

        • the size has to be odd, so that the current node can be in the center. If the size is even, size+1 will be used.
        Parameters:
        size - the size of the window in cell numbers.
        Returns:
        the window nodes.
      • getElevationAt

        public double getElevationAt​(Direction direction)
        Get the value of the elevation in one of the surrounding direction.
        Parameters:
        direction - the Direction.
        Returns:
        the elevation value.
      • goDownstreamSP

        public GridNode goDownstreamSP()
        Get next downstream node following the steepest path.
        Returns:
        the next downstream node or null if it is an outlet.
      • getFlow

        public int getFlow()
        Get the flow value of this node based in the steepest path.
        Returns:
        the value of flow.
      • getSurroundingNodes

        public List<GridNode> getSurroundingNodes()
        Gets all surrounding nodes, starting from the most eastern. Note that the list contains all 8 directions, but some might be null, if outside a boundary
        Returns:
        the nodes surrounding the current node.
      • getNodeAt

        public GridNode getNodeAt​(Direction direction)
        Get a neighbor node at a certain direction.
        Parameters:
        direction - the direction to get the node at.
        Returns:
        the node.
      • isNeighborOf

        public Direction isNeighborOf​(GridNode otherNode)
        Checks if the supplied node is adjacent to the current.
        Returns:
        the Direction if the two cells touch, else null.
      • isSameValueNeighborOf

        public Direction isSameValueNeighborOf​(GridNode otherNode)
        Checks if the supplied node is adjacent to the current and has the same value.
        Returns:
        the Direction if the two cells touch and have the same value, else null.
      • getValidSurroundingNodes

        public List<GridNode> getValidSurroundingNodes()
        Gets only the valid surrounding nodes, starting from the most eastern.
        Returns:
        the valid nodes surrounding the current node.
      • getEnteringNodesSP

        public List<GridNode> getEnteringNodesSP()
        Gets all surrounding nodes that DO flow into this node by steepest path rule.
        Returns:
        the nodes that flow into this node.
      • getNonEnteringNodesSP

        public List<GridNode> getNonEnteringNodesSP()
        Gets all surrounding nodes that do NOT flow into this node by steepest path rule.
        Returns:
        the nodes that flow into this node.
      • getSlopeTo

        public double getSlopeTo​(GridNode node)
        Calculates the slope from the current to the supplied point.
        Parameters:
        node - the node to which to calculate the slope to.
        Returns:
        the slope.
      • getDistance

        public double getDistance​(GridNode node)
      • getEastElev

        public double getEastElev()
      • getENElev

        public double getENElev()
      • getNorthElev

        public double getNorthElev()
      • getNWElev

        public double getNWElev()
      • getWestElev

        public double getWestElev()
      • getWSElev

        public double getWSElev()
      • getSouthElev

        public double getSouthElev()
      • getSEElev

        public double getSEElev()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isFlat

        public boolean isFlat()