Search Results for

    Show / Hide Table of Contents

    Class PrecisionUtility

    Functions for computing precision model scale factors that ensure robust geometry operations. In particular, these can be used to automatically determine appropriate scale factors for operations using limited-precision noding (such as OverlayNG).

    WARNING: the inherentScale and robustScale functions can be very slow, due to the method used to determine number of decimal places of a number. These are not recommended for production use.
    Inheritance
    object
    PrecisionUtility
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: NetTopologySuite.Operation.OverlayNG
    Assembly: NetTopologySuite.dll
    Syntax
    public static class PrecisionUtility

    Fields

    | Edit this page View Source

    MAX_ROBUST_DP_DIGITS

    A number of digits of precision which leaves some computational "headroom" to ensure robust evaluation of certain double-precision floating point geometric operations.

    This value should be less than the maximum decimal precision of double-precision values (16).
    Declaration
    public static int MAX_ROBUST_DP_DIGITS
    Field Value
    Type Description
    int

    Methods

    | Edit this page View Source

    InherentScale(Geometry)

    Computes the inherent scale of a geometry. The inherent scale is the scale factor for rounding which preserves all digits of precision (significant digits) present in the geometry ordinates.

    This is the maximum inherent scale of all ordinate values in the geometry.

    WARNING: this is very slow.
    Declaration
    public static double InherentScale(Geometry geom)
    Parameters
    Type Name Description
    Geometry geom

    A geometry

    Returns
    Type Description
    double

    The inherent scale factor in the geometry's ordinates

    | Edit this page View Source

    InherentScale(Geometry, Geometry)

    Computes the inherent scale of two geometries. The inherent scale is the scale factor for rounding which preserves all digits of precision (significant digits) present in the geometry ordinates.

    This is the maximum inherent scale of all ordinate values in the geometries.
    Declaration
    public static double InherentScale(Geometry a, Geometry b)
    Parameters
    Type Name Description
    Geometry a

    A geometry

    Geometry b

    A geomety (which may be null)

    Returns
    Type Description
    double

    The inherent scale factor in the geometries' ordinates

    | Edit this page View Source

    InherentScale(double)

    Computes the inherent scale of a number. The inherent scale is the scale factor for rounding which preserves all digits of precision (significant digits) present in the numeric value. In other words, it is the scale factor which does not change the numeric value when rounded:

    num = round( num, inherentScale(num) )
    Declaration
    public static double InherentScale(double value)
    Parameters
    Type Name Description
    double value

    A number

    Returns
    Type Description
    double

    The inherent scale factor of the number

    | Edit this page View Source

    RobustPM(Geometry)

    Determines a precision model to use for robust overlay operations for one geometry. The precision scale factor is chosen to maximize output precision while avoiding round-off issues.

    NOTE: this is a heuristic determination, so is not guaranteed to eliminate precision issues.

    WARNING: this is very slow.
    Declaration
    public static PrecisionModel RobustPM(Geometry a)
    Parameters
    Type Name Description
    Geometry a

    A geometry

    Returns
    Type Description
    PrecisionModel

    A suitable precision model for overlay

    | Edit this page View Source

    RobustScale(Geometry)

    Determines a scale factor which maximizes the digits of precision and is safe to use for overlay operations. The robust scale is the minimum of the inherent scale and the safe scale factors.

    Declaration
    public static double RobustScale(Geometry a)
    Parameters
    Type Name Description
    Geometry a

    A geometry

    Returns
    Type Description
    double

    A scale factor for use in overlay operations

    | Edit this page View Source

    RobustScale(Geometry, Geometry)

    Determines a scale factor which maximizes the digits of precision and is safe to use for overlay operations. The robust scale is the minimum of the inherent scale and the safe scale factors.

    WARNING: this is very slow.
    Declaration
    public static double RobustScale(Geometry a, Geometry b)
    Parameters
    Type Name Description
    Geometry a

    A geometry

    Geometry b

    A geometry

    Returns
    Type Description
    double

    A scale factor for use in overlay operations

    | Edit this page View Source

    SafeScale(Geometry)

    Computes a safe scale factor for a geometry. A safe scale factor ensures that rounded number has no more than MAX_ROBUST_DP_DIGITS digits of precision.

    Declaration
    public static double SafeScale(Geometry geom)
    Parameters
    Type Name Description
    Geometry geom

    A geometry.

    Returns
    Type Description
    double

    A safe scale factor for the geometry ordinates

    | Edit this page View Source

    SafeScale(Geometry, Geometry)

    Computes a safe scale factor for two geometry. A safe scale factor ensures that rounded number has no more than MAX_ROBUST_DP_DIGITS digits of precision.

    Declaration
    public static double SafeScale(Geometry a, Geometry b)
    Parameters
    Type Name Description
    Geometry a

    A geometry.

    Geometry b

    A geometry (which may be null).

    Returns
    Type Description
    double

    A safe scale factor for the geometry ordinates

    | Edit this page View Source

    SafeScale(double)

    Computes a safe scale factor for a numeric value. A safe scale factor ensures that rounded number has no more than MAX_ROBUST_DP_DIGITS digits of precision.

    Declaration
    public static double SafeScale(double value)
    Parameters
    Type Name Description
    double value

    A numeric value.

    Returns
    Type Description
    double

    A safe scale factor for the value

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX