java.lang.Object
org.apache.sis.internal.feature.j2d.PathBuilder
org.apache.sis.internal.processing.isoline.Joiner

final class Joiner extends PathBuilder
Assembles arbitrary number of PolylineBuffers in a single Java2D Shape for an isoline level. This class extends PathBuilder with two additional features: remove spikes caused by ambiguities, then apply a MathTransform on all coordinate values.

Spikes

If the shape delimited by given polylines has a part with zero width or height (i.e. a spike), truncates the polylines for removing that spike. This situation happens when some pixel values are exactly equal to isoline value, as in the picture below: The spike may appear or not depending on the convention adopted for strictly equal values. In above picture, the spike appears because the convention used in this implementation is:
  • ○: pixel value < isoline value.
  • ●: pixel value ≥ isoline value.
If the following convention was used instead, the spike would not appear in above figure (but would appear in different situations):
  • ○: pixel value ≤ isoline value.
  • ●: pixel value > isoline value.
This class detects and removes those spikes for avoiding convention-dependent results. We assume that spikes can appear only at the junction between two PolylineBuffer instances. Rational: having a spike require that we move forward then backward on the same coordinates, which is possible only with a non-null PolylineBuffer.opposite field.
Since:
1.1
Version:
1.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final org.opengis.referencing.operation.MathTransform
    Final transform to apply on coordinates, or null if none.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Joiner(org.opengis.referencing.operation.MathTransform gridToCRS)
    Creates an initially empty set of isoline shapes.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected int
    filterChunk(double[] coordinates, int lower, int upper)
    Detects and removes spikes for avoiding convention-dependent results.
    protected int
    filterFull(double[] coordinates, int upper)
    Applies user-specified coordinate transform on all points of the whole polyline.

    Methods inherited from class org.apache.sis.internal.feature.j2d.PathBuilder

    append, append, build, createPolyline, snapshot, toString, toString

    Methods inherited from class java.lang.Object

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

    • gridToCRS

      private final org.opengis.referencing.operation.MathTransform gridToCRS
      Final transform to apply on coordinates, or null if none.
  • Constructor Details

    • Joiner

      Joiner(org.opengis.referencing.operation.MathTransform gridToCRS)
      Creates an initially empty set of isoline shapes.
  • Method Details

    • filterChunk

      protected int filterChunk(double[] coordinates, int lower, int upper)
      Detects and removes spikes for avoiding convention-dependent results. See Joiner class-javadoc for a description of the problem.

      We perform the analysis in this method instead of in filterFull(double[], int) on the the assumption that spikes can appear only between two calls to append(…) (because having a spike requires that we move forward then backward on the same coordinates, which happen only with two distinct PolylineBuffer instances). It reduce the amount of coordinates to examine since we can check only the extremities instead of looking for spikes anywhere in the array.

      Overrides:
      filterChunk in class PathBuilder
      Parameters:
      coordinates - the coordinates to filter. Values can be modified in-place.
      lower - index of first coordinate to filter. Always even.
      upper - index after the last coordinate to filter. Always even.
      Returns:
      number of valid coordinates after filtering.
    • filterFull

      protected int filterFull(double[] coordinates, int upper) throws org.opengis.referencing.operation.TransformException
      Applies user-specified coordinate transform on all points of the whole polyline. This method is invoked after filterChunk(double[], int, int).
      Overrides:
      filterFull in class PathBuilder
      Parameters:
      coordinates - the coordinates to filter. Values can be modified in-place.
      upper - index after the last coordinate to filter. Always even.
      Returns:
      number of valid coordinates after filtering. Should be upper, unless some coordinates have been removed. Must be an even number ≥ 0 and ≤ upper.
      Throws:
      org.opengis.referencing.operation.TransformException - if this method wanted to apply a coordinate operation and that transform failed.