Class ContourBuilder
- java.lang.Object
-
- gov.nasa.worldwind.util.ContourBuilder
-
public class ContourBuilder extends java.lang.Object
Generates contour lines at threshold values in a rectangular array of numeric values. ContourBuilder differs from the ContourLine renderable shape in that ContourBuilder can compute the coordinates of contour lines within arbitrary two-dimensional scalar data, whereas the ContourLine shape operates only on elevation values associated with a World Wind globe. Note that ContourBuilder can be used to compute contour line coordinates within a rectangular array of elevation values.ContourBuilder operates on a caller specified rectangular array. The array is specified as a one dimensional array of floating point numbers, and is understood to be organized in row-major order, with the first index indicating the value at the rectangle's upper-left corner. The domain of array values is any value that fits in a 64-bit floating point number.
Contour lines may be computed at any threshold value (i.e. isovalue) by calling
buildContourLines(double)
orbuildContourLines(double, gov.nasa.worldwind.geom.Sector, double)
. The latter method maps contour line coordinates to geographic positions by associating the rectangular array with a geographic sector. It is valid to compute contour lines for a threshold value that is less than the rectangular array's minimum value or greater than the rectangular array's maximum value, though the result is an empty list of contour lines. The domain of contour line coordinates is the XY Cartesian space defined by the rectangular array's width and height. X coordinates range from 0 to width-1, and Y coordinates range from 0 to height-1.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ContourBuilder.CellInfo
protected static class
ContourBuilder.CellKey
protected static class
ContourBuilder.Direction
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<ContourBuilder.CellKey>
contourCellList
protected java.util.Map<ContourBuilder.CellKey,ContourBuilder.CellInfo>
contourCellMap
protected java.util.List<java.util.List<double[]>>
contourList
protected java.util.List<double[]>
currentContour
protected static java.util.Map<java.lang.Integer,java.util.LinkedHashMap<ContourBuilder.Direction,ContourBuilder.Direction>>
dirNext
protected static java.util.Map<ContourBuilder.Direction,ContourBuilder.Direction>
dirRev
protected int
height
protected double[]
values
protected int
width
-
Constructor Summary
Constructors Constructor Description ContourBuilder(int width, int height, double[] values)
Creates a new ContourBuilder with the specified rectangular array arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addIntersection(ContourBuilder.CellInfo cell, ContourBuilder.Direction dir)
protected void
assembleContourCells(double value)
java.util.List<java.util.List<double[]>>
buildContourLines(double value)
Computes the contour lines at a specified threshold value.java.util.List<java.util.List<Position>>
buildContourLines(double value, Sector sector, double altitude)
Computes the geographic contour lines at a specified threshold value.protected void
clearContourCells()
protected ContourBuilder.CellInfo
getContourCell(int x, int y)
protected ContourBuilder.CellInfo
nextCell(ContourBuilder.CellInfo cell, ContourBuilder.Direction dir)
protected void
putContourCell(ContourBuilder.CellInfo cell)
protected void
traverseContour(ContourBuilder.CellInfo cell, ContourBuilder.Direction dir)
protected void
traverseContourCells()
protected double
valueFor(int x, int y)
-
-
-
Field Detail
-
width
protected int width
-
height
protected int height
-
values
protected double[] values
-
contourCellMap
protected java.util.Map<ContourBuilder.CellKey,ContourBuilder.CellInfo> contourCellMap
-
contourCellList
protected java.util.List<ContourBuilder.CellKey> contourCellList
-
contourList
protected java.util.List<java.util.List<double[]>> contourList
-
currentContour
protected java.util.List<double[]> currentContour
-
dirRev
protected static java.util.Map<ContourBuilder.Direction,ContourBuilder.Direction> dirRev
-
dirNext
protected static java.util.Map<java.lang.Integer,java.util.LinkedHashMap<ContourBuilder.Direction,ContourBuilder.Direction>> dirNext
-
-
Constructor Detail
-
ContourBuilder
public ContourBuilder(int width, int height, double[] values)
Creates a new ContourBuilder with the specified rectangular array arguments. The array is understood to be organized in row-major order, with the first index indicating the value at the rectangle's upper-left corner.- Parameters:
width
- the rectangular array width.height
- the rectangular array height.values
- the rectangular array values, as a one-dimensional array. Must contain at least width * height values. This array is understood to be organized in row-major order, with the first index indicating the value at the rectangle's upper-left corner.- Throws:
java.lang.IllegalArgumentException
- if either the width or the height are less than 1, if the array is null, or if the array length is insufficient for the specified width and height.
-
-
Method Detail
-
buildContourLines
public java.util.List<java.util.List<double[]>> buildContourLines(double value)
Computes the contour lines at a specified threshold value. The returned list represents a collection of individual geographic polylines, which may or may not represent a closed loop. Each polyline is represented as a list of two-element arrays, with the X coordinate at index 0 and the Y coordinate at index 1. The domain of contour line coordinates is the XY Cartesian space defined by the rectangular array's width and height. X coordinates range from 0 to width-1, and Y coordinates range from 0 to height-1.This returns an empty list if there are no contour lines associated with the value. This occurs when the value is less than the rectangular array's minimum value, or when the value is greater than the rectangular array's maximum value.
- Parameters:
value
- the threshold value (i.e. isovalue) to compute contour lines for.- Returns:
- a list containing the contour lines for the threshold value.
-
buildContourLines
public java.util.List<java.util.List<Position>> buildContourLines(double value, Sector sector, double altitude)
Computes the geographic contour lines at a specified threshold value. The returned list represents a collection of individual geographic polylines, which may or may not represent a closed loop. This maps contour line coordinates to geographic positions by associating the rectangular array with a geographic sector. The array's upper left corner is mapped to the sector's Northwest corner, and the array's lower right corner is mapped to the sector's Southeast corner.The domain of contour line coordinates is the geographic space defined by the specified sector. Prior to the mapping into geographic coordinates, contour line X coordinates range from 0 to width-1, and Y coordinates range from 0 to height-1. After the mapping into geographic coordinates, contour line X coordinates range from sector.getMinLongitude() to sector.getMaxLongitude(), and Y coordinates range from sector.getMaxLatitude() to sector.getMinLatitude().
This returns an empty list if there are no contour lines associated with the value. This occurs when the value is less than the rectangular array's minimum value, or when the value is greater than the rectangular array's maximum value.
- Parameters:
value
- the threshold value (i.e. isovalue) to compute contour lines for.sector
- the sector to associate with the rectangular array. The array's upper left corner is mapped to the sector's Northwest corner, and the array's lower right corner is mapped to the sector's Southeast corner.altitude
- the altitude to assign to the geographic positions.- Returns:
- a list containing the geographic contour lines for the threshold value.
- Throws:
java.lang.IllegalArgumentException
- if the sector is null.
-
assembleContourCells
protected void assembleContourCells(double value)
-
traverseContourCells
protected void traverseContourCells()
-
traverseContour
protected void traverseContour(ContourBuilder.CellInfo cell, ContourBuilder.Direction dir)
-
addIntersection
protected void addIntersection(ContourBuilder.CellInfo cell, ContourBuilder.Direction dir)
-
clearContourCells
protected void clearContourCells()
-
nextCell
protected ContourBuilder.CellInfo nextCell(ContourBuilder.CellInfo cell, ContourBuilder.Direction dir)
-
valueFor
protected double valueFor(int x, int y)
-
putContourCell
protected void putContourCell(ContourBuilder.CellInfo cell)
-
getContourCell
protected ContourBuilder.CellInfo getContourCell(int x, int y)
-
-