Class SubEnvelope

All Implemented Interfaces:
Serializable, Cloneable, Emptiable, org.opengis.geometry.Envelope

final class SubEnvelope extends GeneralEnvelope
A view over a sub-set of the dimensions of a GeneralEnvelope. This class doesn't keep any reference to the original envelope; only the internal array is shared.
Since:
0.3
Version:
0.3
  • Field Details

  • Constructor Details

    • SubEnvelope

      SubEnvelope(double[] coordinates, int beginIndex, int endIndex)
      Creates a new envelope over a portion of the given array. This constructor stores the given reference directly; it does not clone the given array. This is the desired behavior for allowing the SubEnvelope view to be "live".
      Parameters:
      coordinates - the array of coordinate values to store directly (not cloned).
      beginIndex - the index of the first valid coordinate value of the lower corner in the coordinates array.
      endIndex - the index after the last valid coordinate value of the lower corner in the coordinates array.
  • Method Details

    • beginIndex

      final int beginIndex()
      Returns the index of the first valid coordinate value of the lower corner in the coordinates array. This information is used by super-class methods.
      Overrides:
      beginIndex in class ArrayEnvelope
    • endIndex

      final int endIndex()
      Returns the index after the last valid coordinate value of the lower corner in the coordinates array. This information is used by super-class methods.
      Overrides:
      endIndex in class ArrayEnvelope
    • getDimension

      public int getDimension()
      Returns the number of dimensions in the portion of the array used by this SubEnvelope.
      Specified by:
      getDimension in interface org.opengis.geometry.Envelope
      Overrides:
      getDimension in class ArrayEnvelope
      Returns:
      the dimensionality of this envelope.
    • getLower

      public double getLower(int dimension) throws IndexOutOfBoundsException
      Must be overridden, since the super-class method does not handle the index range for performance reasons.
      Overrides:
      getLower in class ArrayEnvelope
      Parameters:
      dimension - the dimension for which to obtain the coordinate value.
      Returns:
      the starting coordinate value at the given dimension.
      Throws:
      IndexOutOfBoundsException - if the given index is negative or is equal or greater than the envelope dimension.
      See Also:
    • getUpper

      public double getUpper(int dimension) throws IndexOutOfBoundsException
      Must be overridden, since the super-class method does not handle the index range for performance reasons.
      Overrides:
      getUpper in class ArrayEnvelope
      Parameters:
      dimension - the dimension for which to obtain the coordinate value.
      Returns:
      the starting coordinate value at the given dimension.
      Throws:
      IndexOutOfBoundsException - if the given index is negative or is equal or greater than the envelope dimension.
      See Also:
    • setRange

      public void setRange(int dimension, double lower, double upper) throws IndexOutOfBoundsException
      Must be overridden, since the super-class method processes the full array as a whole.
      Overrides:
      setRange in class GeneralEnvelope
      Parameters:
      dimension - the dimension to set.
      lower - the limit in the direction of decreasing coordinate values.
      upper - the limit in the direction of increasing coordinate values.
      Throws:
      IndexOutOfBoundsException - if the given index is out of bounds.
    • setEnvelope

      public void setEnvelope(double... corners)
      Must be overridden, since the super-class method processes the full array as a whole.
      Overrides:
      setEnvelope in class GeneralEnvelope
      Parameters:
      corners - coordinates of the new lower corner followed by the new upper corner.
    • isAllNaN

      public boolean isAllNaN()
      Must be overridden, since the super-class method processes the full array as a whole.
      Overrides:
      isAllNaN in class ArrayEnvelope
      Returns:
      true if this envelope has NaN values.
      See Also:
    • setToNaN

      public void setToNaN()
      Must be overridden, since the super-class method processes the full array as a whole.
      Overrides:
      setToNaN in class GeneralEnvelope
      See Also:
    • hashCode

      public int hashCode()
      Must be overridden, since the super-class method processes the full array as a whole.
      Overrides:
      hashCode in class ArrayEnvelope
    • equals

      public boolean equals(Object object)
      Must be overridden, since the super-class method processes the full array as a whole.
      Overrides:
      equals in class ArrayEnvelope
      Parameters:
      object - the object to compare with this envelope.
      Returns:
      true if the given object is equal to this envelope.
    • subEnvelope

      public GeneralEnvelope subEnvelope(int b, int e) throws IndexOutOfBoundsException
      Must be overridden, since the super-class method does not handle the index range for performance reasons.
      Overrides:
      subEnvelope in class GeneralEnvelope
      Parameters:
      b - the index of the first valid coordinate value of the corners.
      e - the index after the last valid coordinate value of the corners.
      Returns:
      the sub-envelope of dimension endIndex - beginIndex.
      Throws:
      IndexOutOfBoundsException - if an index is out of bounds.
      See Also:
    • clone

      public GeneralEnvelope clone()
      If the user wants a clone, copy only the relevant part of the coordinates array.
      Overrides:
      clone in class GeneralEnvelope
      Returns:
      a clone of this envelope.