Class WithResolutionBase<T extends FeatureInputWithResolution>

Type Parameters:
T - feature input type, which must include resolution information
Direct Known Subclasses:
FeatureConvertUnits, UnitsWithinRange

public abstract class WithResolutionBase<T extends FeatureInputWithResolution> extends FeatureUnaryGeneric<T>
Base class for a feature that requires input resolution to be calculated.

This class provides a framework for features that depend on image resolution for their calculations. It handles cases where resolution might be missing.

Author:
Owen Feehan
  • Constructor Details

    • WithResolutionBase

      protected WithResolutionBase(Feature<T> feature)
      Creates a new instance with a specified feature.
      Parameters:
      feature - the feature to be used in calculations
    • WithResolutionBase

      public WithResolutionBase()
  • Method Details

    • calculate

      public final double calculate(FeatureCalculationInput<T> input) throws FeatureCalculationException
      Calculates the feature value, handling cases where resolution might be missing.
      Specified by:
      calculate in class Feature<T extends FeatureInputWithResolution>
      Parameters:
      input - the input for feature calculation
      Returns:
      the calculated feature value
      Throws:
      FeatureCalculationException - if an error occurs during calculation
    • calculateWithResolution

      protected abstract double calculateWithResolution(double value, Resolution resolution) throws FeatureCalculationException
      Calculates the feature value using the provided value and resolution.
      Parameters:
      value - the input value to be used in the calculation
      resolution - the resolution to be used in the calculation
      Returns:
      the calculated feature value
      Throws:
      FeatureCalculationException - if an error occurs during calculation
    • isAcceptMissingResolution

      public boolean isAcceptMissingResolution()
      Whether to return Double.NaN (if true) or throw an exception (if false) when image resolution is missing.
    • setAcceptMissingResolution

      public void setAcceptMissingResolution(boolean acceptMissingResolution)
      Whether to return Double.NaN (if true) or throw an exception (if false) when image resolution is missing.