Class GridNode
- java.lang.Object
-
- org.hortonmachine.gears.libs.modules.Node
-
- org.hortonmachine.gears.libs.modules.GridNode
-
public class GridNode extends Node
A node in the grid environment of a digital elevation model.- Author:
- Andrea Antonello (www.hydrologis.com)
-
-
Field Summary
Fields Modifier and Type Field Description doubleelevationdoublexResdoubleyRes-
Fields inherited from class org.hortonmachine.gears.libs.modules.Node
col, cols, doubleNovalue, floatNovalue, gridIter, intNovalue, isValid, row, rows, touchesBound, touchesNovalue
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)doublegetDistance(GridNode node)doublegetEastElev()doublegetElevationAt(Direction direction)Get the value of the elevation in one of the surrounding direction.doublegetENElev()List<GridNode>getEnteringNodesSP()Gets all surroundingnodesthat DO flow into this node by steepest path rule.intgetFlow()Get the flow value of this node based in the steepest path.GridNodegetNodeAt(Direction direction)Get a neighbor node at a certain direction.List<GridNode>getNonEnteringNodesSP()Gets all surroundingnodesthat do NOT flow into this node by steepest path rule.doublegetNorthElev()doublegetNWElev()doublegetSEElev()doublegetSlopeTo(GridNode node)Calculates the slope from the current to the supplied point.doublegetSouthElev()doublegetSurroundingMin()List<GridNode>getSurroundingNodes()Gets all surroundingnodes, starting from the most eastern.List<GridNode>getValidSurroundingNodes()Gets only the valid surroundingnodes, starting from the most eastern.doublegetWestElev()List<GridNode>getWindow(int size)Get a window of nodes surrounding the current node.double[][]getWindow(int size, boolean doCircular)Get a window of values surrounding the current node.doublegetWSElev()GridNodegoDownstreamSP()Get next downstreamnodefollowing the steepest path.inthashCode()booleanisFlat()DirectionisNeighborOf(GridNode otherNode)Checks if the supplied node is adjacent to the current.booleanisOutlet()booleanisPit()booleanisPitFor(List<GridNode> existingConnectedNodes)DirectionisSameValueNeighborOf(GridNode otherNode)Checks if the supplied node is adjacent to the current and has the same value.voidsetDoubleValueInMap(javax.media.jai.iterator.WritableRandomIter map, double value)voidsetFloatValueInMap(javax.media.jai.iterator.WritableRandomIter map, float value)Utility method to set the value of a certain map in the current node position.StringtoString()-
Methods inherited from class org.hortonmachine.gears.libs.modules.Node
getDoubleValueFromMap, getFloatValueFromMap, getIntValueFromMap, getValueFromMap, isValid, setIntValueInMap, setValueInMap, touchesBound, touchesNovalue
-
-
-
-
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.
-
-
Method Detail
-
setFloatValueInMap
public void setFloatValueInMap(javax.media.jai.iterator.WritableRandomIter map, float value)Description copied from class:NodeUtility method to set the value of a certain map in the current node position.- Overrides:
setFloatValueInMapin classNode- Parameters:
map- the map to set the value in. ifnull, it is ignored.value- the value to set.
-
setDoubleValueInMap
public void setDoubleValueInMap(javax.media.jai.iterator.WritableRandomIter map, double value)- Overrides:
setDoubleValueInMapin classNode
-
isOutlet
public boolean isOutlet()
- Returns:
trueif this node can't flow anywhere following the steepest path downstream.
-
isPit
public boolean isPit()
- Returns:
trueif all cells around the node are higher than the current.
-
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- iftruethe 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- theDirection.- Returns:
- the elevation value.
-
goDownstreamSP
public GridNode goDownstreamSP()
Get next downstreamnodefollowing the steepest path.- Returns:
- the next downstream node or
nullif 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 surroundingnodes, 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
Directionif the two cells touch, elsenull.
-
isSameValueNeighborOf
public Direction isSameValueNeighborOf(GridNode otherNode)
Checks if the supplied node is adjacent to the current and has the same value.- Returns:
- the
Directionif the two cells touch and have the same value, elsenull.
-
getValidSurroundingNodes
public List<GridNode> getValidSurroundingNodes()
Gets only the valid surroundingnodes, starting from the most eastern.- Returns:
- the valid nodes surrounding the current node.
-
getEnteringNodesSP
public List<GridNode> getEnteringNodesSP()
Gets all surroundingnodesthat DO flow into this node by steepest path rule.- Returns:
- the nodes that flow into this node.
-
getNonEnteringNodesSP
public List<GridNode> getNonEnteringNodesSP()
Gets all surroundingnodesthat 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()
-
isFlat
public boolean isFlat()
-
-