java.lang.Object
org.apache.sis.internal.processing.isoline.Tracer

final class Tracer extends Object
Iterator over contouring grid cells together with an interpolator and an assembler of polyline segments. A single instance of this class is created by Isolines.generate(…) for all bands to process in a given image. Tracer is used for doing a single iteration over all image pixels.
Since:
1.1
Version:
1.3
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) final class 
    Builder of polylines for a single level.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.opengis.referencing.operation.MathTransform
    Final transform to apply on coordinates (integer source coordinates at pixel centers).
    (package private) static final int
    Mask to apply on Tracer.Level.isDataAbove for telling that value in a corner is higher than the level value.
    (package private) static final int
    Mask to apply on Tracer.Level.isDataAbove for telling that value in a corner is higher than the level value.
    private final int
    Increment to the position for reading next sample value.
    private final double
    Translation to apply on coordinates.
    private final double
    Translation to apply on coordinates.
    (package private) static final int
    Mask to apply on Tracer.Level.isDataAbove for telling that value in a corner is higher than the level value.
    (package private) static final int
    Mask to apply on Tracer.Level.isDataAbove for telling that value in a corner is higher than the level value.
    private final double[]
    The 2×2 window containing pixel values in the 4 corners of current contouring grid cell.
    (package private) int
    Pixel coordinate on the left side of the cell where to interpolate.
    (package private) int
    Pixel coordinate on the top side of the cell where to interpolate.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tracer(double[] window, int pixelStride, Rectangle domain, org.opengis.referencing.operation.MathTransform gridToCRS)
    Creates a new position for the given data window.
  • Method Summary

    Modifier and Type
    Method
    Description
    private Joiner
    writeTo(Joiner path, PolylineBuffer[] polylines, boolean close)
    Writes all given polylines to the specified path builder.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UPPER_LEFT

      static final int UPPER_LEFT
      Mask to apply on Tracer.Level.isDataAbove for telling that value in a corner is higher than the level value. Values are defined in PixelIterator.Window iteration order: from left to right, then top to bottom.

      Note: there is some hard-coded dependencies to those exact values. If values are changed, search for example for log2(UPPER_RIGHT) in comments.

      See Also:
    • UPPER_RIGHT

      static final int UPPER_RIGHT
      Mask to apply on Tracer.Level.isDataAbove for telling that value in a corner is higher than the level value. Values are defined in PixelIterator.Window iteration order: from left to right, then top to bottom.

      Note: there is some hard-coded dependencies to those exact values. If values are changed, search for example for log2(UPPER_RIGHT) in comments.

      See Also:
    • LOWER_LEFT

      static final int LOWER_LEFT
      Mask to apply on Tracer.Level.isDataAbove for telling that value in a corner is higher than the level value. Values are defined in PixelIterator.Window iteration order: from left to right, then top to bottom.

      Note: there is some hard-coded dependencies to those exact values. If values are changed, search for example for log2(UPPER_RIGHT) in comments.

      See Also:
    • LOWER_RIGHT

      static final int LOWER_RIGHT
      Mask to apply on Tracer.Level.isDataAbove for telling that value in a corner is higher than the level value. Values are defined in PixelIterator.Window iteration order: from left to right, then top to bottom.

      Note: there is some hard-coded dependencies to those exact values. If values are changed, search for example for log2(UPPER_RIGHT) in comments.

      See Also:
    • window

      private final double[] window
      The 2×2 window containing pixel values in the 4 corners of current contouring grid cell. Values are always stored with band index varying fastest, then column index, then row index. The length of this array is (number of bands) × 2 (width) × 2 (height).
    • pixelStride

      private final int pixelStride
      Increment to the position for reading next sample value. It corresponds to the number of bands in window.
    • x

      int x
      Pixel coordinate on the left side of the cell where to interpolate. The range is 0 inclusive to domain.width exclusive.
    • y

      int y
      Pixel coordinate on the top side of the cell where to interpolate. The range is 0 inclusive to domain.height exclusive.
    • translateX

      private final double translateX
      Translation to apply on coordinates. For isolines computed sequentially, this is the image origin (often 0,0 but not necessarily). For isolines computed in parallel, the translations are different for each computation tile.
    • translateY

      private final double translateY
      Translation to apply on coordinates. For isolines computed sequentially, this is the image origin (often 0,0 but not necessarily). For isolines computed in parallel, the translations are different for each computation tile.
    • gridToCRS

      private final org.opengis.referencing.operation.MathTransform gridToCRS
      Final transform to apply on coordinates (integer source coordinates at pixel centers). Can be null if none.
  • Constructor Details

    • Tracer

      Tracer(double[] window, int pixelStride, Rectangle domain, org.opengis.referencing.operation.MathTransform gridToCRS)
      Creates a new position for the given data window.
      Parameters:
      window - the 2×2 window containing pixel values in the 4 corners of current contouring grid cell.
      pixelStride - increment to the position in window for reading next sample value.
      domain - pixel coordinates where iteration will happen.
      gridToCRS - final transform to apply on coordinates (integer source coordinates at pixel centers).
  • Method Details

    • writeTo

      private Joiner writeTo(Joiner path, PolylineBuffer[] polylines, boolean close) throws org.opengis.referencing.operation.TransformException
      Writes all given polylines to the specified path builder. Null PolylineBuffer instances are ignored. PolylineBuffer instances at even index are written with their points in reverse order. All given polylines are cleared by this method.
      Parameters:
      path - where to write the polylines, or null if not yet created.
      polylines - the polylines to write.
      close - whether to close the polygon.
      Returns:
      the given path builder, or a newly created builder if the argument was null.
      Throws:
      org.opengis.referencing.operation.TransformException - if the gridToCRS transform cannot be applied.