Class 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) or buildContourLines(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.

    • 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()
      • clearContourCells

        protected void clearContourCells()
      • valueFor

        protected double valueFor​(int x,
                                  int y)