Class NumberPrecisionReducer

java.lang.Object
com.vividsolutions.jump.geom.precision.NumberPrecisionReducer

public class NumberPrecisionReducer extends Object
Reduces the precision of a number by rounding it off after scaling by a given scale factor.
  • Constructor Details

    • NumberPrecisionReducer

      public NumberPrecisionReducer()
    • NumberPrecisionReducer

      public NumberPrecisionReducer(double scaleFactor)
      A negative value for scaleFactor indicates that the precision reduction will eliminate significant digits to the left of the decimal point. (I.e. the scale factor will be divided rather than multiplied). A zero value for scaleFactor will result in no precision reduction being performed. A scale factor is normally an integer value.
      Parameters:
      scaleFactor - scale factor
  • Method Details

    • scaleFactorForDecimalPlaces

      public static double scaleFactorForDecimalPlaces(int decimalPlaces)
      Computes the scale factor for a given number of decimal places. A negative value for decimalPlaces indicates the scale factor should be divided rather than multiplied. The negative sign is carried through to the computed scale factor.
      Parameters:
      decimalPlaces - number of decimal places
      Returns:
      the scale factor
    • setScaleFactor

      public void setScaleFactor(double scaleFactor)
    • reducePrecision

      public double reducePrecision(double d)